Export to png - DPI rounds down next time

Bug #1089040 reported by pRototype
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Undecided
Unassigned

Bug Description

Hi.

I've tested this on two computer that have both different OS and Inkscape version. Inkscape behaved just the same on both computers:
Computer 1: Windows 7, norwegian. Inkscape 0.48.3.1 r9886
Computer 2: Windows xp, norwegian. Inkscape 0.48+devel r11943

Sample file is provided, I cannot always reproduce on a brand new svg file.

Steps to reproduce:
* Open sample file. Open the "Export PNG image" dialog box.
* Select "Page" and set dpi to 36,00
* Export a PNG file.
* Close the dialog box and Inkscape. Save the file.

* Open same file again. and open the "Export PNG image" dialog box, just like before.
* Notice that DPI is now changed from 36 to 35.

That means that I have to change the DPI settings every time I'm about to export to PNG after reopening the svg file.

Revision history for this message
pRototype (regeir) wrote :
Revision history for this message
nightrow (jb-benoit) wrote :

Hi,
I just reproduced it on win7 with inkscape 0.48.2
However, if you set dpi to 36, just click on the dialog with image size, and you will see that dpi is in fact re-computed to 35.9xxx.
So i guess that it's then saved as 35 without further precision.
I tried to set dpi to 36.02, and saw that it's then rounded to 36, what you want, and it stay that way after re-opening the file.
Does it work for you ?
Anyway this is strange that the requested dpi is not stored, i'm guessing the resolution is stored, and the dpi re-computed from it.

Revision history for this message
pRototype (regeir) wrote :

Hi.

Setting the dpi to 36,02 seems to work here too. At least on the XP computer.

But having Inkscape reducing from 36,02 to 36,00 is still no satisfied solution.

Afaik this is not an issue when dealing with px as unit. But in this project, I had a mix of millimeters and centimeters. Maybe that is what confuses Inkscape?

su_v (suv-lp)
tags: added: bitmap ui
removed: dpi
tags: added: precision
removed: ui
Revision history for this message
jazzynico (jazzynico) wrote :

Not reproduced on Windows XP, Inkscape 0.48.3.1, 0.48.5 and trunk rev. 14005, French locales and new preferences.xml file.
The dpi values are correctly saved, not rounded.

pRototype, nightrow, are you still affected? If so, could you please attach you preferences.xml file so that we could investigate with the same preferences? Thanks!

Changed in inkscape:
status: New → Incomplete
Revision history for this message
pRototype (regeir) wrote :

Still affected.
Inkscape 0.91pre2 r13516

At exporting first time, I set DPI to 36. When i shift focus (t.ex by click export button, but drag the mouse away) or export, DPI changes to 35,98.

I did export to png twice before I noticed that DPI was set to 35 (not by me).

Contents of preferences.xml
http://pastebin.com/gNkWP8Qt

Revision history for this message
Alvin Penner (apenner) wrote :

strictly speaking, this last comment 5, is a separate issue, not related to the original report. The original report concerned the question of whether the export settings were being correctly remembered or not. The answer to that is yes, they are remembered. For example, use the following steps:
- open sample_dpibugfile.svg
- set the png export dpi at 37.89 just for fun
- export the png file and make sure to save the svg file as well, this is very important
- now read the svg file in a text editor and get the settings:

   inkscape:export-xdpi="37.889999"
   inkscape:export-ydpi="37.889999

- note that there is a bit of round-off error but that is not serious
- now read the preferences.xml file and get the settings:

      <group
         id="exportarea"
         value="page" />
      <group
         id="defaultxdpi"
         value="37.89" />

- in this case there is no round-off error here
- now reload Inkscape and note that it remembers the 37.89 dpi value

- the exact behavior you get on the reload may depend on whether you saved the svg file or not, because the data is stored in two places. If you did not save the svg file then the value remembered in the preferences may be different than the value stored in the file. The next time you start Inkscape, if you start it with no file specified, then you will initially get the value stored in the preferences, and then if you load the svg file you will get the value stored in the file.

with respect to comment 5, the problem here is that there are two ways of doing the calculation. you can either do it by using dpi to calculate the png image size or you can do it by using png image size to calculate dpi. The two methods will normally not agree due to round-off error, since the image size is apparently rounded-off to be an integer, while the dpi is not rounded. The exact result you get may depend on which text box you last clicked on or which text box most recently lost focus. If you want the dpi to be fixed at 36 then I think the best thing to do is just make sure that the dpi box is the last thing you touch before you export.

 unfortunately the situation is a bit unnecessarily complicated. one way to simplify it would be to make the dpi as the independent variable and make the image size to be a dependent variable which could not be directly edited. However that would almost certainly disagree with some other users's preferences.

su_v (suv-lp)
Changed in inkscape:
status: Incomplete → New
Revision history for this message
su_v (suv-lp) wrote :

Other related reports:
* Bug #1484161 “dpis in export PNG, reset to whole number after deselecting the object”
* Bug #286000 “Export bitmap dialog DPI field changes value when height/width fields lose focus”

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.