Bug 97383

Summary: SVG: Embedded images doesn't keep ratio when width and height are different
Product: LibreOffice Reporter: Xisco Faulí <xiscofauli>
Component: LibreOfficeAssignee: Xisco Faulí <xiscofauli>
Status: RESOLVED FIXED    
Severity: normal CC: h3734236, rb.henschel, xiscofauli
Priority: medium Keywords: filter:svg
Version: 5.2.0.0.alpha0+   
Hardware: All   
OS: All   
Whiteboard: target:5.2.0
Crash report or crash signature: Regression By:
Attachments: sample
comparison Firefox and Libreoffice
not squared embedded image
Example with preserveAspectRatio

Description Xisco Faulí 2016-01-26 23:14:26 UTC
Created attachment 122225 [details]
sample

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();
297 
298                             if(rRatio.isSet())
299

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":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=080e5f2f24513e871f2563c88a69fa8a9ecfe0eb

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

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.