plug-ins: handle fill layers with negative height

As mentioned on Discourse here
https://discourse.gnome.org/t/error-opening-psd-image-height-no-support-or-invalid-1/17743
When opening a certain psd
(https://github.com/Squirtleiscool/Coalition-Technologies-Skill-Test/blob/master/CT_SkillTest_v1.psd)
We get a warning when creating a layer with a height of -1.
Apparently certain fill layers can have a negative height. Data on how
to handle this height is probably inside the 'SoCo' layer resource
that we don't handle yet.
For now, we will set the layer to empty and the height to 1.

To be on the safe side, let's also check the layer width to be non
negative.
This commit is contained in:
Jacob Boerema 2023-10-24 17:31:47 -04:00
parent 1caf6a8de4
commit c2d76f38ff
1 changed files with 16 additions and 0 deletions

View File

@ -2222,6 +2222,22 @@ add_layers (GimpImage *image,
l_y = lyr_a[lidx]->top;
l_w = lyr_a[lidx]->right - lyr_a[lidx]->left;
l_h = lyr_a[lidx]->bottom - lyr_a[lidx]->top;
if (l_h <= 0)
{
/* For fill layers this can be -1 apparently;
e.g. test file CT_SkillTest_v1.psd
Mark as empty and set height to 1.
*/
empty = TRUE;
l_h = 1;
}
if (l_w <= 0)
{
g_warning ("Unexpected layer width: %d", l_w);
empty = TRUE;
l_w = 1;
}
}
image_type = get_gimp_image_type (img_a->base_type, TRUE);