When you want to keep images on your Zaurus or mobile device, it's a good idea to resize them from megapixels to the display size. This will make loading images quicker, reduce the memory load and be more efficient with storage.

This is a Perl script I've been using for a while to generate display size images. It will put the resized images in a new directory called Z and adds a postfix to the filename, i.e. image cimg0001.jpg will be resized to Z/cimg0001-z.jpg; this is so you don't accidentally copy the resized image over the original and you know which image it came from.

Images will be rotated to make the best use of the display. The script is intelligent enough to only affect image files (based on the filename extension). When I make a thumbnail I like to give it a postfix of -s so those images will be ignored.

You need to have ImageMagick installed. Just cd to the directory with the images and run the script. Here it is:

#! /usr/bin/perl
# Brief : Script to resize images to Zaurus resolution
# File  : resize.pl
# Author: Lyndon Hill
# Date  : 2011.04.09 Changed to use identify.

# Images will be dumped in a directory called "Z"

use File::Basename;

# If your Zaurus is not VGA then edit the next line:
$newwidth = 640; $newheight = 480;

# ***** No more edits are required. *****

if($#ARGV != -1)
{
  print "Usage: resizez.pl\n";
  exit;
}

# List of valid image extensions
@extensions = ("jpg", "jpeg", "png", "ppm", "bmp");
$numext = @extensions;

$newdimensions = $newwidth . "x" . $newheight;
$resizedir = 0;

# Get a directory listing
$ls = `ls -l`;
@lines = split /\n/, $ls;
$numlines = @lines;

# Check each file
for($l = 1; $l < $numlines; $l++)
{
  if(substr($lines[$l],0,1) eq "d")
  {
    # skip directories
    next;
  }

  @info = split /\ /, $lines[$l];
  $infosize = @info;
  
  $name = $info[$infosize-1];
  $size = $info[$infosize-4];

  ($basename,$dir,$ext) = fileparse($name,'\..*');

  $final = substr($basename, length($basename)-2, length($basename));

  if($final eq "-s") { next; } # skip thumbnails

  $validimageext = 0;
  $ext = substr($ext, 1);

  # Check file extension is an image we can deal with
  $lcext = lc($ext);               # Make lower case
  foreach $testext (@extensions) {
    if($testext eq $lcext) {
      $validimageext = 1;
      last;
    }
  }

  if(!$validimageext)
  {
    next;
  }

  $zaurusname = $basename . "-z." . $ext;

  # Check that the Z directory has been made
  if(!$resizedir)
  {
    `mkdir Z`;
    $resizedir = 1;
  }

  # Get size of image
  $imgsummary = `identify $name`;

  ($fullpath, $type, $res, $geom) = split /\ /, $imgsummary;
  ($resx,$resy) = split /x/, $res;

  if(($resx == $newwidth) && ($resy == $newheight))
  {
    # No need to resize
    print "File $name will be copied to Z/$zaurusname\n";
    `cp $name Z/$zaurusname`;
    next;
  }

  if($resx > $resy)
  { 
    print "File $name will be resized to Z/$zaurusname\n";
    `convert $name -resize $newdimensions Z/$zaurusname`;
  }
  else
  {
    print "File $name will be resized and rotated to Z/$zaurusname\n";
    `convert $name -rotate 90 -resize $newdimensions Z/$zaurusname`;
  }
}

exit;