Resized bitmap images are rendered differently by Firefox or Batik ('preserveAspectRatio' attribute not set)

Bug #616717 reported by Igor Lino on 2010-08-12
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Tavmjong Bah

Bug Description

Technical details of solution at:

extra explanation:

I have generated a couple of SVG that have embedded images with Inkscape
but after opening or files in firefox, I get everything perfectly rendered
except the images.

Reproducible: Always

Steps to Reproduce:
1.Print/Export any website with background images enabled to a PDF (i.e. using
2.Import the PDF into Inkscape (embedding images)
3.Save the image in SVG format.
4.Open the SVG file in Firefox.
Actual Results:
After opening or files in firefox, I get everything perfectly rendered except
the images which look compressed. The files open fine in Inkscape.

Expected Results:
The embedded images in SVG should render fully as in the original WebSite/PDF.

su_v (suv-lp) on 2010-08-12
tags: added: importing pdf
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48+devel r9701 on OS X 10.5.8 (poppler 0.12.4, cairo 1.8.10)

An imported PDF with embedded images and saved as SVG file only renders as expected in Inkscape, but looks different with regard to the scaling of the embedded bitmap from other renderers (e.g. Firefox 3.6.8, Safari 5.0, Opera 10.60 and Squiggle (Batik 1.7)).

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
su_v (suv-lp) wrote :

from the mozilla bug report:

> Ah, and that's because the meaning of |width="1" height="1"| is that the image
> should be fit into a 1x1 rectangle. _How_ it fits in there depends on the
> value of the preserveAspectRatio attribute. The default value if the attribute
> is not specified is "xMidYMid" according to section 7.8 of the SVG 1.1
> specification. The behavior of this is defined to be:
> Force uniform scaling.
> Align the midpoint X value of the element's ‘viewBox’ with the midpoint X
> value of the viewport.
> Align the midpoint Y value of the element's ‘viewBox’ with the midpoint Y
> value of the viewport.
> If I add preserveAspectRatio="none" to the <image>, then all the browser render
> the way Inkscape does.
> So sounds like this is a bug in Inkscape: it's assuming an incorrect default
> value of preserveAspectRatio.

Related issue reported in:
Bug #461467 in Inkscape: “Image scale saved incorrectly”

After adding 'preserveAspectRatio="none"' to each of the scaled images the SVG file renders as expected and identically in Inkscape, Firefox and Batik.

su_v (suv-lp) wrote :

Edited example from bug #461467 (attached to comment #7),
with 'preserveAspectRatio' added to each scaled image

tags: added: bitmap transformations
removed: importing pdf
su_v (suv-lp) on 2010-08-12
summary: - SVG with embedded images are not readable by Firefox or Baltik
+ Resized bitmap images are rendered differently by Firefox or Batik
+ ('preserveAspectRatio' attribute not set)
su_v (suv-lp) wrote :

from the Scalable Vector Graphics (SVG) 1.1 specification:

5.7 The ‘image’ element:
«If attribute ‘preserveAspectRatio’ is not specified, then the effect is as if a value of xMidYMid meet were specified.»

5.8 The ‘preserveAspectRatio’ attribute:
«For ‘image’ elements, ‘preserveAspectRatio’ indicates how referenced images should be fitted with respect to the reference rectangle and whether the aspect ratio of the referenced image should be preserved with respect to the current user coordinate system.»

su_v (suv-lp) wrote :

Setting bug importance to 'High' in accordance with
"non-SVG-compliant output"

Changed in inkscape:
importance: Medium → High
tags: added: svg
su_v (suv-lp) wrote :

Fixed for direct bitmap image import in r13020, for bitmap images of imported PDF files in r13023.

See also:

Changed in inkscape:
assignee: nobody → Tavmjong Bah (tavmjong-free)
milestone: none → 0.91
status: Confirmed → Fix Committed
Magnes (magnesus2) wrote :

I now have - after the fix - a weird problem - some images in my old SVG files have preserveAspectRatio="none" and some don't and I can't change it in Inkscape - yet it affect the way I can scale them (I want them to scale independently of the aspect ratio)... The result is that I can't scale some of the images in my Inkscape file without preserving the aspect ratio. :(

Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers