GNOME Bugzilla – Bug 335615
TIFF offset information is not retained
Last modified: 2013-10-27 22:25:47 UTC
Please describe the problem: When using hugin, images are distorted to fit on a large canvas. Normally, each image is output on a large, blank canvas. To save space, these images can be output as files not much larger than the original, with offset information embedded. Sometimes, these images need to have their alpha channels edited to fine-tune them. However, editing the alpha channels in the Gimp destroys that offset information. Steps to reproduce: 1. Create a panorama with hugin. Set it to generate multiple cropped TIFF files. 2. Stitch these with enblend; the result will be fine. 3. Load and save one of the source TIFFs with Gimp. 4. Stitch these with enblend. Actual results: The offset information will have been clobbered, and the result will be incorrect. Expected results: The offset information should be retained, as long as no cropping or resizing of the image has occurred. Does this happen every time? Yes; this is repeatable. Other information: I'm aware that not everyone has a copy of hugin; small sample images will be attached to this bug.
Output from enblend, before editing: $ enblend -v -z barnscene0000.tif barnscene0001.tif -o test.tif Input image "barnscene0000.tif" RGB UINT8 position=8429x0 size=2294x3549 Input image "barnscene0001.tif" RGB UINT8 position=6654x0 size=2440x3549 and after editing: $ enblend -v -z barnscene0000.tif barnscene0001.tif -o test2.tif Input image "barnscene0000.tif" RGB UINT8 position=0x0 size=2294x3549 Input image "barnscene0001.tif" RGB UINT8 position=0x0 size=2440x3549 The relevant bit from the vigra library included with enblend-2.5 is in src/vigra_impex/tiff.cxx: // XPosition if (TIFFGetField( tiff, TIFFTAG_XPOSITION, &fvalue )) { fvalue = fvalue * x_resolution; position.x = (int)floor(fvalue + 0.5); } // YPosition if (TIFFGetField( tiff, TIFFTAG_YPOSITION, &fvalue )) { fvalue = fvalue * y_resolution; position.y = (int)floor(fvalue + 0.5); }
Created attachment 61826 [details] TIFF image with offset tags set. $ enblend -v -z tmp-scene-0000.tif -o tmp.tif enblend: only one input file given. Enblend needs two or more overlapping input images in order to do blending calculations. The output will be the same as the input.Input image "tmp-scene-0000.tif" RGB UINT8 position=157x0 size=43x66 Output image size: (157, 0) -> (200, 66) = (43 x 66) Loading next image: tmp-scene-0000.tif assembled images bounding box: (3, 2) -> (43, 64)
The way to implement this in GIMP would be to offset the layer according to the offset information and to store the layer offset in the TIFF file when saving.
PNG also supports this; should I file a separate bug for it, or can it be folded into this request? The relevant code from src/vigra_impex/png.cxx: // read offset position.x = png_get_x_offset_pixels( png, info ); position.y = png_get_y_offset_pixels( png, info );
Some commented out code has been added to the respective plug-ins. Basically a workflow dialog has to be added to the tiff-load plug-in, asking whether the offset info has to be used or not, as there are TIFFs out there with bad offsets. We have decided to put this off till after the 2.4 release as it's too late to add it in 2.3.x now.
Resolving as duplicate of bug 419578 which has patches. *** This bug has been marked as a duplicate of bug 419578 ***