Looking for a tool that could optimize image files under Linux?

2

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?

Jichao

Posted 2011-03-11T16:42:17.897

Reputation: 5 245

Answers

5

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.

Majenko

Posted 2011-03-11T16:42:17.897

Reputation: 29 007

1

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

kmarsh

Posted 2011-03-11T16:42:17.897

Reputation: 4 632

1dpi does not matter on the web. there is no such thing. – grapefrukt – 2011-05-26T07:10:09.900

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 – 2011-07-28T12:51:36.973

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ć – 2011-10-02T18:47:16.407

1

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

mbaljeetsingh

Posted 2011-03-11T16:42:17.897

Reputation: 307

0

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).

Goran Jurković

Posted 2011-03-11T16:42:17.897

Reputation: 306