batch resizing photos for web... linux to the rescue!

Discussion in 'Digital Cameras' started by Tombo, Jan 15, 2004.

  1. Tombo

    Tombo Guest

    Just though I would share a mini success...

    Same old problem every time I want to post some images to the web I have
    to reduce the size of the image. This can become tedious using the canon
    zoom browser for more than a few images.

    A quick bit of research and I discovered that I already had the tools to
    help on my linux box, but that suits me just fine :) I have a samba
    share to my linux machine so i just draged the images over using M$
    explorer. Once there a few commands later and I have my scaled images.

    The programs needed are 'djpeg', 'pnmscale' and 'cjpeg' the great thing
    is that using these command line tools is so flexible, I can scale 1 or
    1000 images just as easily.

    The 'djpeg' command converts a jpeg image to a PNM file and 'cjpeg' does
    the reverse. The 'pnmscale' command does exactly what you would think it
    can reduce or enlarge a 'pnm' image.

    So to achieve a 75% reduction all you have to do is string the three
    filters together like so:-

    djpeg largefile.jpg | pnmscale '0.25' | cjepg > smallfile.jpg

    Thats all well and good, the source file remains untouched and a new
    small image is created, but we can make things easier still.
    Its a pain to type the source and destination filenames especially if
    you want to convert more than a few files.

    So all we do is embed these commands in a few lines of shell script and
    I can scale as many images as I want automaticaly reading and creating
    file names:-

    mkdir small
    ls *jpg|while read F
    do
    echo "scaling $F"
    djpeg $F|pnmscale '0.25'|cjepg >small/$F
    done


    Job Done!! I now have a folder called 'small' filled with the reduced
    images.

    Along with 'pnmscale' there are other acompanying filters which I have
    yet to try 'pnmstrech', 'pnmflip', etc

    Tom
     
    Tombo, Jan 15, 2004
    #1
    1. Advertisements

  2. Tombo

    imagejunkie Guest

    Or, if you want to stick within Windows, simply download and install the
    freeware program EasyThumbnails from http://www.fookes.com/ezthumbs/ and it
    will do everything you just described with an easy to use graphical
    interface. If you choose to use the lanczos3 algorithm and add a little
    sharpness (both selected from within the settings menu), you'll be amazed at
    the quality of images it produces. You can batch process all images in a
    directory, tell it to create the output directory you specify, have it
    rename the newly created files based on incremental additions to the
    existing filename, and specify the maximum pixel dimension allowable in
    either axis while still maintaining the proper aspect ratio.
     
    imagejunkie, Jan 15, 2004
    #2
    1. Advertisements

  3. Tombo

    Quercus Guest

    There's no need to convert them to pnm and back to jpg, you can
    manipulate jpgs with convert (google for ImageMagik).

    I wrote some tiny scripts to reduce jpegs, rotate, rename as sequence,
    and so on...

    You can even use scripts from the console or from Konqueror, or even
    GQView (that's my choice to view, organize, manipulate images :)

    I love the flexibility that command line gives you doing such things...

    -Quercus-

    Tombo escribió:
     
    Quercus, Jan 15, 2004
    #3
  4. A quick bit of research and I discovered that I already had the tools to
    No need to wake up linux to do that - the tools are available for Windows
    (at least djpeg and cjpeg are...).

    Cheers,
    David
     
    David J Taylor, Jan 16, 2004
    #4
  5. You don't even need to use pnmscale for this purpose, as djpeg has a
    built-in rescaling option (look at its "-scale" option) which makes
    the process much more efficient. The choice of rescaling factors is
    limited though, to values 1/2, 1/4, and 1/8.
    More options are available with my improved versions (currently unofficial
    forks of original library, will probably go in next official version):

    http://jpegclub.org/djpeg/
    http://jpegclub.org/cjpeg/

    The tools are also available for other systems (Windows etc.).

    Regards
    Guido
     
    Guido Vollbeding, Jan 16, 2004
    #5
  6. While this works fine, I recommend you go find a copy of ImageMagick
    and use it's "convert" command for stuff like this---it's a lot more
    versatile and feature-rich.
     
    Richard Kaszeta, Jan 16, 2004
    #6
  7. Tombo

    Tombo Guest

    Thanks all for your comments, as always there is more than one
    way to skin a cat. I did look at down loading a windows tool
    for the job, but there are so many, and I just will not install any
    old software on my windows pc anymore. My start menu is already
    bigger than than it should be. I find it best to keep just the
    software I use on my PC. So trying out a few different packages
    to find a good one is not attractive.
    The point i was trying to make was that i had the tools already
    on my linux box no download needed.
    I think I will try imagemagic tho probably on linux as thats where
    my webserver lives.

    tom
     
    Tombo, Jan 16, 2004
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.