I use Picasa Web Album to store my photos online. To save the precious storage at server, I have to change jpeg files before uploading them even for those taken by my old PowerShot S30 (which outputs photos with resolution 2048x1536, which is beyond the display capacity of most monitors today). To reduce file size, one normally need to reduce both resolution and image quality.
So how to adjust images in batch mode? There are various solutions of course. The one I take is to use the combination of find/xargs/mogrify (Note that mogrify modifies files in place. Therefore one may use convert instead of mogrify to preserve original files.) in Linux. Note that mogrify is one of ImageMagick utilities and may need separate installation depending on distribution. Following is my work flow when publishing images online.
Firstly, I select images with my preferred viewer gthumb. Images are rotated if necessary. During browsing, I copy the chosen files to another folder and run the following command in that folder:
find . -iname "*.jpg" | xargs mogrify -resize resize-option -quality quality-option(I find the above command from here.)
Several notes regarding the above command:
- resize-option could be either absolute (e.g. 800x600) or relative (e.g. 50%). For my S30, I use the latter which reduce the photo resolution to 1/4 of its original size.
- quality-option is JPEG compression level. The larger the value, the better the quality, but the larger the file size. I often set the value as 60 to save space.
So for photos from my S30, I use the following command:
find . -iname "*.jpg" | xargs mogrify -resize 50% -quality 60After running above command, photo file size can be reduced around 10 times. This means that I can put more images into my web album.
No comments:
Post a Comment