Bug 468288

Summary: kimageformats-read-psd autotest started to fail with 5.105.0
Product: [Frameworks and Libraries] frameworks-kimageformats Reporter: Heiko Becker <heiko.becker>
Component: generalAssignee: Alex Merry <alex.merry>
Status: REOPENED ---    
Severity: normal CC: aacid, kdelibs-bugs, kloczko.tomasz, mircomir
Priority: NOR    
Version: 5.105.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Birthday image generated on my desktop
Birthday image generated on CI's VM

Description Heiko Becker 2023-04-08 13:44:47 UTC
kimageformats-read-psd autotest started to fail with 5.105.0 while it passed with 5.104.0 for me. I see it passing on invent though, not sure yet what is different locally here.

STEPS TO REPRODUCE
1.  cmake && ninja 
2.  ninja test

SOFTWARE/OS VERSIONS
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9 + patch collection

4/22 Test  #4: kimageformats-read-psd ...........***Failed    0.66 sec
********* Starting basic read tests for psd images *********
QImageReader::supportedImageFormats: 3fr, ani, arq, arw, avif, avifs, bay, bmp, bmq, bw, cap, cine, cr2, cr3, crw, cs1, cur, dc2, dcr, dcs, dng, drf, dxo, eip, eps, epsf, epsi, erf, exr, fff, gif, hdr, heic, heif, icns, ico, iiq, jpeg, jpg, jxl, k25, kc2, kdc, kra, mdc, mef, mfw, mng, mos, mrw, nef, nrw, obm, ora, orf, ori, pbm, pcx, pdd, pdf, pef, pgm, pic, png, ppm, psb, psd, psdt, ptx, pxn, qtk, r3d, raf, ras, raw, rdc, rgb, rgba, rw2, rwl, rwz, sgi, sr2, srf, srw, sti, svg, svgz, tga, wbmp, webp, x3f, xbm, xcf, xpm
* Run on RANDOM ACCESS device
INFO : 16bit-rle.psd: converting 16bit-rle.psd from RGBX64 to ARGB32
INFO : 16bit-rle.psd: converting 16bit-rle.png from RGBA64 to ARGB32
PASS : 16bit-rle.psd
INFO : 16bit_grayscale.psd: converting 16bit_grayscale.psd from Grayscale16 to ARGB32
INFO : 16bit_grayscale.psd: converting 16bit_grayscale.png from Grayscale16 to ARGB32
PASS : 16bit_grayscale.psd
PASS : 16bit_photoshop.psb
PASS : 32bit-rgb.psd
INFO : 32bit_grayscale.psd: converting 32bit_grayscale.psd from Grayscale16 to ARGB32
INFO : 32bit_grayscale.psd: converting 32bit_grayscale.png from Grayscale16 to ARGB32
PASS : 32bit_grayscale.psd
INFO : 53alphas.psd: converting 53alphas.psd from RGBA8888_Premultiplied to ARGB32
PASS : 53alphas.psd
INFO : 8bit-grayscale.psd: converting 8bit-grayscale.psd from Grayscale8 to ARGB32
INFO : 8bit-grayscale.psd: converting 8bit-grayscale.png from Grayscale8 to ARGB32
PASS : 8bit-grayscale.psd
INFO : 8bit-photoshop.psb: converting 8bit-photoshop.psb from RGB888 to ARGB32
INFO : 8bit-photoshop.psb: converting 8bit-photoshop.png from RGB32 to ARGB32
PASS : 8bit-photoshop.psb
INFO : adobehq-2_5.psd: converting adobehq-2_5.psd from RGB888 to ARGB32
INFO : adobehq-2_5.psd: converting adobehq-2_5.png from RGB32 to ARGB32
PASS : adobehq-2_5.psd
INFO : argb16-raw-affinityphoto-1.8.5.psd: converting argb16-raw-affinityphoto-1.8.5.psd from RGBA64_Premultiplied to ARGB32
INFO : argb16-raw-affinityphoto-1.8.5.psd: converting argb16-raw-affinityphoto-1.8.5.png from RGBA64 to ARGB32
PASS : argb16-raw-affinityphoto-1.8.5.psd
INFO : birthday.pdd: converting birthday.pdd from RGBA8888_Premultiplied to ARGB32
FAIL : birthday.pdd: differs from birthday.png
       expected data written to birthday.pdd-expected.data
       actual data written to birthday.pdd-actual.data
