Page 1 of 1
Can image be loaded without loading profiles?
Posted: 2014-06-24T09:04:45-07:00
by johnbuuck
I am encountering some images that contain some very large profiles that I have no need of. Sometimes they fail to load resulting in an exception from Magick::Image.read(), and sometimes they succeed and take up a lot of memory causing my more important allocation of a pixels buffer (that I pass to Magick::Image.write()) to fail.
It looks like I can call strip() after read() to discard such profiles before allocating my pixels buffer and I also see the ping() method that could be used to just access number of rows and columns without loading profiles (but that won't leave the Image in a state where I can call Write() to fill my pixels buffer).
Is there a way to have ImageMagick load the image such that I can get the pixel data without ever loading the profiles?
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T10:12:04-07:00
by fmw42
From
http://www.imagemagick.org/Usage/formats/#jpg_read, it
would appear that you can use +profile or -strip before reading a jpg to strip the profiles and/or other meta data while reading in the file. But I have not tested that, nor do I know if that would be any faster.
So you would have to test or get a reply from one of the IM developers.
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T10:34:50-07:00
by magick
We can support this request with a simple patch, something like -define jpeg:skip-profile ICC, for example. Which image formats do you need to skip profiles? JPEG, TIFF, etc? Can you post a URL to a few of your images with large profiles so we can test the patch?
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T10:39:30-07:00
by fmw42
magick wrote:We can support this request with a simple patch, something like -define jpeg:skip-profile ICC, for example. Which image formats do you need to skip profiles? JPEG, TIFF, etc? Can you post a URL to a few of your images with large profiles so we can test the patch?
Is it possible (or practical) to do this for any image without specifying the image type? For example doing it in a loop over many images (or with mogrify), such that one does not need to get the image type before using this command?
such as
This is just a thought that might be useful, at least as an option. If one wants to limit it to image type and type of profile, that is also fine.
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T11:08:29-07:00
by magick
Not that many image formats support profiles, so jpeg:skip-profile, tiff:skip-profile is reasonable. We prefer specific namespaces. However, if we find we are support this functionality in many image formats, a more general namespace is called for.
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T12:03:34-07:00
by johnbuuck
I should clarify that I am using the term "Profiles" as it is used within a certain portion of the ImageMagick code rather than in the more narrow sense of published standard profiles like ICC, EXIF. Specifically, I am concerned with TIFF images and the TIFFGetProfiles() method of tiff.c which includes the loading of the "tiff:37724" TIFF tag which contains PhotoshopLayerData. Here is a link to an example file:
https://drive.google.com/file/d/0BwGVQe ... sp=sharing.
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T12:38:45-07:00
by snibgo
You might also use exiftool to pre-process files, eg:
Re: Can image be loaded without loading profiles?
Posted: 2014-06-24T18:57:21-07:00
by glennrp
Years ago there were three types of profile that ImageMagick's PNG decoder would recognize: "ICC", "IPTC", and "generic". Now only "ICC" and "generic" remain, with IPTC being a type of "generic" profile. In a PNG input file, "generic" profiles are carried inside the zTXt or iTXt chunk, hex-encoded. Color profiles can be conveyed in either the zTXt or iTXt chunk (as hex-codes) or in the iCCP chunk. Simple color profiles can also be conveyed via the gAMA, cHRM, and sRGB chunks. EXIF is a type of "generic" profile. Adobe "XMP" profiles are conveyed via the iTXt chunk.
Simplest to implement would be an all-or-none choice:
-define png:skip-profiles
if present, skips all profiles and if absent keeps all profiles.
More complex:
-define png:skip-profiles=generic
-define png:skip-profiles=icc