At first, there was an issue that caught my eye. I am using magick++, but am able to recreate an example of the issue with this command:
Code: Select all
convert.exe progressive.jpg nonprogressive.jpg
As I dug deeper into the IM internals, I discovered that there is an issue, but I don't know where the problem lies. It's either one of two issues (or both):
1- there doesn't seem to be a way to read/populate an ImageInfo struct for an image, unless the user ( me ) does it manually by reading Image values and setting the appropriate ImageInfo property.
2- some encoders (in this case, JPEG) use the ImageInfo struct to determine how to write the file. However, since the ImageInfo struct never seems to be populated unless I do it manually, a simple command (like the one I posted above) corrupts/changes the image unexpectedly. In debugging, I can see that the Image* contains the correct info, but the ImageInfo* has the wrong data (I'm assuming the values are ImageInfo defaults). And since the JPEG encoder uses the ImageInfo struct for it's decision-making, its writing the incorrect values. Example: jpeg.c, line 2171, for the progressive property.
So, should the image encoders use the Image pointer, or should they use the ImageInfo pointer? If the answer is the former, then jpeg.c is wrong. If the answer is the latter, how does a programmer like me reliably populate the ImageInfo struct based on an Image? And why doesn't convert.exe do it? ( I'm assuming the same problem applies to the other utility programs, since they all share the same code ). It appears as though SyncImageSettings copies ImageInfo to an image, but there doesn't seem to be a method to do the reverse.
Please advise, thanks!