INFO : bitmap.psd: converting bitmap.psd from Mono to ARGB32
INFO : bitmap.psd: converting bitmap.png from Mono to ARGB32
PASS : bitmap.psd
INFO : ccbug182496.psd: converting ccbug182496.psd from RGB888 to ARGB32
INFO : ccbug182496.psd: converting ccbug182496.png from RGB32 to ARGB32
PASS : ccbug182496.psd
PASS : cmyka-16bits.psd
INFO : cmyka-8bits.psd: converting cmyka-8bits.psd from RGBA8888 to ARGB32
PASS : cmyka-8bits.psd
INFO : duotone.psb: converting duotone.psb from Grayscale8 to ARGB32
INFO : duotone.psb: converting duotone.png from Grayscale8 to ARGB32
PASS : duotone.psb
INFO : indexed.psd: converting indexed.psd from Indexed8 to ARGB32
INFO : indexed.psd: converting indexed.png from Indexed8 to ARGB32
PASS : indexed.psd
PASS : laba_16bit.psd
INFO : laba_8bit.psd: converting laba_8bit.psd from RGBA8888 to ARGB32
PASS : laba_8bit.psd
PASS : mch-16bits.psd
INFO : mch-8bits.psd: converting mch-8bits.psd from RGB888 to ARGB32
INFO : mch-8bits.psd: converting mch-8bits.png from RGB32 to ARGB32
PASS : mch-8bits.psd
INFO : rgb-gimp-2.8.10.psd: converting rgb-gimp-2.8.10.psd from RGB888 to ARGB32
INFO : rgb-gimp-2.8.10.psd: converting rgb-gimp-2.8.10.png from RGB32 to ARGB32
PASS : rgb-gimp-2.8.10.psd
PASS : rgb16-raw-affinityphoto-1.8.5.psd
* Run on SEQUENTIAL ACCESS device
INFO : 16bit-rle.psd: converting 16bit-rle.psd from RGBX64 to ARGB32
INFO : 16bit-rle.psd: converting 16bit-rle.png from RGBA64 to ARGB32
PASS : 16bit-rle.psd
INFO : 16bit_grayscale.psd: converting 16bit_grayscale.psd from Grayscale16 to ARGB32
INFO : 16bit_grayscale.psd: converting 16bit_grayscale.png from Grayscale16 to ARGB32
PASS : 16bit_grayscale.psd
PASS : 16bit_photoshop.psb
PASS : 32bit-rgb.psd
INFO : 32bit_grayscale.psd: converting 32bit_grayscale.psd from Grayscale16 to ARGB32
INFO : 32bit_grayscale.psd: converting 32bit_grayscale.png from Grayscale16 to ARGB32
PASS : 32bit_grayscale.psd
SKIP : 53alphas.psd: cannot read on a sequential device (don't worry, it's ok)
INFO : 8bit-grayscale.psd: converting 8bit-grayscale.psd from Grayscale8 to ARGB32
INFO : 8bit-grayscale.psd: converting 8bit-grayscale.png from Grayscale8 to ARGB32
PASS : 8bit-grayscale.psd
INFO : 8bit-photoshop.psb: converting 8bit-photoshop.psb from RGB888 to ARGB32
INFO : 8bit-photoshop.psb: converting 8bit-photoshop.png from RGB32 to ARGB32
PASS : 8bit-photoshop.psb
INFO : adobehq-2_5.psd: converting adobehq-2_5.psd from RGB888 to ARGB32
INFO : adobehq-2_5.psd: converting adobehq-2_5.png from RGB32 to ARGB32
PASS : adobehq-2_5.psd
SKIP : argb16-raw-affinityphoto-1.8.5.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : birthday.pdd: cannot read on a sequential device (don't worry, it's ok)
INFO : bitmap.psd: converting bitmap.psd from Mono to ARGB32
INFO : bitmap.psd: converting bitmap.png from Mono to ARGB32
PASS : bitmap.psd
SKIP : ccbug182496.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : cmyka-16bits.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : cmyka-8bits.psd: cannot read on a sequential device (don't worry, it's ok)
INFO : duotone.psb: converting duotone.psb from Grayscale8 to ARGB32
INFO : duotone.psb: converting duotone.png from Grayscale8 to ARGB32
PASS : duotone.psb
INFO : indexed.psd: converting indexed.psd from Indexed8 to ARGB32
INFO : indexed.psd: converting indexed.png from Indexed8 to ARGB32
PASS : indexed.psd
SKIP : laba_16bit.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : laba_8bit.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : mch-16bits.psd: cannot read on a sequential device (don't worry, it's ok)
SKIP : mch-8bits.psd: cannot read on a sequential device (don't worry, it's ok)
INFO : rgb-gimp-2.8.10.psd: converting rgb-gimp-2.8.10.psd from RGB888 to ARGB32
INFO : rgb-gimp-2.8.10.psd: converting rgb-gimp-2.8.10.png from RGB32 to ARGB32
PASS : rgb-gimp-2.8.10.psd
PASS : rgb16-raw-affinityphoto-1.8.5.psd
Totals: 35 passed, 10 skipped, 1 failed
********* Finished basic read tests for psd images *********
Comment 1 Albert Astals Cid 2023-04-08 19:19:42 UTC
*** Bug 468292 has been marked as a duplicate of this bug. ***
Comment 2 Albert Astals Cid 2023-04-08 19:29:06 UTC
Mirco, I can also reproduce this locally (CI seems happy though).

