Paul Irofti


About me: 
 Resume (RO)
 Experience
 Education
 Papers
 Notes
 Hobbies
 LinkedIn

Services: 
 Training
 Development
 System Administration
 Security Audits

Contact: 
 [E-mail address]

Viewing images on the Kindle

This article will show how to display image files on the Kindle without
having to go through Amazon's conversion service, but by merely transferring
files on Kindle's internal storage.

It used to be that you could just transfer a directory filled with JPEGs or
PNGs and it would get picked up and displayed as new once you disconnect
and power-up the device.
I have an old 2011 directory on my Kindle that holds as evidence that in
the past you were able to do that and my hack is largely based on it.

There are two methods that I know of through which you can still display
picture files from a directory on the Kindle:
 ZIP and Transfer
 Transfer and Create Special Files

The special files solution is a hack I found by looking at the files
created by Kindle in my old 2011 directory.
By mimicking their structure I was able to once again enable directories
for viewing. I also wrote a script that does all the work for you.

ZIP and Transfer

Put the image files in a ZIP archive and transfer it somewhere inside
the documents directory found on Kindle's internal storage.
A new item by the name of the archive should pop-up once you disconnect
and power-on the device.

Transfer and Create Special Files

Transfer a directory with the images somewhere inside the documents
directory found on Kindle's internal storage.
Run this script to create internal state and pass the collection it
belongs to as its argument like so:

$ ./add-to-kindle.sh collection

So if you had the picture directory sketches filled with PNGs,
and Kindle's storage mounted on /kindle and you want to add
sketches to the work collection, the following sequence
would add it to your Kindle:

$ cp -r sketches /kindle/documents
$ cd /kindle/documents/sketches
$ ./add-to-kindle.sh work

Afterwards, unmounting /kindle and powering on the device should
display sketches as the most recent item.

That's it!

For the curious, I will next describe what the script does.

The Script

There are two files that Kindle creates inside an image directory:
a bookmark file and a magic file.

The bookmark filename has the following format:

ITEM.COLLECTION_save

So for the sketch example it would look like:

sketch.work_save

The bookmark's first line is a comment containing the accessed date.

#Wed Apr 02 01:59:36 EEST 2014

The script builds this string by using the date(1) command.

DATE=`date +"%a %b %d %T %Z %Y"`
echo "#${DATE}" > "${ITEM}.${COLL}_save"

ITEM is built by looking at the basename(1) of the
pwd(1) output and COLL is received as an argument to
the script:

PWD=`pwd`
ITEM=`basename "${PWD}"`
COLL=$1

The second line is the actual bookmark pointing to the last read item.

LAST=/mnt/us/documents/sketch/art-001.png

The important part is the one starting after documents.
I've seen LAST written both as a full path and as a relative path.

The script builds a path similar to the one I found on my old 2011 entry
just to make sure it works.
So all the paths will start with /mnt/us/documents followed by the
actual directory path within documents.

DIR=`pwd | sed s,[\]\[_a-zA-Z/\-]*/documents,/mnt/us/documents,`

Next, the script picks the first picture listed by ls(1) as its
bookmark and builds the LAST path with it:

FILE=`ls | head -1`
LAST=${DIR}/${FILE}
echo "LAST=${LAST}" >> "${ITEM}.${COLL}_save"

That takes care of the bookmark file.

The magic file is easier to build.
The filename scheme is similar to that of the bookmark:

ITEM.COLLECTION

So for the sketch example it looks like:

sketch.work

Notice the missing _save suffix.

The magic cookie is a null byte. So it's enough to do:

echo -en "\x00" > "${ITEM}.${COLL}"

That's it. With this any directory containing images on your Kindle should
be available for viewing. Enjoy!

Disclaimer

All my experiments were made on a Kindle 3. Let me know if the same trick
works on other models.