Bug 122057 - Loading Deflate/ZIP compression in TIFF image does not work
Summary: Loading Deflate/ZIP compression in TIFF image does not work
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: BSA target:7.4.0
Keywords:
Depends on:
Blocks: Images-TIFF
  Show dependency treegraph
 
Reported: 2018-12-12 18:42 UTC by Jan Ågren
Modified: 2022-05-21 18:32 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
2 samples of tif-files that trigger "Unknown format" (566.72 KB, image/tiff)
2018-12-13 18:43 UTC, Jan Ågren
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Ågren 2018-12-12 18:42:10 UTC
Description:
When loading a tif image into a document I get the response: Unknown format.
Other formats works well

Steps to Reproduce:
1.Insert a tif-image
2.
3.

Actual Results:
Unknown format

Expected Results:
Loaded ok


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Comment 1 Oliver Brinzing 2018-12-13 18:10:42 UTC Comment hidden (obsolete)
Comment 2 Jan Ågren 2018-12-13 18:43:56 UTC
Created attachment 147509 [details]
2 samples of tif-files that trigger "Unknown format"
Comment 3 Oliver Brinzing 2018-12-13 19:20:36 UTC
reproducible with attached tif.

also noticed: drag & drop into writer document opens "Insert Section" dialog
Comment 4 Xisco Faulí 2018-12-18 13:19:37 UTC
Also reproduced in

Version: 5.2.0.0.alpha0+
Build ID: 3ca42d8d51174010d5e8a32b96e9b4c0b3730a53
Threads 4; Ver: 4.15; Render: default; 


LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 5 Timur 2021-05-05 10:18:24 UTC Comment hidden (obsolete)
Comment 6 Julien Nabet 2022-05-17 09:40:04 UTC
tiffinfo gives:
=== TIFF directory 0 ===
TIFF Directory at offset 0x86814 (550932)
  Subfile Type: (0 = 0x0)
  Image Width: 7581 Image Length: 3457
  Resolution: 200, 200
  Bits/Sample: 8
  Compression Scheme: Deflate
  Photometric Interpretation: palette color (RGB from colormap)
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 1
  Planar Configuration: single image plane
  Color Map: (present)

Today, tiff mechanism import in LO doesn't implement "Deflate" compression.

IHMO, it should be considered as an enhancement.
Comment 7 Julien Nabet 2022-05-17 13:55:12 UTC Comment hidden (obsolete)
Comment 8 Julien Nabet 2022-05-17 14:00:33 UTC
(In reply to Julien Nabet from comment #7)
> I noticed there's include/package/Inflater.hxx (to decompress "Deflate"
> compressed code) but this one takes "Sequence" var for in and out.
> So if someone wants to use it, at least it won't be from scratch.

Of course this person may also prefer implementing libtiff or another lib for this to read several tiff "flavors" in a row but it'll be more work as already indicated in another bugtracker related to tiff.
Could be an idea for Gsoc next year?
Comment 9 Julien Nabet 2022-05-17 15:26:51 UTC
I gave a try with https://gerrit.libreoffice.org/c/core/+/134485
Comment 10 Timur 2022-05-17 17:11:54 UTC Comment hidden (obsolete)
Comment 11 Julien Nabet 2022-05-17 17:18:44 UTC Comment hidden (obsolete)
Comment 12 V Stuart Foote 2022-05-17 18:21:18 UTC
(In reply to Julien Nabet from comment #11)
> (In reply to Timur from comment #10)
> > (In reply to Julien Nabet from comment #8)
> > > Could be an idea for Gsoc next year?
> > 
> > Buovjaga is a person for ideas. 
> > But since you are in it now, do you consider yourself a candidate for that,
> > GSoC or not? 
> No thank you.
> 
> > Yes, an endeavor, but that would be an achievement.
> Indeed! I suppose it also depends on if tiff format is widely and often used
> or not and I have no idea about this.

Gutting out our own OOo/LO code and doing the libtiff integration, assuming permisible licensing, seems the better GSOC project scope. Might need to be stripped down a bit cross platform, but would go into /external like poppler, pdfium, libpng, etc.
Comment 13 Commit Notification 2022-05-17 18:54:05 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f0d3727322207b3a547313e14305440ad7009079

tdf#122057: read tiff with deflate compression (code 32946 only)

It will be available in 7.4.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 Julien Nabet 2022-05-17 18:59:26 UTC
I'd like to have 1 or 2 more examples with this specific compression 32946 because a black rectangle isn't a good example.
(hope the attachment was indeed a black rectangle, at least Gimp displays as this).

I tried to generate an example file with Gimp but it exports with Adobe deflate 8 code.

Remark: I pushed the patch quickly on master so people can give it a try. If it's wrong, it can be reverted.
Comment 15 Commit Notification 2022-05-17 19:06:31 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/522de4493e982d987f55fd88a64dd9e83c46e895

Revert "tdf#122057: read tiff with deflate compression (code 32946 only)"

It will be available in 7.4.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 16 Julien Nabet 2022-05-17 19:08:22 UTC
Argh, just opened with Firebird, it's not a black rectangle but design plan for a house.
The patch was wrong then so I reverted it :-(.
Comment 17 Caolán McNamara 2022-05-21 18:22:33 UTC
I've committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/22b50f1937de67e4ad9e692d6964aa5b8d33af7a

use libtiff for tiff import

It will be available in 7.4.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 18 Julien Nabet 2022-05-21 18:32:13 UTC
I confirm it works!