Using ImageMagick for sanitising images
Posted: 2009-10-10T11:13:44-07:00
Hi,
Suppose I have a web forum that allows users to upload images. Because images uploaded by a user will be shown to any visitor, I want to make sure that the image data is not purposedly broken in order to exploit some weakness in the browser's image rendering engine [*]. It would also be useful to eliminate extra stuff (comments, EXIF data) present in the images.
Could I perform this sanitising with ImageMagick? Basically, I want a script that inputs a (PNG | JPG | GIF) and outputs a visually identical (PNG | JPG | GIF) that is guaranteed to conform to the standard and does not contain extra hidden data. In the JPG case it would also be nice if the filter would not reencode the image, as not to degrade the quality.
Any thoughts?
Thank you!
J. Smark
[*] Yes, I realise there is a separate issue concerning the legality/tastefulness of the image content itself. That is handled separately, and I don't want to bring it into this discussion.
Suppose I have a web forum that allows users to upload images. Because images uploaded by a user will be shown to any visitor, I want to make sure that the image data is not purposedly broken in order to exploit some weakness in the browser's image rendering engine [*]. It would also be useful to eliminate extra stuff (comments, EXIF data) present in the images.
Could I perform this sanitising with ImageMagick? Basically, I want a script that inputs a (PNG | JPG | GIF) and outputs a visually identical (PNG | JPG | GIF) that is guaranteed to conform to the standard and does not contain extra hidden data. In the JPG case it would also be nice if the filter would not reencode the image, as not to degrade the quality.
Any thoughts?
Thank you!
J. Smark
[*] Yes, I realise there is a separate issue concerning the legality/tastefulness of the image content itself. That is handled separately, and I don't want to bring it into this discussion.