PSD->TIFF conversion loses layer offsets.

Bug #37510 reported by Adam Buchbinder
4
Affects Status Importance Assigned to Milestone
imagemagick (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

I'm stitching TIFFs together with hugin and enblend. enblend relies on offset information created by hugin. Hugin creates multilayer TIFFs, which are edited in Gimp (if the layer masks need tweaking) and saved as multilayer PSDs (as Gimp cannot save multilayer TIFFs, see GNOME bug 335975). These PSDs have layer offset information:

$ identify beach.psd
beach.psd[0] PSD 6630x1906 DirectClass 73.2mb 50.590u 1:59
beach.psd[1] PSD 3052x1906 3052x1906+3578+0 DirectClass 73.2mb 49.860u 1:58
beach.psd[2] PSD 3146x1906 3146x1906+1533+0 DirectClass 73.2mb 49.520u 1:58
beach.psd[3] PSD 3027x1906 3027x1906+0+0 DirectClass 73.2mb 49.170u 1:57

Layer 0 is the entire canvas, presumably; this is a composite of three images.

The +x+y coordinates are what I'm interested in. enblend doesn't support stitching from multilayer images, so it can either use an image the size of the final canvas, or an image with offset information, as the layers here are interpreted.

The PSD was converted to TIFF:

$ convert -verbose -compress lzw beach.psd beach-tmp%d.tif
beach.psd[0] PSD 6630x1906 DirectClass 73.2mb 52.870u 1:12
beach.psd[0] PSD 3052x1906 3052x1906+3578+0 DirectClass 73.2mb 52.130u 1:11
beach.psd[0] PSD 3146x1906 3146x1906+1533+0 DirectClass 73.2mb 51.790u 1:11
beach.psd[0] PSD 3027x1906 3027x1906+0+0 DirectClass 73.2mb 51.430u 1:10
beach.psd PSD 6630x1906 DirectClass 73.2mb
beach.psd PSD 3052x1906 3052x1906+3578+0 DirectClass 73.2mb
beach.psd PSD 3146x1906 3146x1906+1533+0 DirectClass 73.2mb
beach.psd PSD 3027x1906 3027x1906+0+0 DirectClass 73.2mb
TIFF Directory at offset 0x0
  Image Width: 6630 Image Length: 1906
  Resolution: 72, 72 (unitless)
  Bits/Sample: 1
  Compression Scheme: LZW
  Photometric Interpretation: min-is-white
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 9
  Planar Configuration: single image plane
  Photoshop Data: <present>, 14 bytes
  Software: ImageMagick 6.2.3 01/24/06 Q16 http://www.imagemagick.org
  DocumentName: beach-tmp0.tif
beach.psd=>beach-tmp0.tif[0] PSD 6630x1906 DirectClass 31kb 0.570u 0:01
TIFF Directory at offset 0x0
  Image Width: 3052 Image Length: 1906
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 1
  Planar Configuration: single image plane
  Photoshop Data: <present>, 14 bytes
  Software: ImageMagick 6.2.3 01/24/06 Q16 http://www.imagemagick.org
  DocumentName: beach-tmp1.tif
  Predictor: horizontal differencing 2 (0x2)
beach.psd=>beach-tmp1.tif[1] PSD 3052x1906 3052x1906+3578+0 DirectClass 8.1mb 1.520u 0:03
TIFF Directory at offset 0x0
  Image Width: 3146 Image Length: 1906
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 1
  Planar Configuration: single image plane
  Photoshop Data: <present>, 14 bytes
  Software: ImageMagick 6.2.3 01/24/06 Q16 http://www.imagemagick.org
  DocumentName: beach-tmp2.tif
  Predictor: horizontal differencing 2 (0x2)
beach.psd=>beach-tmp2.tif[2] PSD 3146x1906 3146x1906+1533+0 DirectClass 6.1mb 2.400u 0:04
TIFF Directory at offset 0x0
  Image Width: 3027 Image Length: 1906
  Resolution: 72, 72 (unitless)
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Extra Samples: 1<unassoc-alpha>
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 1
  Planar Configuration: single image plane
  Photoshop Data: <present>, 14 bytes
  Software: ImageMagick 6.2.3 01/24/06 Q16 http://www.imagemagick.org
  DocumentName: beach-tmp3.tif
  Predictor: horizontal differencing 2 (0x2)
beach.psd=>beach-tmp3.tif[3] PSD 3027x1906 3027x1906+0+0 DirectClass 5.3mb 3.210u 0:05

The resultant TIFFs have lost their offset information:

$ identify -verbose beach-tmp3.tif
beach-tmp3.tif TIFF 3027x1906 DirectClass 5.3mb 0.660u 0:01

And, of course, enblend identifies them as having no offset:

$ enblend -v beach-tmp{1,2,3}.tif -o beach-final.tif -z
Input image "beach-tmp1.tif" RGB UINT8 position=0x0 size=3052x1906
Input image "beach-tmp2.tif" RGB UINT8 position=0x0 size=3146x1906
Input image "beach-tmp3.tif" RGB UINT8 position=0x0 size=3027x1906
Output image size: (0, 0) -> (3146, 1906) = (3146 x 1906)

The current workaround is to expand each layer in Gimp to be the size of the entire canvas. This is monstrously space-inefficient, so I end up expanding, saving and deleting each layer in sequence.

Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

Forgot to add: I'm running Breezy Badger, imagemagick version 6:6.2.3.4-1ubuntu1.1.

Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote : Reported upstream.

This bug has been reported upstream on the imagemagick phpBB board:

http://redux.imagemagick.org/discussion-server/viewtopic.php?p=18781

Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote : Sample PSD with layered offsets.

This is a scaled-down version of the PSD saved by Gimp after editing a multilayer TIFF output by hugin. It identical, except that the layer masks have not been edited, the image was not cropped in Gimp, and the output from hugin was scaled down to 600 pixels wide.

$ identify beach-small.psd
beach-small.psd[0] PSD 570x184 DirectClass 683kb 0.370u 0:01
beach-small.psd[1] PSD 267x180 267x180+303+0 DirectClass 683kb 0.360u 0:01
beach-small.psd[2] PSD 267x177 267x177+130+7 DirectClass 683kb 0.360u 0:01
beach-small.psd[3] PSD 257x177 257x177+0+7 DirectClass 683kb 0.360u 0:01

Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

In the thread posted above, the ImageMagick development team said that a patch will be included in version 6.2.6-9 beta. So either importing the patch from there or upgrading to that version will solve the issue.

Revision history for this message
Dennis Kaarsemaker (dennis) wrote : Re: [Bug 37510] Re: PSD->TIFF conversion loses layer offsets.

Thanks for taking this upstream. If they have a patch that applies
fairly clean to the dapper version, the fix may land in dapper.
Otherwise it'll be dapper+1 material.

Changed in imagemagick:
status: Unconfirmed → Confirmed
Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

I'm running imagemagick 7:6.3.7.9.dfsg1-2ubuntu3 on Intrepid. It crashes now, but if I leave off -verbose mode, the correct output is provided. (I opened bug 302454 for that.) The file used here is attached over at that bug.

$ identify small-test.psd
small-test.psd[0] PSD 500x165 500x165+0+0 DirectClass 8-bit 567.291kb 0.870u 0:03
small-test.psd[1] PSD 107x165 107x165+393+0 DirectClass 8-bit 567.291kb 0.860u 0:03
small-test.psd[2] PSD 114x165 114x165+310+0 DirectClass 8-bit 567.291kb 0.860u 0:03
small-test.psd[3] PSD 104x165 104x165+248+0 DirectClass 8-bit 567.291kb 0.860u 0:03
small-test.psd[4] PSD 114x165 114x165+186+0 DirectClass 8-bit 567.291kb 0.860u 0:03
small-test.psd[5] PSD 114x165 114x165+124+0 DirectClass 8-bit 567.291kb 0.860u 0:03
small-test.psd[6] PSD 114x155 114x155+31+0 DirectClass 8-bit 567.291kb 0.850u 0:03
small-test.psd[7] PSD 83x165 83x165+0+0 DirectClass 8-bit 567.291kb 0.850u 0:03
$ convert -compress lzw small-test.psd small-test%d.tif
$ identify small-test3.tif
small-test3.tif TIFF 104x165 104x165+248+0 DirectClass 8-bit 47.4082kb
$ enblend -v small-test{1,2,3,4,5,6,7}.tif -o small-test-final.tif -z
Input image "small-test1.tif" RGB UINT8 position=393x0 size=107x165
Input image "small-test2.tif" RGB UINT8 position=310x0 size=114x165
Input image "small-test3.tif" RGB UINT8 position=248x0 size=104x165
Input image "small-test4.tif" RGB UINT8 position=186x0 size=114x165
Input image "small-test5.tif" RGB UINT8 position=124x0 size=114x165
Input image "small-test6.tif" RGB UINT8 position=31x0 size=114x155
Input image "small-test7.tif" RGB UINT8 position=0x0 size=83x165
Output image size: [(0, 0) to (500, 165) = (500x165)]
[snip]

The stitched TIFF that enblend outputs is correct; the layer offsets are maintained.

Changed in imagemagick:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.