Google
 

Monday, March 19, 2007

Batch jpeg image resize in linux

The (jpeg) photos we take using digital camera are just too large so to save space and bandwidth, it's better to resize them before uploading them to online photo sharing sites like Picasa or Flickr. Here's how i do it in linux..

Basically two commands are used here.
1. djpeg - decompress a JPEG file to an image file
2. cjpeg - compress an image file to a JPEG file

So to resize, i run this script on a folder containing the image files.

#!/bin/sh

mkdir resized
for i in *.JPG
do
echo 'Resizing image..' $i
djpeg -scale 1/2 $i | cjpeg > resized/$i
done


After script is done, a folder named 'resized' is created containing the resized images..


EDIT:
Both the program djpeg/cjpeg isn't installed by default, they're part of libjpeg-progs package. Under Ubuntu you can get it by

sudo apt-get install libjpeg-progs

(thanx subir dai for pointing this out)

6 comments:

  1. thanks for the info. was helpful for me.
    keep it up with more tips and tricks

    ReplyDelete
  2. Okay nice blog you have got.
    I suggest you to change the template. Find one to which you can add second side bar. I hope you can edit the css to do that. (I cannot do! :P)

    http://keshuvko.blogspot.com

    all the best

    ReplyDelete
  3. Hey jwalanta, that was really helpful! But it would've been better if u'd mentioned about the package that installs cjpeg and djpeg. They are part of the package 'libjpeg-progs' :) for others information.

    ReplyDelete
  4. i cannot but do like you said... sorry...

    Mr Editor

    ReplyDelete
  5. you want to need Background Remover App? so install app and remove the background of photos.

    ReplyDelete
  6. I am thinking that in this time you should give a try to this new app Car Crash Simulator Royale Mod Apk : which is now most trending app in the world.

    ReplyDelete