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

[bug] PhotoDemon 9.2 pre-alpha: Writing Multi-Layered TIFF error #508

Closed
hi5 opened this issue Dec 15, 2023 · 3 comments
Closed

[bug] PhotoDemon 9.2 pre-alpha: Writing Multi-Layered TIFF error #508

hi5 opened this issue Dec 15, 2023 · 3 comments
Labels
bug fixed (hopefully)

Comments

@hi5
Copy link

hi5 commented Dec 15, 2023

First of all: I'm really happy with the way PD reads multi-layered TIFFs, many graphic programs can't handle it properly, PD can!
Second: I don't consider this a serious but as I suspect there might be something "off" with the way I create the TIFFs, but I thought it was worth reporting anyway. Perhaps there is an easy fix.

Version information

PhotoDemon 9.2 pre-alpha (all builds I think). Windows 10, Windows 11

Describe the bug

I'm using GraphicsMagick - an ImageMagick fork - to create a multi-layer TIFF (samples attached)

PD opens these perfectly and I can edit them - I often just need to move the top layer into position. I then save the result as JPG or PNG which works perfectly of course.

But there is an error when saving it back as TIFF. It works to save as a flattened TIFF, but keeping it multi-layered doesn't work and shows

An unspecified error occurred when attempting to save this image.
Please try saving the image to an alternate format.

If the problem persists, please report it to the PhotoDemon developers
via photodemon.org/contact

At first I thought it was because the base layer I was using was only 8b output1.tiff, but it happens with 24b too output2.tiff

How can I reproduce the bug?

TIFF files: tiff.zip

Open one of the TIFFs, Save as TIFF, just be sure to select Multi-page TIFF (basic settings in the Save) - file isn't saved and error message (above) is shown.

NOTE: when I use a test image from elsewhere it works just fine, so my guess there is something peculiar with my TIFFs.

Expected behavior

Having it saves as multi-layered tiff :)

Debug logs

-DBG- Internal VB error encountered in TIFF routine. Err #10, This array is fixed or temporarily locked

Debug: DebugTiff.zip

@hi5 hi5 changed the title PhotoDemon 9.2 pre-alpha: Writing Multi-Lay TIFF error [bug] PhotoDemon 9.2 pre-alpha: Writing Multi-Layered TIFF error Dec 15, 2023
tannerhelland added a commit that referenced this issue Dec 15, 2023
...to properly account for blank single-color pages.  (Previously, the function would always compare the first two unique colors encountered - but a second unique color doesn't exist if a page is single-color!)

Relates to #508.  Thank you to @hi5 for catching this and taking the time to file an excellent, in-depth bug report.
@tannerhelland tannerhelland added the fixed (hopefully) label Dec 15, 2023
@tannerhelland
Copy link
Owner

Hello @hi5 . I am so sorry that you've encountered multiple image export bugs lately!

Fortunately for me, your bug reports are incredibly helpful, and the files you attached made it much easier for me to track down the problem. Thank you.

This bug was entirely my fault. Because TIFF files can be so large, PhotoDemon's TIFF exporter tries to find the smallest possible color-depth that works for each page. One check it performs is for monochrome pages, and the check is simple enough - compare the first two unique colors found on each page, and if they are black and white, save that page as a monochrome one.

I just discovered that this simple function crashes on your TIFF files because it tries to compare the first two unique colors it finds on each page... but if the page is blank, there is only one unique color and it crashes when looking at the (non-existent) second unique color 🤦‍♂️

I am embarrassed and sorry for not thinking of this earlier. I believe I have fixed the problem, and new nightly builds are already available. Please let me know if further problems occur.

I hope to release a new stable 9.2 version soon with all the many bug-fixes since 9.0's release. I just need to finish up a few minor feature enhancements that have taken longer than expected.

Thank you again for filing these bug reports so promptly. I am excited to ship these important fixes to all users soon!

@hi5
Copy link
Author

hi5 commented Dec 15, 2023

Excellent, glad the report was useful and apparently easy to fix. And don't worry about errors, nothing is without errors and there are simply too many edge cases to consider, and mutlipage TIFFs are quite exotic already, having poor or no support at all in other programs illustrates it as well.

I can confirm it works correctly now with build 230. 🍾

@tannerhelland
Copy link
Owner

Thank you so much for the follow-up! 1 problem down, 99 to go 😆

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

No branches or pull requests

2 participants