Skip to content

Instantly share code, notes, and snippets.

@kmakita13714
Last active October 6, 2015 02:32
Show Gist options
  • Save kmakita13714/4e6bb745fae32984efa9 to your computer and use it in GitHub Desktop.
Save kmakita13714/4e6bb745fae32984efa9 to your computer and use it in GitHub Desktop.
graphicsmagickを利用して、@3xの画像ファイルから@2xの画像ファイルを生成するワンライナー
for filename in $(ls *@3x.*); do echo $filename; newFilename=`echo $filename | sed -e 's/@3x/@2x/'`; WIDTH=`gm identify -format "%w" $filename`; (( NEW_WIDTH = $WIDTH / 3 * 2 )); HEIGHT=`gm identify -format "%h" $filename`; (( NEW_HEIGHT = $HEIGHT / 3 * 2 )); echo "${WIDTH}x${HEIGHT}"; echo "${NEW_WIDTH}x${NEW_HEIGHT}"; gm convert -resize "${NEW_WIDTH}x${NEW_HEIGHT}" -unsharp 2x1.4+0.5+0 -quality 100 $filename $newFilename; echo 'done!'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment