Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VlivCreateTrueColorDIBSection failed with error 87: The parameter is incorrect #10

Open
howff opened this issue Nov 14, 2024 · 5 comments

Comments

@howff
Copy link

howff commented Nov 14, 2024

I got this error when loading a TIFF file VlivCreateTrueColorDIBSection failed with error 87: The parameter is incorrect

The file seems to have been created by Photoshop. I realise that gdalinfo (below) reports an error, but IrfanView can display it ok (I don't have Photoshop to check).

Size is 26315, 30924
ERROR 1: Error reading EXIF Directory count at 18446744072669665560
Metadata domains:
  (default)
  xml:XMP
  IMAGE_STRUCTURE
  DERIVED_SUBDATASETS
Metadata:
  TIFFTAG_DATETIME=2021:08:03 21:44:34
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=Adobe Photoshop 21.1 (Windows)
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,30924.0)
Upper Right (26315.0,    0.0)
Lower Right (26315.0,30924.0)
Center      (13157.5,15462.0)
Band 1 Block=26315x1 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA
Band 2 Block=26315x1 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA
Band 3 Block=26315x1 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA
Band 4 Block=26315x1 Type=Byte, ColorInterp=Alpha
@delhoume
Copy link
Owner

delhoume commented Nov 14, 2024

Hi,

Thee not many parameters to VlivCreateTrueColorDIBSection (that calls CreateDIBSection with very standard parameter) that can fail. It seems that CreateDIBSection is limited to 32 bit data so no more than 2 gb as I found out googling...

Can you run tiffinfo on this image ?

if your image is single strip of the whole height, that would be not a good case for Vliv (or any other using CreateDIBSection with 4 byte/pixel). IrfanView might use another API or break the data into chunks.

For a non-tiled image, 26315x30904x4 is 3.5 gigabyte to allocate.

Is there's any chance you can convert this tiff to a tiled format, or at least to strips with more than 1 strip ?
Or generate it using tile or strips (1 pixel height strip will be enough).

I am usually using VIPS that has options t create tiles, something like
vips copy in.tif "out.tif[tile=yes]"
or
tiffcp in.tif out.tif -s -c zip -r 32

It will open much faster and take almost no memory if tiled (only what fits in a screen), a little more if stripped, because strips are the same width than the image.

Can you give access to this TIFF ? I would like to try with an alternative Windows implementation (Wine on on MacOS), Vliv works fine there.

I currently do not have access to a Windows machine with a compiler so it might take some time to fix in the code, if this proves to be necessary.

@howff
Copy link
Author

howff commented Nov 14, 2024

The tiffinfo output is as follows (yes it includes many blank lines)

