Skip to content

Instantly share code, notes, and snippets.

@akagr
Last active December 19, 2018 18:17
Show Gist options
  • Save akagr/0560e0873b4d0a95262e94f9ffee16ee to your computer and use it in GitHub Desktop.
Save akagr/0560e0873b4d0a95262e94f9ffee16ee to your computer and use it in GitHub Desktop.
Squares up rectangular images by filling empty space with blur of same image
# To get the resolution, multiply 118 by cm. For example, 7 cm image at 300ppi will be 7 * 118 = 826 px
RESOLUTION=826
convert $1 -resize ${RESOLUTION}x${RESOLUTION}^ -gravity center -crop ${RESOLUTION}x${RESOLUTION}+0+0 +repage -blur 0x8 temp.jpg
convert temp.jpg $1 -resize ${RESOLUTION}x -gravity center -composite -matte "./output/$1-out.jpg"
@akagr
Copy link
Author

akagr commented Sep 18, 2018

Sample usage

> chmod +x squareup.sh
> ./squareup.sh myimage.jpg

Example output:

apple-imac-retina-5k-official-wallpapers jpg-out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment