Putting Images on the iPod Touch from Linux


Idea

I wanted to put images on my iPod Touch without using iTunes since, as most of us know, there is no good way to use it from Linux. It turns out there is a magic directory on the iPod Touch where it saves images from Safari. I simply looked at how it saved them, and applied it on my box here at home.

Requirements

  • Jailbroken iPod Touch (I used WinPWN), with OpenSSH installed and working (the root password is alpine)
  • Firmware 2.0 (Though, 1.x may work, I just haven’t tried it)
  • A Linux box with a bash shell
  • Cool images
  • convert and mogrify from ImageMagick installed

Method

These instructions might work for the iPhone as well. YMMV

All of your images must be in the format IMG_XXXX.YYY where XXXX is a number < 9999, and YYY is either JPG or THM (THM is a thumbnail). To rename our files, I use a simple trick I outlined in my last post:


EII=4; for i in *.jpg; do ls $i; \
NEWNAME=IMG_00`printf "%02d" $EII`.JPG; \
echo Renaming $i to $NEWNAME; \
mv $i $NEWNAME; EII=`expr $EII + 1`; done

That will rename all the JPEG files in order from 4 to, in my case, 62. Now, I have to make the thumbnails:


for i in `ls *.JPG | cut -d '.' -f 1`; do \
convert $i.JPG -resize 75x75! $i.THM; \
done

The 75×75! part makes sure they are exactly those dimensions. You end up with something like the following:


IMG_0004.JPG  IMG_0016.JPG  IMG_0028.JPG  IMG_0040.JPG  IMG_0052.JPG
IMG_0004.THM  IMG_0016.THM  IMG_0028.THM  IMG_0040.THM  IMG_0052.THM
IMG_0005.JPG  IMG_0017.JPG  IMG_0029.JPG  IMG_0041.JPG  IMG_0053.JPG
....

Now, note that the iPod can only display images under 100KB (to my knowledge). If your high-res image is too large, it will just display the magnified 75×75, which is really ugly. So, make sure all your images fit that description, and if they don’t, mogrify -resize them until they do (or take other measures as necessary). I used this:


mogrify -resize 400x *.JPG

All my images turned out to be between 30 and 90 KB. This also keeps the aspect ratio, unlike the 75×75!.

Now, SSH into your iPod (if you can’t do this yet, google it). You should have the following file:


/var/mobile/Media/DCIM/.MISC/Info.plist

Open this file in vi, and observe the plist>dict>integer part of the hierarchy:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>LastFileGroupNumber-100</key>
        <integer>62</integer>
</dict>
</plist>

So, I put 62 in there since the last image I have is numbered 0062. It’s a very simple idea. Now, just load them onto the iPod:


scp IMG_00* root@ipod:/var/mobile/Media/DCIM/100APPLE/

Let’s have a look from the iPod console!


HanksTouch:/var/mobile/Media/DCIM/100APPLE root# ls
IMG_0002.JPG  IMG_0014.THM  IMG_0027.JPG  IMG_0039.THM  IMG_0052.JPG
IMG_0002.THM  IMG_0015.JPG  IMG_0027.THM  IMG_0040.JPG  IMG_0052.THM

Beautiful. Now, to test it…