Bug 142629 - Importing psd image with transparent background results in "Unknown image format"
Summary: Importing psd image with transparent background results in "Unknown image for...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
6.1.0.3 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: target:7.2.0 target:7.1.5
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2021-06-03 04:27 UTC by Alistair Saywell
Modified: 2021-06-16 03:25 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
sample psd with transparent background (fails) (1.08 MB, image/psd)
2021-06-03 04:30 UTC, Alistair Saywell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alistair Saywell 2021-06-03 04:27:01 UTC
Description:
Importing a .psd image (Photoshop CS5) with a transparent background brings up "unknown image format". A PSD without transparency imports correctly. Import filter issue

Dragging the transparent image file from file manager brings up Insert Section dialog with file as link; if OK'ed only blank section displayed.

Workaround: drag image from Gimp

Steps to Reproduce:
1.Create new document in Writer or Draw
2. Click Insert > Image and select psd with transparent background
3.Click OK. 

Actual Results:
Dialog appears with  "unknown image format" 

Expected Results:
Image to be correctly imported into document


Reproducible: Always


User Profile Reset: No



Additional Info:
Issue raised in AskLibreOffice https://ask.libreoffice.org/en/question/312259/importing-psd-images-libo60-vs-libo61/

Version: 7.1.3.2 (x64) / LibreOffice Community
Build ID: 47f78053abe362b9384784d31a6e56f8511eb1c1
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: en-NZ (en_GB); UI: en-US
Calc: threaded

