Bug 459307 - Krita can't open psd files
Summary: Krita can't open psd files
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 5.1.1
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-18 05:13 UTC by Brim
Modified: 2022-09-19 21:51 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
It's the psd file that presents the error (105.97 KB, image/vnd.adobe.photoshop)
2022-09-18 05:13 UTC, Brim
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brim 2022-09-18 05:13:04 UTC
Created attachment 152178 [details]
It's the psd file that presents the error

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. try to open the psd file
2. the error will pop up


OBSERVED RESULT
the error ''Could not open C:/Users\Brim_\Download\TESTE Kleki.psd.
Reason: The file format cannot be parsed'' pops up

EXPECTED RESULT
open the psd file 

SOFTWARE/OS VERSIONS
Windows: Windows 10 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
The error only happens when i try to open a psd file that came from outside krita, and if I save a krita file as psd and try to open it goes normaly
Comment 1 Halla Rempt 2022-09-18 08:48:44 UTC
I can confirm that this file does not load.  If I load it in Gimp and save it again, it loads fine, so there is something weird about this file.  Which application created this file? 

The Krita file handling log says:

pos: 0
(valid: true, signature: "8BPS", version:1, number of channels: 3, height: 589, width: 968, channel depth: 8, color mode: RGB)
Read header. pos: 26
Read color mode block. pos: 30
Image Resource Sectionlength: 0 , starts at: 34
Read 0 Image Resource Blocks
Read image resource section. pos: 34
(PSD) reading layer section. Pos: 34 bytes left: 108480
layer block size 54300
Layer info block size 54292
Number of layers: 1
Has separate projection transparency: false
Going to read layer 0 pos 44
== Enter PSDLayerRecord
Going to read layer record. Pos: 44
	top 0 left 0 bottom 589 right 968 number of channels 3
	channel 0 id "red" length 18060 start 0 offset 0 channelInfoPosition 0
	channel 1 id "green" length 18060 start 0 offset 0 channelInfoPosition 0
	channel 2 id "blue" length 18060 start 0 offset 0 channelInfoPosition 0
	Blend mode "norm" pos 88
	Opacity 255 89
	clipping 0 90
	flags 8 91
	transparency protected false
	visible true
	irrelevant false
	filler at  91
	Going to read extra data length 92
	Extra data length 56
Going to read extra data field. Bytes available:  108418 pos 96
	Read layer mask/adjustment layer data. Length of block: 0 pos 100
	Number of blending channels: 0
	Going to read layer name at 104
	layer name length unpadded 0 pos 105
	layer name length padded 3 pos 105
	layer name "" 108
	About to read additional info blocks at 108
Photoshop signature verification failed! Got:  "0000ffff" ( "" )
== Leave PSDLayerRecord
Finished reading layer 0 "" blending mode "norm" 108 Number of channels: 3
Going to seek channel positions for layer 0 pos 108
	Reading channel image data for channel 0 from pos 108
		Channel 0 has compression type 0
		start 108 data start 110 data length 18060 pos 110
		channel record 0 for layer 0 with id 0 starting position 110 with length 18058 and has compression type 0
	Reading channel image data for channel 1 from pos 18168
		Channel 1 has compression type 33279
		start 18168 data start 18170 data length 18060 pos 18170
		channel record 1 for layer 0 with id 1 starting position 18170 with length 18058 and has compression type 33279
	Reading channel image data for channel 2 from pos 36228
		Channel 2 has compression type 33279
		start 36228 data start 36230 data length 18060 pos 36230
		channel record 2 for layer 0 with id 2 starting position 36230 with length 18058 and has compression type 33279