=== TIFF directory 0 ===
TIFF Directory at offset 0x8 (8)
  Subfile Type: (0 = 0x0)
  Image Width: 26315 Image Length: 30924
  Resolution: 72, 72 pixels/inch
  Bits/Sample: 8
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Extra Samples: 1<assoc-alpha>
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 30924
  Planar Configuration: single image plane
  Software: Adobe Photoshop 21.1 (Windows)
  DateTime: 2021:08:03 21:44:34
  XMLPacket (XMP Metadata):
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 6.0-c002 79.164352, 2020/01/30-15:50:38        ">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:xmp="http://ns.adobe.com/xap/1.0/"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
            xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
            xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#">
         <xmp:CreatorTool>Adobe Photoshop 21.1 (Windows)</xmp:CreatorTool>
         <xmp:CreateDate>2021-08-03T21:39:55-03:00</xmp:CreateDate>
         <xmp:ModifyDate>2021-08-03T21:44:34-03:00</xmp:ModifyDate>
         <xmp:MetadataDate>2021-08-03T21:44:34-03:00</xmp:MetadataDate>
         <dc:format>image/tiff</dc:format>
         <photoshop:ColorMode>3</photoshop:ColorMode>
         <xmpMM:InstanceID>xmp.iid:72516f48-8ca6-4e46-aae4-62b7e380d851</xmpMM:InstanceID>
         <xmpMM:DocumentID>adobe:docid:photoshop:29244263-ff94-cc43-aea8-d75c366831a4</xmpMM:DocumentID>
         <xmpMM:OriginalDocumentID>xmp.did:738fc7ba-9326-d440-99c6-a363b1fdf02c</xmpMM:OriginalDocumentID>
         <xmpMM:History>
            <rdf:Seq>
               <rdf:li rdf:parseType="Resource">
                  <stEvt:action>created</stEvt:action>
                  <stEvt:instanceID>xmp.iid:738fc7ba-9326-d440-99c6-a363b1fdf02c</stEvt:instanceID>
                  <stEvt:when>2021-08-03T21:39:55-03:00</stEvt:when>
                  <stEvt:softwareAgent>Adobe Photoshop 21.1 (Windows)</stEvt:softwareAgent>
               </rdf:li>
               <rdf:li rdf:parseType="Resource">
                  <stEvt:action>saved</stEvt:action>
                  <stEvt:instanceID>xmp.iid:72516f48-8ca6-4e46-aae4-62b7e380d851</stEvt:instanceID>
                  <stEvt:when>2021-08-03T21:44:34-03:00</stEvt:when>
                  <stEvt:softwareAgent>Adobe Photoshop 21.1 (Windows)</stEvt:softwareAgent>
                  <stEvt:changed>/</stEvt:changed>
               </rdf:li>
            </rdf:Seq>
         </xmpMM:History>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>
























































































































<?xpacket end="w"?>
  Photoshop Data: <present>, 6352 bytes
  EXIFIFDOffset: 0xc2049918
TIFF Directory at offset 0xc2049918 (3255081240)
  ColorSpace: 65535
  PixelXDimension: 26315
  PixelYDimension: 30924

@delhoume
Copy link
Owner

Yes one strip of 30924 rows...

Converting to tiled or strips with a usable rows/strip is my first advice.
As it is now, even if you did not encounter this CreateDIBSection issue in Vliv, or using another software, loading this image requires 3.5 Go of memory in any case, and unzooming will be slow.
And if the image was say 10 times larger it would not be possible to load it on almost any machine on earth.

My best advice is to convert to a pyramidal tiled tiff, you can do that with vips
vips copy in.tif "out.tif[tile,pyramid]"

You'll then experience what Vliv is meant for with instant loading/panning/unzooming even on modest configurations.

I created Vliv for this specific type of tiff, and loading "bad" (non tiled, non stripped, non pyramidal) images is not really where it shines (fort example unzooming will only be possible if the image is pyramidal)

Vliv can open instantly pyramidal tiled images that are 4200000x2000000 pixels (I have one that weights 1.5 Tb)

@delhoume
Copy link
Owner

I created a tiff like yours using Image Magick:

magick -size 30000x30000 canvas:black -depth 32 -compress Zip -define tiff:rows-per-strip=30000 toto.tif

opening it in Vliv on Windows fails with the same error you have.
on MacOS Wine, it also fails but the error message is strange as it says 32 bit images are not supported, that seems to be a libtiff message.

converting it to a stripped format using vips allows it to be loaded in Vliv (default is 128 rows/strip)
vips copy toto.tif "tutu.tif[compression=deflate]"
image

you can also generate a tiled pyramidal tiff
vips copy toto.tif "titi.tif[compression=deflate,tile,pyramid]"

image

you can also use tiffcp to generate a Vliv loadable image (note the mandatory -m 0 parameter)
tiffcp -m 0 -s -r 32 -c zip toto.tif tutu.tif

image

@howff
Copy link
Author

howff commented Nov 21, 2024

ok, thank you very much for investigating this, much appreciated.

I am surprised that I've hit a limit with vliv, that's a shame it can't load every image.

Maybe you could catch the error and issue an error message which explains the problem better, so that users know exactly what's wrong (and maybe how to fix it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants