idm
idm

Reputation: 1748

How can I safely remove color scheme profile metadata while generating image preview on server?

User uploads image in browser. On server side I generate preview. I want to remove metadata from preview image. Options:

  1. Remove everything (EXIF, ICC) and save image with the color scheme profile it was uploaded. Is it safe? Will ImageMagic process such images correctly? Will browsers display this properly?

  2. Remove everything and convert the preview to sRGB.

  3. Check ICC color profile and if it is not sRGB - do not remove it.

Any other ideas? Which approach would you reccomend / use in your projects?

Thanks,

Upvotes: 0

Views: 237

Answers (1)

user3344003
user3344003

Reputation: 21627

The hump you face is dealing with the various forms of JPEG file formats.

In a JFIF file, you could remove all the COM and APPn markers (save APP0), to clean out the metadata and have a readable file.

In an Exif file, APP1 is used in place of JFIF's APP0. However, the EXIF APP1 marker can include metadata.

One thing you could try is to simply strip out all APPn and COM markers. It is likely that many browsers would be able to read JPEG streams without a file format specified and that the would assume a 3 component stream is YCbCr and a 1 component stream is grayscale.

Another solution would be to convert everything to JFIF.

Upvotes: 1

Related Questions