fix2x.sh – automatically create/resize @2x and non-@2x images for IOS

I’ve put together a quick bash script to automatically generate @2x and non-@2x images for IOS.

The script looks through a directory, auto creates missing @2x or non-@2x files, and auto resizes the non-@2x files.

Instructions:

  1. Download fix2x.sh from the Coder Cowboy Scripts GitHub Repo
  2. Copy the script to a directory
  3. Copy your original .png or .jpg files to the directory
  4. Open terminal & do something like the following:
  1. $ cd ~/Desktop/2x/
  2. $ chmod +x fix2x.sh
  3. $ ./fix2x.sh .

Script output will look something like this:

  1. Now processing file: ./normal name.png
  2. CREATING ./normal name@2x.png
  3. Original width: 15, height: 11
  4. Small width: 7, height: 5
  5. /Users/jason/Desktop/2x/normal name.png
  6. libpng warning: zero length keyword
  7. libpng warning: Empty language field in iTXt chunk
  8.   /Users/jason/Desktop/2x/normal name.png
  9. Now processing file: ./twox name@2x.png
  10. Creating ./twox name.png
  11. Original width: 124, height: 92
  12. Small width: 62, height: 46
  13. /Users/jason/Desktop/2x/twox name.png
  14. libpng warning: zero length keyword
  15. libpng warning: Empty language field in iTXt chunk
  16.   /Users/jason/Desktop/2x/twox name.png