Thursday, July 19, 2007

Compression in RMagick

Whenever you upload an image, and resize it using rmagick library, it will do the resize operation with default compression techniques. Sometimes the user may upload images which are directly from digital cameras, these images contain lots of metadata including color profiles. Anyway We don’t need any of these color profile information in the resized images :)

You can remove those color profiles from your images using the RMagick method called "delete_profile" (an instance method of Image class in RMagick library).

or You can use the method "profile!("*", nil)" to delete all the color profiles.

you have to use the above methods like this

image.delete_profile(profile_name)

if you put a specific profile name like "IPTC" or "ICC", it will delete the specified profile.

if you use image.delete_profile("*"), it will delete all the profiles.


image.profile!("*", nil)

This will remove all the profiles of the images.


Note :

RMagick does not automatically remove profiles when resizing images. If you are trying to make your JPEG thumbnail images as small as possible, use profile! to remove any profiles from the image as well.


And there is one more method called "strip!" strips an image of all profiles and comments.

image.strip!

This will Strip an image of all profiles and comments.



0 comments: