Skip to content

Instantly share code, notes, and snippets.

@tvandervossen
Created March 11, 2011 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvandervossen/865869 to your computer and use it in GitHub Desktop.
Save tvandervossen/865869 to your computer and use it in GitHub Desktop.
Add images to the iOS Simulator 'Saved Photos' album
#!/bin/bash
# Adds images to the iOS Simulator 'Saved Photos' album
# Originall from http://ofcodeandmen.poltras.com/2008/11/04/adding-pictures-to-the-simulator/
# You might have to change the simPath and you probably have to remove the contennt of the 'PhotoData'
# directory before the added photos can be found. Note that this overwrites existing images.
simPath="$HOME/Library/Application Support/iPhone Simulator/4.2/Media/DCIM/100APPLE"
if [ -z "$1" ]; then
echo usage: $0 "<folder>"
exit 1
fi
if [ ! -d "$simPath" ]; then
echo $0: path $simPath not found.
exit 1
fi
index=1
for i in `ls $1/*.{jpg,png,gif,bmp,JPG} 2>/dev/null`; do
while [ -f "$simPath/`printf IMG_%04d.JPG $index`" ]; do
let index=$index+1
done
jpgName=`printf IMG_%04d.JPG $index`
thmName=`printf IMG_%04d.THM $index`
echo $i "->" $simPath/$jpgName
sips -s format jpeg $i --out "$simPath/$jpgName" > /dev/null 2> /dev/null || continue
sips -s format jpeg -z 96 96 $i --out "$simPath/$thmName" > /dev/null 2> /dev/null || continue
let index=$index+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment