David
David

Reputation: 16726

General Image Optimisation for the Web in ImageMagick

I currently do a strait copy() of images that are the correct width/height to go into my site. I was wondering what sort of best practicies in Imagemagick should I be doing to ensure filesize is lowest it can be without loosing quality of the JPEG?

Upvotes: 0

Views: 302

Answers (2)

Bonzo
Bonzo

Reputation: 5299

I resize on upload as even if you read a jpg into Imagemagick and save without doing anything it recompresses it.

If you resize and use -resize all EXIF data is kept; using -thumbnail all EXIF data ( including the embeded thumbnail ) apart from the colour profile is stripped. You can also use -strip on its own which will remove all EXIF data and the colour profile.

To keep the quality in jpg use -quality 100 so you could use something like:

convert input.jpg -strip -quality 100 output.jpg

Upvotes: 0

Baba
Baba

Reputation: 95101

What you can do is that identify the current image quality & size before you do your copy and compression

Example

 identify -verbose rose.jpg

Would return all information including

  • Compression
  • Quality
  • Resolution
  • Depth
  • File Size
  • etc ...

To do your own Optimization

Don't just use fixed values .. used the information too calculated possible and ideal compression and size for the image

Example

If an image quality is 70 and 60 is your bench mark .. all you need so do is reduce it by 10% and its it is 100 reduce by 40% .. at all times you would images with the same level of quality

Upvotes: 1

Related Questions