Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created August 19, 2015 19:43
Show Gist options
  • Save gene1wood/3b4b37d5a438871b8876 to your computer and use it in GitHub Desktop.
Save gene1wood/3b4b37d5a438871b8876 to your computer and use it in GitHub Desktop.
Search through Eclipse jar files and images and resize them for HiDPI / Retina displays
#!/bin/bash
# Original written by Redsandro in http://stackoverflow.com/a/29032397/168874
for J in *.jar
do
d="`mktemp --directory`"
trap 'rm -rf "$d"' EXIT
f="`readlink -f \"$J\"`"
echo "Extracting $J..."
unzip -q "$f" -d "$d"
echo "Processing images in $J..."
find "$d" -name "*.gif" -exec sh -c "expr \$(identify -format \"%h\" {}) \<= 16 > /dev/null" \; -exec convert {} -resize 200% {} \; -printf "%f resized\n"
echo "Compressing $J..."
mv -f "$f" "$f.`date +%Y%m%d%H%M%S`.bak"
pushd "$d" >/dev/null
zip -qr "$f" .
popd >/dev/null
rm -rf "$d"
done
echo "Processing all images outside of jars..."
find -name "*.gif" -exec sh -c "expr \$(identify -format \"%h\" {}) \<= 16 > /dev/null" \; -exec convert {} -resize 200% {} \; -printf "%f resized\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment