Replacing profiles without decompressing/compressing image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
mact

Replacing profiles without decompressing/compressing image

Post by mact »

Moin,

I am sure I have read about a way to deal with image profiles (IPTC, color profiles etc) without actually decompressing and recompressing the image, but I cannot find the tag/flag any more that lets me do it.

Could someone please point me in the right direction?

Thanks!

Marc
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

See http://www.cit.gu.edu.au/~anthony/graph ... jpg_non_im for a discussion of dealing with profiles
Last edited by magick on 2006-09-06T09:33:34-07:00, edited 1 time in total.
mact

Post by mact »

Hi,

thanks for the link, unfortunately only the common tools are discussed there (like exiftool and the like). I would like to stick with one toolset (or library). Currently I am doing the IPTC-replacement myself (by means of a very simple JPEG parser) but I'd love to use IM core to do deal with non-image data in an image file conveniently.

Marc
sacha

Re: Replacing profiles without decompressing/compressing image

Post by sacha »

There was this in the announcement of ImageMagick 5.4.7:
+ Lossless JPEG embedding (similar to provided by iptcutil) is supported.
Does anyone have any sample code?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Replacing profiles without decompressing/compressing image

Post by anthony »

Lossless JPEG is only supported with the NEW JPEG2000 library.
The old library does not understand lossless.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sacha

Re: Replacing profiles without decompressing/compressing image

Post by sacha »

The OP is about embedding profiles into JPEGs "losslessly" i.e. without decompressing and recompressing the JPEG. I believe this can be done with iptcutil (see the jpegembed function), so I'd understood the changelog to indicate that this was now possible via the ImageMagick APIs.

I think lossless JPEG ("quality 100") is a red herring.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Replacing profiles without decompressing/compressing image

Post by anthony »

IM is basically a image processor. It will always read and write the image data, and for normal jpeg that means it is always lossy.

It is not primarally a profile handler, or try to handles specific format problems, though it does some of that for image conversion.

For lossless profile handling IM is NOT the program to use. That is whay I listed thos non-im tools for lossless JPEG handling.

You will be hard pressed to find any tool that does all things.
JohnNavarra wrote:Sometimes we need a hammer and sometimes a screwdriver.
IM come close, for image conversion, but it can never do everything! That is imposible!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sacha

Re: Replacing profiles without decompressing/compressing image

Post by sacha »

Ok. It was the message in the Changelog that made me think ImageMagick might be able to do it; it would still be interesting to know what that was referring to.

For what it's worth, I think many lossless operations on the image container might be possible if file container parsing were decoupled from decoding.

If you look at the source for many of the coders, they do just that. They find out as much as they can about the image, setting up data structures, and then decode the image into the pixel cache.

At the API level, perhaps it could be something like:

// read an image file without decoding the image data
MagickOpenImage(filename)

This would parse the image file, extracting all the relevant information (height, width, colourspace, profiles etc) but not decode the image, just read the bytes into memory (or some structure telling it how to extract the bytes, e.g. a file descriptor, offset and byte length). This would allow operations on the container (setting profiles etc) without modifying the image data.

Anyway thanks for your responses; I'll see if I can find another tool to do what I need.
Post Reply