Leftover before additional blocks: 54334 54180
Global mask size: 0 ( 54338 54176 )
Position before starting global info section: 54338
Photoshop signature verification failed! Got:  "00010010" ( "" )
Read layer/mask section.  1 layers. pos: 54338
Going to read channels for layer 0 ""
Reading pixel data for layer "" pos 54338
ERROR: fetchChannelsBytes: "Unsupported Compression mode: 33279"
failed reading channels for layer:  "" "Unsupported Compression mode: 33279"
Comment 2 Brim 2022-09-18 18:54:21 UTC
(In reply to Halla Rempt from comment #1)
> I can confirm that this file does not load.  If I load it in Gimp and save
> it again, it loads fine, so there is something weird about this file.  Which
> application created this file? 
> 
> The Krita file handling log says:
> 
> pos: 0
> (valid: true, signature: "8BPS", version:1, number of channels: 3, height:
> 589, width: 968, channel depth: 8, color mode: RGB)
> Read header. pos: 26
> Read color mode block. pos: 30
> Image Resource Sectionlength: 0 , starts at: 34
> Read 0 Image Resource Blocks
> Read image resource section. pos: 34
> (PSD) reading layer section. Pos: 34 bytes left: 108480
> layer block size 54300
> Layer info block size 54292
> Number of layers: 1
> Has separate projection transparency: false
> Going to read layer 0 pos 44
> == Enter PSDLayerRecord
> Going to read layer record. Pos: 44
> 	top 0 left 0 bottom 589 right 968 number of channels 3
> 	channel 0 id "red" length 18060 start 0 offset 0 channelInfoPosition 0
> 	channel 1 id "green" length 18060 start 0 offset 0 channelInfoPosition 0
> 	channel 2 id "blue" length 18060 start 0 offset 0 channelInfoPosition 0
> 	Blend mode "norm" pos 88
> 	Opacity 255 89
> 	clipping 0 90
> 	flags 8 91
> 	transparency protected false
> 	visible true
> 	irrelevant false
> 	filler at  91
> 	Going to read extra data length 92
> 	Extra data length 56
> Going to read extra data field. Bytes available:  108418 pos 96
> 	Read layer mask/adjustment layer data. Length of block: 0 pos 100
> 	Number of blending channels: 0
> 	Going to read layer name at 104
> 	layer name length unpadded 0 pos 105
> 	layer name length padded 3 pos 105
> 	layer name "" 108
> 	About to read additional info blocks at 108
> Photoshop signature verification failed! Got:  "0000ffff" ( "" )
> == Leave PSDLayerRecord
> Finished reading layer 0 "" blending mode "norm" 108 Number of channels: 3
> Going to seek channel positions for layer 0 pos 108
> 	Reading channel image data for channel 0 from pos 108
> 		Channel 0 has compression type 0
> 		start 108 data start 110 data length 18060 pos 110
> 		channel record 0 for layer 0 with id 0 starting position 110 with length
> 18058 and has compression type 0
> 	Reading channel image data for channel 1 from pos 18168
> 		Channel 1 has compression type 33279
> 		start 18168 data start 18170 data length 18060 pos 18170
> 		channel record 1 for layer 0 with id 1 starting position 18170 with length
> 18058 and has compression type 33279
> 	Reading channel image data for channel 2 from pos 36228
> 		Channel 2 has compression type 33279
> 		start 36228 data start 36230 data length 18060 pos 36230
> 		channel record 2 for layer 0 with id 2 starting position 36230 with length
> 18058 and has compression type 33279
> Leftover before additional blocks: 54334 54180
> Global mask size: 0 ( 54338 54176 )
> Position before starting global info section: 54338
> Photoshop signature verification failed! Got:  "00010010" ( "" )
> Read layer/mask section.  1 layers. pos: 54338
> Going to read channels for layer 0 ""
> Reading pixel data for layer "" pos 54338
> ERROR: fetchChannelsBytes: "Unsupported Compression mode: 33279"
> failed reading channels for layer:  "" "Unsupported Compression mode: 33279"

It came from this site https://kleki.com it's a drawing website, i used to make some sketches and upload as psd in krita before 5.1 and it worked normaly
Comment 3 Freya Lupen 2022-09-19 04:08:34 UTC
Krita is ignoring 8 bytes of "blendingData" and then trying to read that as the layer name.
Changing psd_layer_record.cpp@363 from
"if (blendingNchannels > 0) {" to
"if (blendingDataLength > 0) {" fixes it.
The relevant lines were changed here:
https://invent.kde.org/graphics/krita/-/commit/1f8f6593d9e24c942197a2472400eef9e21e85c3

(Saving in GIMP removes the blending data, which is why Krita is then able to open it.)
Comment 4 amyspark 2022-09-19 21:50:59 UTC
Git commit bb28090652d3839d00e0ef0f80bce8c03fb0b484 by L. E. Segovia.
Committed on 19/09/2022 at 21:50.
Pushed by lsegovia into branch 'master'.

psd: fix reading of layer blending ranges

Freya Lupen's comment regarding a bad check was spot on. Let's add some
hardening while at it, too.

M  +24   -14   libs/psd/psd_layer_record.cpp

https://invent.kde.org/graphics/krita/commit/bb28090652d3839d00e0ef0f80bce8c03fb0b484
Comment 5 amyspark 2022-09-19 21:51:50 UTC
Git commit 0dd11393eff866ddb81919a0008ae20bf6ae6c0d by L. E. Segovia.
Committed on 19/09/2022 at 21:51.
Pushed by lsegovia into branch 'krita/5.1'.

psd: fix reading of layer blending ranges

Freya Lupen's comment regarding a bad check was spot on. Let's add some
hardening while at it, too.
(cherry picked from commit bb28090652d3839d00e0ef0f80bce8c03fb0b484)

M  +24   -14   libs/psd/psd_layer_record.cpp

https://invent.kde.org/graphics/krita/commit/0dd11393eff866ddb81919a0008ae20bf6ae6c0d