trunk, 0.91.x: add extension/feature to fix rendering of non-uniformly scaled bitmap images

Bug #1357808 reported by su_v on 2014-08-16
This bug affects 7 people
Affects Status Importance Assigned to Milestone

Bug Description

Follow-up report to
- Bug #616717 “Resized bitmap images are rendered differently by Firefox or Batik ('preserveAspectRatio' attribute not set)”
- Bug #461467 “Image scale saved incorrectly (preserveAspectRatio)”

The recent fix to correctly set the attribute 'preserveAspectRatio' for bitmap images to 'none', and to respect that attribute for rendering, may break Inkscape documents with embedded or linked bitmap images which had been created with Inkscape 0.48 and older versions of Inkscape. It often also affects older Inkscape documents based on imports of file formats like PS/EPS/PDF - such SVG documents often use structures with non-uniformly scaled bitmap images masked by equally scaled bitmap images.

The attached extension allows to add the attribute to selected or all bitmap images in the current document (including bitmap images used as masks, which are stored in the <defs> section). This could serve as workaround until Inkscape has an extended GUI for such attributes (see e.g. bug #1252991).

Please review and test - this was written quickly and not thoroughly tested (a better fix of course would be if Inkscape had an internal feature (with GUI) to set/unset such attributes for <image> elements).

su_v (suv-lp) wrote :
su_v (suv-lp) wrote :
su_v (suv-lp) on 2014-10-21
Changed in inkscape:
milestone: 0.91 → none
su_v (suv-lp) on 2015-02-02
summary: - trunk: add extension to fix rendering of non-uniformly scaled bitmap
- images
+ trunk, 0.91.x: add extension/feature to fix rendering of non-uniformly
+ scaled bitmap images
tags: added: svg
giuliano69 (giuliano-lotta) wrote :

Hi suv,
I've the same problem moving from ver 0,48 to 0,91.

Is your extension intended to be used
-in ver 0,48, to SAVE the interested files, and then "normally open" them in 0,91,
-or to OPEN the files in the new 0,91 (saved with the old 0,48) preventing the error to be displayed?


su_v (suv-lp) wrote :

@giuliano69 - I wrote the extension with Inkscape 091 in mind, but it can be used in either version (in 0.48 to prepare files to be used in 0.91, in 0.91 to fix rendering of files created with older versions). If you run it in 0.48, you won't see an immediate visual effect there, whereas in 0.91, the images will be rendered scaled as expected immediately after the extension has been applied.

1) install extension
2) open the SVG file in Inkscape 0.91
3) apply the extension (Extensions > Images > Set attribute 'preserveAspectRatio')

The default settings will add the attribute to _all_ images in the current document.

Updated version of extension (cleanup, adds one additional scope to
modify images in)

Needs more testing and review.

source also available at

giuliano69 (giuliano-lotta) wrote :

Thanks suv
installed version 0.91, and opened an svg file created with version 0.48
The problem was present.

Applied the plugin and the bitmap suddenly showed correctly.

good work. Thanks a lot !


su_v (suv-lp) wrote :

Setting bug status to confirmed based on two other reports asking about the changes how bitmap images in files created with older Inkscape versions are rendered in Inkscape 0.91 (bug #1417277, bug #1420679).

Changed in inkscape:
status: New → Confirmed

Updated version of the extension:
* combine features for this (bug #1357808) and bug #1418038 into a single extension (Extensions > Images > Set Image Attributes)
* add a new 'Basic' front tab for "Quick fix" feature:
Default: add 'preserveAspectRatio="none"' to all images in document
Optional: change rendering mode for existing images to 'blocky'

Source also available here:

B7 (bech7d) wrote :


I fixed this problem, ( the barbarian way ) for all the thousands of .svg files i previoulsy worked with Inkscape 0.48, by installing and using the tool "regexxer".

regexxer changes any characters in any number of ASCII files.

I just changed all the chains of character in all of my .svg files:


by this chain of character:

<image preserveAspectRatio="none"

I can work ok now, with my 0.48 .svg files

I think this trick should be used only on previoulsy 0.48 .svg files that have not been yet opened by 0.91, because it would add another extra preserveAspectRatio="none" for every images.

I hope this can help.

ScislaC (scislac) wrote :

Tested with trunk r14086, works as expected, I think it should be committed to trunk.

su_v (suv-lp) wrote :

Attaching latest updated version of the extension (I'll commit it to
trunk later today):

332: 2015-05-20 remove 'Help' tab (not really needed); whitespace
331: 2015-05-20 fix 'in_selection' scope
183: 2015-02-27 fix tab context (elif); unify dict usage
182: 2015-02-27 refactor if/else; add live preview
181: 2015-02-27 unset attributes if not checked in 'Basic' tab
180: 2015-02-27 add support for optional <meetOrSlice> value

Changed in inkscape:
assignee: nobody → ~suv (suv-lp)
milestone: none → 0.92
status: Confirmed → In Progress
su_v (suv-lp) wrote :

Extension committed to trunk in r14164.

Changed in inkscape:
status: In Progress → Fix Committed
su_v (suv-lp) on 2015-06-02
description: updated
description: updated
Bryce Harrington (bryce) on 2017-01-10
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

Related questions