What can we do to help debug this?
Comment 3 Mirco Miranda 2023-04-09 00:11:56 UTC
(In reply to Albert Astals Cid from comment #2)
> Mirco, I can also reproduce this locally (CI seems happy though).
> 
> What can we do to help debug this?

It's the problem I had about a month ago after my last patch to the psd plugin. For me it worked locally (debian unstable) but failed on invent (all vms). That image is the only one with premultiplied alpha and alpha values other than 255. In my case it changed a few pixels and it seemed due to rounding differences in the conversion from RBG8888_Premul to ARGB32.
I then assumed that my distro (install dated 2006) was the problem and so I used invent's comparison png.

To help with debugging I must definitely reintroduce Base64 printing of the image on failure. I do this in the afternoon and then try to figure out what's going on.
Comment 4 Mirco Miranda 2023-04-09 12:25:29 UTC
Created attachment 157974 [details]
Birthday image generated on my desktop
Comment 5 Mirco Miranda 2023-04-09 12:26:31 UTC
Created attachment 157975 [details]
Birthday image generated on CI's VM
Comment 6 Mirco Miranda 2023-04-09 12:32:32 UTC
Even on my Debian, the image generated by birthday.ppd is slightly different from the one generated on all CI machines. The difference is on 15 pixels with values like RGB(55,47,54) vs RGB(55,48,54). I have no idea how to figure out what is causing this difference.

PS: In the meantime I also fixed a problem I found but it doesn't change the result.
Comment 7 Mirco Miranda 2023-04-09 13:42:13 UTC
OK, I played dirty. I modified the test to accept tif images as well as pngs. The tiffs can be saved in premultiplied format, so the test must convert both the image to be tested and the comparison images. Now it works both on my local machine and on invent.
I don't like the solution I proposed and it's marked as a draft. In any case, can you try it?

https://invent.kde.org/frameworks/kimageformats/-/merge_requests/148
Comment 8 kloczek 2023-04-09 19:26:05 UTC
(In reply to Mirco Miranda from comment #7)
[..]
>  In any case, can you try it?
> 
> https://invent.kde.org/frameworks/kimageformats/-/merge_requests/148

Of course :)
One sec ..
Comment 9 kloczek 2023-04-09 21:20:19 UTC
(In reply to Mirco Miranda from comment #7)
[..]
> https://invent.kde.org/frameworks/kimageformats/-/merge_requests/148

Tested and it works with that MR :)
Thank you.
Comment 10 Heiko Becker 2023-04-10 19:14:23 UTC
(In reply to Mirco Miranda from comment #7)
> I don't like the solution I proposed and it's marked as a draft. In any
> case, can you try it?
> https://invent.kde.org/frameworks/kimageformats/-/merge_requests/148

Passed here as well, after installing the libqtiff plugin.
Comment 11 Albert Astals Cid 2023-04-12 20:11:11 UTC
(In reply to Mirco Miranda from comment #6)
> I have no idea how to figure out what is causing this difference.

I are we using some pow/sqrt/sin or similar in that code?
Comment 12 Albert Astals Cid 2023-04-12 20:34:46 UTC
Git commit 9b1fafe29bbf1242406d59f39206e62e2bbb6985 by Albert Astals Cid, on behalf of Mirco Miranda.
Committed on 12/04/2023 at 20:34.
Pushed by aacid into branch 'kf5'.

Fix wrong alpha conversion

and use tif for image comparison in this particular one instead of png

D  +-    --    autotests/read/psd/birthday.png
A  +-    --    autotests/read/psd/birthday.tif
M  +8    -3    autotests/readtest.cpp
M  +1    -2    src/imageformats/psd.cpp

https://invent.kde.org/frameworks/kimageformats/commit/9b1fafe29bbf1242406d59f39206e62e2bbb6985
Comment 13 kloczek 2023-05-14 01:59:50 UTC
I'm going to reopen this ticked because if source tree is configured with BUILD_TESTING=ON it should be added checking dependency for Qt5::QTiffPlugin.
Withou that cmake is able configure source tree and there is no any obstacles to start test suite which is failig with

ERROR: birthday.pdd: could not load birthday.tif: Unsupported image format
Comment 14 Mirco Miranda 2024-10-01 05:36:21 UTC
(In reply to kloczek from comment #13)
> I'm going to reopen this ticked because if source tree is configured with
> BUILD_TESTING=ON it should be added checking dependency for Qt5::QTiffPlugin.

This should be fixed in KF6. Instead of including the plugin, the test is skipped if the comparison image format is not present (notifying you).

The change has not been ported to KF5.