Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created June 16, 2014 13:48
Show Gist options
  • Save neonichu/24a617d40c12539b2052 to your computer and use it in GitHub Desktop.
Save neonichu/24a617d40c12539b2052 to your computer and use it in GitHub Desktop.
Create 1x versions of all images in the CWD.
#!/bin/sh
#
# Create 1x versions of all images in the CWD.
#
IFS=$'\n'
for file in `ls *@2x*`
do
new_file=`echo $file|sed 's/@2x//g'`
size=`identify "$file" 2>/dev/null|cut -d ' ' -f3`
width=`echo $size|cut -dx -f-1`
new_width=`expr $width / 2`
height=`echo $size|cut -dx -f2-`
new_height=`expr $height / 2`
convert "$file" -resize ${new_width}x$new_height "$new_file" 2>/dev/null
done
@neonichu
Copy link
Author

Shell programming, how does it even work?

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