Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to process images in batched for uploading onto websites. I am looking for a script which will provide optimum compression with 1024x768 size using commandline tools like image magic etc.

EDIT: 1 Here is one that I did on MS Windows. orginally It was 3008x2000. I used MS office picture manager to reduce the resolution to 1024x768 and the file size was around 600KB. Then I ran it through sea monster and the final outcome was 1024x768 resolution and the file size was 84 KB. Here is the picture:

alt text

Using the same process with image magic and gives a picture which has a size of 314 KB.

share|improve this question
You should also include information about the type of image (e.g. photograph, screenshot, etc.) and whether or not you want to have some quality loss. – JanC Oct 29 '10 at 10:43

The quickest way to get off the ground is to shoot for something lossless. Resizing obviously can't help but lose data but if you use something like imagemagik to resize, leave the end quality quite high (at least 90%).

To compress, you have several options but the one I've had most luck with is Yahoo's It's an online webservice which means you have to upload your images. However there's a nice Python tool called Smooshy that does all this for you.

This is a lossless operation that basically keeps re-compressing the images until they start to show wear. In some cases, it can make a huge difference to filesize.

The bonus over jpegoptim is you don't have to worry about quality (it's always as good as the original) and it supports all formats. It just takes a little longer and you're bound by Yahoo's terms and conditions (they probably own your soul if you use it, etc).

share|improve this answer
I just ran this over the famfamfam silk icons (used all over the internet). They started off with a collective size of 646.7KB and now they're 50KB smaller. A relative small saving but these were already well compressed. – Oli Oct 29 '10 at 11:49
As these are PNGs I then ran them through pngcrush in -brute mode and that saved me another 3k over the whole batch. Strangely running it against the original set only saved me 1k (was 645k). So if you're dealing with PNGs, Smooshy then pngcrush. – Oli Oct 29 '10 at 11:57

Using ImageMagik is quite easy

mogrify -path destination/path -resize x768 -quality 90 source/path/*.jpg

I've only defined height in the resize in order to ensure the image H/W ratio isn't altered, adjust quality parameter at will.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.