Bug 97383 - SVG: Embedded images doesn't keep ratio when width and height are different
Summary: SVG: Embedded images doesn't keep ratio when width and height are different
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
(earliest affected)
Hardware: All All
: medium normal
Assignee: Xisco Faulí
Whiteboard: target:5.2.0
Keywords: filter:svg
Depends on:
Reported: 2016-01-26 23:14 UTC by Xisco Faulí
Modified: 2016-10-25 19:11 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:

sample (216.98 KB, image/svg+xml)
2016-01-26 23:14 UTC, Xisco Faulí
comparison Firefox and Libreoffice (22.56 KB, image/png)
2016-01-26 23:14 UTC, Xisco Faulí
not squared embedded image (214.40 KB, image/svg+xml)
2016-01-28 23:04 UTC, Xisco Faulí
Example with preserveAspectRatio (1002.31 KB, application/zip)
2016-01-31 15:43 UTC, Regina Henschel

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2016-01-26 23:14:26 UTC
Created attachment 122225 [details]

Steps to reproduce:
   1. Open attached file where the 3 images have different widths and heights
Comment 1 Xisco Faulí 2016-01-26 23:14:56 UTC
Created attachment 122226 [details]
comparison Firefox and Libreoffice
Comment 2 Xisco Faulí 2016-01-28 23:04:25 UTC
Created attachment 122264 [details]
not squared embedded image
Comment 3 Regina Henschel 2016-01-31 15:43:38 UTC
Created attachment 122297 [details]
Example with preserveAspectRatio

The image element has no attribute preserveAspectRatio. In such cases the default value "xMidYMid meet" has to be used, see end of section 5.7 in https://www.w3.org/TR/SVG/struct.html#ImageElement

If the attribute preserveAspectRatio="xMidYmid meet" is set in the image element, then the rendering is correct.

Therefore the error is, that in case of missing attribute the default is not used. I have not looked yet, where in the source this is.

I have used an example with a linked image, so you can be sure, that it is in all cases the same image. The package contains the png image, the two svg images (one with attribute, the other without) and a Draw document which links the svg images.
Comment 4 Regina Henschel 2016-01-31 15:55:11 UTC
It seems to be in /core/svgio/source/svgreader/svgimagenode.cxx the part around

293                 else
294                         {
295                             // create mapping
296                             const SvgAspectRatio& rRatio = getSvgAspectRatio();
298                             if(rRatio.isSet())

In case rRatio.isSet() results in false, the default values have to be set, and then mapping outside the case differentiation. (I think so, but have not tested it.)
Comment 5 Commit Notification 2016-02-05 09:26:56 UTC
Armin Le Grand committed a patch related to this issue.
It has been pushed to "master":


SVGIO: tdf#97383: Keep ratio in embedded images...

It will be available in 5.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Xisco Faulí 2016-02-08 10:08:40 UTC
I gess we can already close this.