Also on Version: 7.0.6.2 (x64) Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win Locale: en-NZ (en_NZ); UI: en-GB Calc: CL
Comment 1 Alistair Saywell 2021-06-03 04:30:11 UTC
Created attachment 172585 [details]
sample psd with transparent background (fails)
Comment 2 Julien Nabet 2021-06-03 05:25:20 UTC
Xisco/Heiko: I'm quite astonished there's an import psd functionality in LO.
I mean, even Gimp may have problem when opening some psd (see https://wiki.gimp.org/wiki/PSD_support).
Is it really useful to maintain psd support in LO?
IHMO, psd should be dealt with Gimp to export the image in jpg/png.. whatever then it's the resulting image which should be imported in LO.
Of course, it forces to use 2 softwares but I suppose being able to fully support psd in LO is quite a challenge.
Comment 3 Xisco Faulí 2021-06-03 07:51:46 UTC
(In reply to Julien Nabet from comment #2)
> Xisco/Heiko: I'm quite astonished there's an import psd functionality in LO.
> I mean, even Gimp may have problem when opening some psd (see
> https://wiki.gimp.org/wiki/PSD_support).
> Is it really useful to maintain psd support in LO?
> IHMO, psd should be dealt with Gimp to export the image in jpg/png..
> whatever then it's the resulting image which should be imported in LO.
> Of course, it forces to use 2 softwares but I suppose being able to fully
> support psd in LO is quite a challenge.

Hi Julien,
what would be your proposal then, to remove it ? I can bring this topic to the ESC meeting
Comment 4 Julien Nabet 2021-06-03 08:26:09 UTC
(In reply to Xisco Faulí from comment #3)
> (In reply to Julien Nabet from comment #2)
> ...support psd in LO is quite a challenge.
> 
> Hi Julien,
> what would be your proposal then, to remove it ? I can bring this topic to
> the ESC meeting

Yes I think it should be removed since:
- it's a proprietary format
- LO isn't an image editor even if you can do some basic edition.
Of course, it's only my personal opinion.
Comment 5 Alistair Saywell 2021-06-03 10:24:54 UTC
According to the question on LibreOffice, the import filter worked for PSD images with transparent backgrounds until 6.1.0.3 or possibly 6.0.0.3; there is uncertainty in the language.

Is there a need to remove PSD filter just because it is proprietary and not 100%? I can think of other filters that also meet that criteria. 

LibreOffice does need to display images. The issue is not about editing them. If you believe that no work should put into displaying of PSD with transparent background, that is quite different to removing existing functionality.
Comment 6 Julien Nabet 2021-06-03 10:55:29 UTC
(In reply to Alistair Saywell from comment #5)
> According to the question on LibreOffice, the import filter worked for PSD
> images with transparent backgrounds until 6.1.0.3 or possibly 6.0.0.3; there
> is uncertainty in the language.
Ok so it would be a regression then.

> Is there a need to remove PSD filter just because it is proprietary and not
> 100%? I can think of other filters that also meet that criteria. 
There is no "need" per se, it's just a thought.
Yes there are other prioprietary formats which are not 100% supported by LO but in this specific case, I prefer improving jpg/png/gif support since psd can be exported in one of these by software like Photoshop or Gimp. Also, I just wonder how often psd import in LO is used compared with the 3 quoted image formats.

Of course, I don't say psd is a bad format or hardly used in general, I just mean to include it in a doc.
I wonder if Word, Excel, Powerpoint can insert psd for just displaying. (it's a real question, no ironical tone here, I don't have MSOffice to give it a try right now).

> 
> LibreOffice does need to display images. The issue is not about editing
> them. If you believe that no work should put into displaying of PSD with
> transparent background, that is quite different to removing existing
> functionality.
Yes LO does need to display images but not every format of images (just take a look at https://en.wikipedia.org/wiki/Image_file_formats).

More generally, I think LO tries to deal with too much formats (it's also true for other things like databases) but few, if there are, aren't supported at 100%. I may be wrong but it seems even odf aren't 100% supported.
Of course, you may respond that support of 98% for example should be enough and the rest is just very specific use and you might be right but, for odf or png at least, I think it's a pity.
Comment 7 Heiko Tietze 2021-06-03 11:41:31 UTC
I'm all in for removing unmaintained features but users disagree typically. The survey in [1] didn't ask for PSD but even less known formats.

[1] https://design.blog.documentfoundation.org/2017/06/28/results-survey-libreoffice-features/
Comment 8 Julien Nabet 2021-06-03 17:17:29 UTC
For those interested the code is in vcl/source/filter/ipsd/ipsd.cxx.
Before d338dc277d7dbe381d669728e30a1c2606a4814a
author	Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>	2021-02-15 09:57:51 +0900
committer	Tomaž Vajngerl <quikee@gmail.com>	2021-02-17 05:53:49 +0100
commit d338dc277d7dbe381d669728e30a1c2606a4814a (patch)
tree 8efb88cafbf827e38a55ab42e247b3c378ecb2fb
parent 509814d936461cb7690862eac8d6c88e9f412362 (diff)
Move PSD reader from filter module into VCL
it wa
Comment 9 Julien Nabet 2021-06-03 17:35:01 UTC
(argh, wrong key, the comment was sent)
So it was filter/source/graphicfilter/ipsd/ipsd.cxx before this.
When looking at git history, there's not really improvement in PSD implementation. It's above all about logging, clean code, etc.

But when you see psd specs https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1055726 and take a look at Gimp implementation, plug-ins/file-psd/psd-load.c it seems LO is a bit far.

Anyway, can't help here=>uncc myself
Comment 10 stephan.sotter 2021-06-07 07:40:03 UTC
Interesting discussion. As the creator of the issue over at ask.libreoffice I'd like to pitch in.
For starters I'd like to add that looking for a workaround that user already exported the files directly from Photoshop CC into TIFF which, interestingly enough, resulted in the same error. Converting the PSDs to TIFF with XnView *got rid* of the error. I had suggested exporting to PNG instead of TIFF and thankfully that works. So while it's not exclusively a problem with PSD files, the workaround does not need to involve another program.


As for discussion about maintaining the feature, I understand the notion that programmers want to streamline their code and get rid of obsolete features. But as someone that routinely needs to see things from a user perspective I'd like to share that insight. It's not *that* rare that people use Photoshop (pretty common, actually) and save their files in psd (also common). It does have it's merits, like non-destructive editing, so it's hardly obsolete.
Removal of functionality from a software that you have used for years and that was perfect for your needs always feels terrible, even if there is a workaround. I always appreciated that LibO supported some more exotic file types. It happened a couple of times that I could "win over" users by showing them that they can edit PDFs and CDRs with it. In my opinion that's kind of a trademark of LibO and it would make me sad if the political decision would be made to only focus on "core features".

Also from what I've read here the fix sounds not too complicated. Some corner case got overlooked during code cleanup, so maybe just reverse it? And btw. the user sounded pretty happy when I told him about this bugzilla issue and that therefore there is a chance that it will get fixed in a future version. So maybe consider that as well. :)
Comment 11 Xisco Faulí 2021-06-07 10:27:26 UTC
The image started to crash at import time after

https://cgit.freedesktop.org/libreoffice/core/commit/?id=2168d709805a847ac012ff87b06e081ca139d064

author	Noel Grandin <noel.grandin@collabora.co.uk>	2018-02-12 15:29:10 +0200
committer	Noel Grandin <noel.grandin@collabora.co.uk>	2018-02-14 07:28:33 +0100
commit 2168d709805a847ac012ff87b06e081ca139d064 (patch)
tree 76b8597bc1dd992cdc1b6c947f5d532c866e20f8
parent f9e611478f7b5d07a6d623ee04ed3a5ea6b1156e (diff)
use RawBitmap in PSDReader

Adding Cc: to Noel Grandin

Bisected with: bibisect-linux64-6.1

later, the crash was fixed in

https://cgit.freedesktop.org/libreoffice/core/commit/?id=79297e32646bf8276f38b1317319abd36cdd45a8

author	Caolán McNamara <caolanm@redhat.com>	2018-02-15 13:12:41 +0000
committer	Caolán McNamara <caolanm@redhat.com>	2018-02-15 17:14:40 +0100
commit 79297e32646bf8276f38b1317319abd36cdd45a8 (patch)
tree cd20875db354852fbac49558a2413097e37675d9
parent 764e4a4cd384ce9aafa2ba4ba862f7dc8a4c8934 (diff)
ofz#6376 Floating-point-exception

Since then, the General Error is prompted
Comment 12 Alistair Saywell 2021-06-07 22:17:11 UTC
(In reply to stephan.sotter from comment #10)

> For starters I'd like to add that looking for a workaround that user already
> exported the files directly from Photoshop CC into TIFF which, interestingly
> enough, resulted in the same error. Converting the PSDs to TIFF with XnView
> *got rid* of the error. 


TIFF files saved with Zip compression fails (Photoshop export suggests that will happen with older readers); LZW compression imports OK. Don't use 16 bit tiffs (red cast)
Comment 13 Commit Notification 2021-06-09 16:26:15 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/520bb32555985c12642b40fad3b7dcac7a940585

tdf#142629 import psd image with transparent background

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2021-06-10 07:12:07 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/289a9f906bdef65f12ee0acb7069d6f39ac825f4

tdf#142629 import psd image with transparent background

It will be available in 7.1.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Xisco Faulí 2021-06-10 08:08:02 UTC
Verified in

Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: 68b6004fe9df184bcbaf46dd53abfec228219df6
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

@Noel, thanks for fixing this issue!!
Comment 16 Commit Notification 2021-06-10 10:00:50 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/266a3bad6d0537e309922ddafe3a6d4119e2c50c

tdf#142629: vcl_filters_test: Add unittest

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Alistair Saywell 2021-06-16 03:25:14 UTC
Hi. Using LibreOffice 7.2.0.0 alpha1 I cannot import psd with transparent background, including  earlier sample 172585; I get a dialog box saying "Image  filter not found". PSD without transparent background still imports OK. Have I downloaded wrong build?
Cheers, Al
Version: 7.2.0.0.alpha1 (x64) / LibreOffice Community
Build ID: 94c1521be4ef12f195d08413d5e2134e07a49f85
CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: en-NZ (en_NZ); UI: en-GB
Calc: CL