Bug 135642 - FILESAVE FILEOPEN When saving a document with a .svg file with the .fodt format, the quality of the svg file decrease
Summary: FILESAVE FILEOPEN When saving a document with a .svg file with the .fodt form...
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
Depends on:
Blocks: ODF-Flat
  Show dependency treegraph
Reported: 2020-08-11 16:10 UTC by guillaume.guillet
Modified: 2022-11-16 03:30 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

Images of the problem (116.65 KB, application/x-zip-compressed)
2020-08-11 16:10 UTC, guillaume.guillet
A svg file that been used to find the bug (54.23 KB, image/svg+xml)
2022-06-01 20:31 UTC, guillaume.guillet

Note You need to log in before you can comment on or make changes to this bug.
Description guillaume.guillet 2020-08-11 16:10:44 UTC
Created attachment 164169 [details]
Images of the problem

When saving a document with a .svg file in it with the .fodt format, the quality of the svg file decrease.

1) I created a .odt file and add a .svg file in it.

2) I saved the .odt file, close it, and reopen it.

3) Now i saved the file into a .fodt file.

4) By opening the .fodt file, the .svg file is pixelated.
Comment 1 woundorf 2020-10-27 09:25:56 UTC
There's a workaround for this: if you open the advanced configuration (Tools > Options, LibreOffice > Advanced, Open advanced configuration) and set a setting called GenerateThumbnail to false it won't happen anymore (for newly inserted images).
Comment 2 Martin Srdoš 2020-11-23 19:55:57 UTC
Hello guillaume.guillet,

Thank you for reporting the bug. I can confirm that the bug is present in master.

I can't confirm what is written in comment 1. The behavior is still faulty.

Version: (x64)
Build ID: 418c63dff5db2005bbc4dbfc92b56778f89cea8b
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: en-GB
Calc: CL

First version, where is the bug:
Version: (x64)
Build ID: 378e26bd4f22a135cef5fa17afd5d4171d8da21a
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: cs-CZ (cs_CZ); Calc: CL

The last version, where it is work ok:
Version: (x64)
Build ID: 78c12ce5f2b8960f18b204a7ea82f971769f1679
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: cs-CZ (cs_CZ); Calc: CL
Comment 3 BogdanB 2020-12-21 16:57:09 UTC
Could be a duplicate of https://bugs.documentfoundation.org/show_bug.cgi?id=80219

*** This bug has been marked as a duplicate of bug 80219 ***
Comment 4 guillaume.guillet 2022-06-01 20:28:01 UTC
Hi again, the bug still appear with version x64 with the same steps.

The potential duplicate of https://bugs.documentfoundation.org/show_bug.cgi?id=80219

has been marked as wont fix but this bug is still clearly there (note that I don't think it was a duplicate).
Comment 5 guillaume.guillet 2022-06-01 20:31:04 UTC
Created attachment 180531 [details]
A svg file that been used to find the bug
Comment 6 Stephen Heumann 2022-11-15 10:06:17 UTC
I can reproduce this on macOS with a recent development build:

Version: (X86_64) / LibreOffice Community
Build ID: 55cd20e6228a06836285c14ca6726adb1bb4ffcb
CPU threads: 10; OS: Mac OS X 13.0.1; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Looking into it a bit, the issue seems to stem from the fact that LibreOffice saves a PNG version of the SVG image for use as a fallback. So it produces code like the following in the .fodt file:

<draw:frame ...>
 <draw:image draw:mime-type="image/svg+xml">
 <draw:image draw:mime-type="image/png">

The first <draw:image> element within the <draw:frame> is supposed to represent the preferred format of the image, in this case SVG. But when LibreOffice reads the .fodt file back in, it seems to ignore the SVG version and use the pixellated PNG version instead.

If I manually edit the XML code in the .fodt file to either remove the PNG version or put the PNG version before the SVG version, then LibreOffice will use the SVG version of the image. So it seems like the issue is that LibreOffice is preferring the last <draw:image> element rather than the first one when reading a .fodt file.
Comment 7 Stephen Heumann 2022-11-16 00:57:54 UTC
I identified a workaround for this: In the options under LibreOffice > Advanced, Open Expert Configuration, search for AddReplacementImage and set it to false. This will prevent generation of the fallback PNG version of SVG images, so the problem does not arise.