--export-area didnt handle decimal values correct

Bug #168641 reported by Bug Importer
0
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Medium
Unassigned

Bug Description

Im calling Inkscape from the console to export a particular region of a
drawing. And everytime i try to use decimal values for "--export-area" it
creates crazy results. (Used Version: 0.45.1 affects Ubuntu and Windows)

For example:

SOURCE_NAME="sakura.svg"
TARGET_NAME="sakura-export.png"
X0=0.0
Y0=0.0
X1=$(inkscape -f $SOURCE_NAME -W)
Y1=$(inkscape -f $SOURCE_NAME -H)
AREA_ARG=$X0":"$Y0":"$X1":"$Y1
echo $AREA_ARG
inkscape \
--file=$SOURCE_NAME \
--export-png=$TARGET_NAME \
--export-area=$AREA_ARG \
--export-width=400 \
--export-height=300

produces the following errormessage:

0.0:0.0:1121.1296:836.25244
** (inkscape:22037): WARNING **: Export area '0.0:0.0:1121.1296:836.25244'
has negative width or height. Nothing exported.

But it has a correct width and height!

The related code is in "src/main.cpp" at Line 861:

    if (sp_export_area) {
        /* Try to parse area (given in SVG pixels) */
        if (!sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &area.x0, &area.y0,
&area.x1, &area.y1) == 4) {
            g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'.
Nothing exported.", sp_export_area);
            return;
        }
        if ((area.x0 >= area.x1) || (area.y0 >= area.y1)) {
            g_warning("Export area '%s' has negative width or height.
Nothing exported.", sp_export_area);
            return;
        }
    }

I cant say what is the exact error (im no C/C++ Developer), but it seems
that sscanf dont parse or store the values correctly.

Contact: <email address hidden>

Revision history for this message
Tobain-users (tobain-users) wrote :

Originator: NO

I tried a little bit more and found the real reason for that behavior:

Im from germany and we use the "," instead of the "." to separate the
decimal parts. If i write the values with ",", they are parsed correctly.
But i think inkscape should constantly use the "." character, since most
other programms and also inkscape deliver values with the "." character.

What to do: Replace the sscanf() with a call that uses "." for the decimal
part in "all" languages!

Revision history for this message
Bryce Harrington (bryce) wrote :

Not really sure if forcing it to always use . is the right solution, but this issue definitely needs further consideration.

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
dmarks (markstedt) wrote :

Bug seems to have been resolved as of v0.47 r22583.

C.f. discussion at https://gna.org/bugs/index.php?16292

Revision history for this message
su_v (suv-lp) wrote :

AFAIU the issue still exists when calling inkscape e.g. from within a python extension script: see <https://bugs.launchpad.net/inkscape/+bug/618581/comments/8>

su_v (suv-lp)
tags: added: cli
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.