~shree
29Sep/091

Resizing dSLR images on my mobile

I'll be carrying my Nikon D80 during this trip. One issue I have faced all these years : how to upload those images ? I'm not carrying my laptop during this tour, and I don't plan to waste time visiting cyber-cafes. My E71 will be my laptop, pretty much.

The solution we came up with is quite simple : instead of the standard SD cards, use micro-SD cards. These fit inside my camera via an adaptor. After I shoot the images, I remove the card, push it inside my mobile, and then upload it to my website using GPRS. That all seems fine, but an image from the camera is upward of 3 MB. That could take ages to upload via GPRS. Also, I don't intend to show the images in the full resolution on this website, since that takes too much bandwidth as well. So I really need to resize the image to something that's small enough : on the order of a 100 kB or so.

I've solved this problem by writing another small python script to resize images. Python for S60 really is neat, and provides all that I need to write this script with ease.

I name my script 0-imgresize.py", and keep it in c:\DATA\python. This way, I can run the script easily, by using the "Run Script" option in the python shell. The script is provided below, and you may use it as you please (freeware). However, if you are using it in another project, you may have to go with GPLv3 since it uses "filesel" from WordMobi, which is released under GPLv3. Not much code there anyway...

import sys
import os
from glob import glob
from appuifw import *

# The following two lines let me import WordMobi's
# file selection abilities
sys.path.append('c:\\DATA\\python\\wordmobidir\\')
from filesel import FileSel

import graphics

sel = FileSel(init_dir="e:\\", mask = r"(.*\.jpeg|.*\.jpg)").run()
if sel is not None:
	print 'Loading %s. Takes a few seconds...'%(sel)
	img = graphics.Image.open(sel)

	rot = selection_list([u"No Rotation", u"Rotated Left", u"Rotated Right"])
	if rot!=0:
		print "Resizing Image..."
	if rot==1:
		img = img.transpose(graphics.ROTATE_270)
	elif rot==2:
		img = img.transpose(graphics.ROTATE_90)
	img2 = img.resize([1024,768],keepaspect=1)

	# derive the output filename from the input filename
	parts = sel.split("\\")
	outfile = 'c:\\data\\resized\\%s'%(parts[-1])

	print 'Saving %s...'%(outfile)
	img2.save(outfile,quality=85)
	note(u"Saved %s"%(outfile), 'info')

Note that this script is tailored for my environment - it outputs to the directory c:\DATA\resized. There's still a 100 MB free on c: on my E71, so no reason for worries there... The resized images will be small - close to a 100 kB. Suits me just fine. Job done. Now, let me go on the trip & shoot some nice images for you to see 🙂

Comments (1) Trackbacks (0)

Leave a comment


No trackbacks yet.