Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In photoshop, there is an option ‘Save for web device’ which allows me to save the orginal large (> 5K) JPEG file to a small (<1K) png file.

But now I want to do it for many images in a folder under linux, which tool should I use?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

The convert command of ImageMagick can do just that.

$ convert oldfile.jpg -quality 4 newfile.jpg

That will take the original JPEG and re-compress it to quality level 4 and save it out as a new JPEG file.

There are many other things that convert can do including resizing, cropping, filtering - infact most things that Photoshop can do interactively.

share|improve this answer

For the web you want to convert to 72 dpi. ImageMagick has an option for that, and can do batch:

convert *.jpg -resample 72 -quality 80% -set filename:orig %t  prefix%[filename:orig].jpg
share|improve this answer
1  
dpi does not matter on the web. there is no such thing. –  grapefrukt May 26 '11 at 7:10
    
72dpi is simply a convention that allows the developer to scale photographs for web use. If viewed at 72dpi the photo becomes huge, but it will end up in a small corner of a web page, you are shipping unnecessary data over the http link and forcing the client computer to do a lot of image rescaling. This is OK for a desktop but not so great for phones, ARMs, Atoms, etc. Also people using 2G/3G/4G are usually paying for their data in some fashion, or are capped, and don't appreciate downloading a 400MB JPG when a 4MB will do nicely. Cropping and resizing before publishing is simple courtesy. –  kmarsh Jul 28 '11 at 12:51
    
Like grapefrukt said, DPI simply doesn't matter on the web. The common misconception is that 72 dpi is needed for better web optimization. It isn't. It is just a number that shows relation between number of pixels present in the image and it's printing size. There is a certain number of pixels present in the image. Those pixels might be compressed using higher or lower compression level, which affects final image quality. But inches simply doesn't matter here. So - for the web you don't need to convert to 72dpi :). You can, but it doesn't matter at all. –  Goran Jurković Oct 2 '11 at 18:47

You can use the photoshop with Wine, and then can use the save for web and devices.

share|improve this answer

For better optimization it could be good idea to strip exif headers. They hold metadata about image and can be stripped out for even smaller file size. For this, you should check '-thumbnail' and '-strip' options when using convert, or you can use program called jhead ( you'll probably have to install it).

share|improve this answer

Your Answer

 
discard

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.