Skip to content

Instantly share code, notes, and snippets.

@jamesacklin
Last active January 19, 2022 15:56
Show Gist options
  • Save jamesacklin/d4c1ed4a4261cf2e7fa35eeb697b8294 to your computer and use it in GitHub Desktop.
Save jamesacklin/d4c1ed4a4261cf2e7fa35eeb697b8294 to your computer and use it in GitHub Desktop.
Make a desktop-sized image from any picture
#!/bin/bash
source=$1
dest=${source::-4}_wp.jpg
colors=($(convert $source +dither -colors 2 -define histogram:unique-colors=true -format "%c" histogram:info: | awk '//{print $3}'))
convert $source \
-gravity center \
-resize 1280x1280 \
-bordercolor ${colors[1]} \
-border 10 \
-bordercolor ${colors[0]} \
-border 33% \
-background ${colors[0]} \
-gravity east \
-extent 3840x2160 \
+repage \
$dest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment