ImageMagick
                                
                                 ImageMagick copied to clipboard
                                
                                    ImageMagick copied to clipboard
                            
                            
                            
                        magick cannot get correct physic size of the xcf image
ImageMagick version
7.1.0-47 Q16-HDRI x86_64 d91623c12:20220827
Operating system
Linux
Operating system, version and so on
Ubuntu20.04
Description
The magick cannot report correct physic size of xcf file created by gimp, instead it always report 72inch.
I created a 300inchx300inch xcf file with gimp and export it as png. Then the magick identify can report the png size correct. But the xcf file is reported as 72 inch.
Steps to Reproduce
magick identify -units pixelsperinch -format "%w x %h %x x %y\n" test-size.png 
1920 x 1080 300 x 300
magick identify -units pixelsperinch -format "%w x %h %x x %y\n" test-size.xcf 
1920 x 1080 72 x 72
1270 x 600 72 x 72
Images
The source code in xcf.c (https://github.com/ImageMagick/ImageMagick/blob/main/coders/xcf.c) says:
        /* BOGUS: we don't write these yet because we aren't
              reading them properly yet :(
              image->resolution.x = xres;
              image->resolution.y = yres;
        */
... so IM doesn't (yet) correctly read resolutions from XCF files.
Imagemagick can, I believe, read the older GIMP xcf format, but not the current one. It is quite complex and needs a fair bit of work on it. Users are free to develop that and contribute to Imagemagick.
@fmw42 I would like to help, but I do not know where to start with. I cannot find any definition or documentation about the XCF format anywhere. All open source 3rd party software claiming to handle xcf, such as krita, cannot read the physic size or density info... If you can point me a direction, I can try to implement it.
well I found something in the source code: https://github.com/GNOME/gimp/blob/cb7f9f86a8aa72c46bfec02921ed6afffca332e1/app/xcf/xcf-load.c#L1168
See the GIMP code.
hmm... comparing the IM and gimp/xcf-load.c, I found in IM we did not handle any PROP_FLOAT_* so I guess missing counterpart of xcf_read_float is the problem?
hmm... but we do have ReadBlobFloat(). Maybe this will be an easy fix?
It seems that we can indeed use the ReadBlobFloat to read the resolution. I am now getting the following output with the patch that I just pushed:
I:\issues\im7\5549>identify -format "%w x %h %x x %y\n" test-size.xcf
1920 x 1080 300 x 300
1270 x 600 300 x 300
This will become available in the next release.