[GRASS-dev] Rendering from command line does not respect size

Hi,

I was trying to render some maps automatically but I’m having problems with setting the size of the image. I set size like this:

export GRASS_RENDER_HEIGHT=1350
export GRASS_RENDER_WIDTH=1500

But with cairo I get still the default size:

d.mon cairo
d.rast aspect

map.png size is now 640x480

d.mon stop=cairo

rm map.png

With png I get an error:

d.mon png
d.rast aspect
ERROR: PNG: input file has incorrect dimensions: expected: 640x480 got:
1500x1350

map.png is now empty but it has the correct size

d.mon stop=png
rm map.png

With wx0 I get the error but also an image in GUI. The main GUI works without any errors. I observe same behavior in 70 branch and when using height and width parameters of d.mon. I exited the session and started again.

Any idea what’s happening or what should I try?

Thanks,
Vaclav

On 01/05/15 05:24, Vaclav Petras wrote:

Hi,

I was trying to render some maps automatically but I'm having problems
with setting the size of the image. I set size like this:

export GRASS_RENDER_HEIGHT=1350
export GRASS_RENDER_WIDTH=1500

But with cairo I get still the default size:

d.mon cairo
d.rast aspect
# map.png size is now 640x480
d.mon stop=cairo
rm map.png

With png I get an error:

d.mon png
d.rast aspect
ERROR: PNG: input file has incorrect dimensions: expected: 640x480 got:
        1500x1350
# map.png is now empty but it has the correct size
d.mon stop=png
rm map.png

I have a vague memory that such an error occurs when you have an existing map.png file in the current directory with dimensions different from the ones you set.

Moritz

On Sat, May 2, 2015 at 12:13 PM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 01/05/15 05:24, Vaclav Petras wrote:

Hi,

I was trying to render some maps automatically but I’m having problems
with setting the size of the image. I set size like this:

[…]

Again for cairo:

$ mkdir abc1
$ cd abc1
$ export GRASS_RENDER_HEIGHT=1350
$ export GRASS_RENDER_WIDTH=1500
$ g.region raster=elevation
$ d.mon cairo
Output file: …/abc1/map.png
$ d.rast elevation
$ file map.png
map.png: PNG image data, 640 x 480, 8-bit/color RGB, non-interlaced
(image contains elevation in 640 x 480)

The same for SVG:

<svg … width=“640pt” height=“480pt” viewBox=“0 0 640 480” version=“1.1”>

<image id=“image5” width=“640” height=“480”…

and also PDF.

And again for png:

$ mkdir abc2
$ cd abc2
$ export GRASS_RENDER_HEIGHT=1350
$ export GRASS_RENDER_WIDTH=1500
$ g.region raster=elevation
$ d.mon png
Output file: …/abc2/map.png
$ d.rast elevation
ERROR: PNG: input file has incorrect dimensions: expected: 640x480 got:
1500x1350
$ file map.png
map.png: PNG image data, 1500 x 1350, 8-bit/color RGBA, non-interlaced
(image contains nothing but has 1500 x 1350)

I have a vague memory that such an error occurs when you have an existing map.png file in the current directory with dimensions different from the ones you set.

I’ve tried to use an empty directory but no effect. So this is not the case. According to this test it seems that PNG driver does not work at all with different height and width, is that even possible?

Vaclav

Moritz

On Sun, May 3, 2015 at 12:04 AM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

On Sat, May 2, 2015 at 12:13 PM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

On 01/05/15 05:24, Vaclav Petras wrote:

Hi,

I was trying to render some maps automatically but I'm having problems
with setting the size of the image. I set size like this:

[...]

Again for cairo:

$ mkdir abc1
$ cd abc1
$ export GRASS_RENDER_HEIGHT=1350
$ export GRASS_RENDER_WIDTH=1500
$ g.region raster=elevation
$ d.mon cairo
Output file: .../abc1/map.png
$ d.rast elevation
$ file map.png
map.png: PNG image data, 640 x 480, 8-bit/color RGB, non-interlaced
(image contains elevation in 640 x 480)

Confirmed for trunk.

Indeed, in relbranch70 I get

GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_HEIGHT=1350
GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_WIDTH=1500
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon start=png
ERROR: PNG: input file is not RGBA

# trying harder:
GRASS 7.0.1svn (nc_spm_08_grass7):~ > echo $GRASS_RENDER_TRUECOLOR

GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_TRUECOLOR=TRUE
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon start=png
ERROR: PNG: input file is not RGBA

huh?

Markus

Hi,

2015-05-01 5:24 GMT+02:00 Vaclav Petras <wenzeslaus@gmail.com>:

I was trying to render some maps automatically but I'm having problems with
setting the size of the image. I set size like this:

export GRASS_RENDER_HEIGHT=1350
export GRASS_RENDER_WIDTH=1500

But with cairo I get still the default size:

d.mon cairo
d.rast aspect
# map.png size is now 640x480
d.mon stop=cairo
rm map.png

please try out r65178. d.mon should respect GRASS_RENDER_HEIGHT and
GRASS_RENDER_WIDTH if `width/height` is not set.

With png I get an error:

d.mon png
d.rast aspect
ERROR: PNG: input file has incorrect dimensions: expected: 640x480 got:
       1500x1350
# map.png is now empty but it has the correct size
d.mon stop=png
rm map.png

Should be also fixed. Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

Hi,

2015-05-03 7:22 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_HEIGHT=1350
GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_WIDTH=1500
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon start=png
ERROR: PNG: input file is not RGBA

input image has been apparently created by cairo. Try to delete file
before starting png display driver. Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Sun, May 3, 2015 at 12:11 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2015-05-03 7:22 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_HEIGHT=1350
GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_WIDTH=1500
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon start=png
ERROR: PNG: input file is not RGBA

input image has been apparently created by cairo. Try to delete file
before starting png display driver. Martin

Good catch! I though I had deleted it...

GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_HEIGHT=1350
GRASS 7.0.1svn (nc_spm_08_grass7):~ > export GRASS_RENDER_WIDTH=1500
GRASS 7.0.1svn (nc_spm_08_grass7):~ > rm -f map.png
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon start=png
Output file: /home/neteler/map.png
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.rast aspect
GRASS 7.0.1svn (nc_spm_08_grass7):~ > d.mon stop=png
GRASS 7.0.1svn (nc_spm_08_grass7):~ > file map.png
map.png: PNG image data, 640 x 480, 8-bit/color RGBA, non-interlaced

### now testing latest trunk changes:

...
GRASS 7.1.svn (nc_spm_08_grass7):~ > file map.png
map.png: PNG image data, 1500 x 1350, 8-bit/color RGBA, non-interlaced

... the latest change helps: seems to work now.

thanks
Markus

On Sun, May 3, 2015 at 4:12 PM, Markus Neteler <neteler@osgeo.org> wrote:

### now testing latest trunk changes:

...
GRASS 7.1.svn (nc_spm_08_grass7):~ > file map.png
map.png: PNG image data, 1500 x 1350, 8-bit/color RGBA, non-interlaced

... the latest change helps: seems to work now.

Thanks Martin, with r65183 most of the things work. With environmental
variables both PNG and Cairo drivers worked, i.e. the size was appropriate.
Options width and height worked for Cairo but not for PNG:

ls

(nothing)

d.mon png width=1500 height=1350
d.rast elevation

ERROR: PNG: input file has incorrect dimensions: expected: 1500x1350 got:
       640x480

file map.png

map.png: PNG image data, 640 x 480, 8-bit/color RGBA, non-interlaced

And the file is empty (white).

I also tested the default settings for Cairo and it (correctly) gives
640x480 image.

Hi,

2015-05-04 2:47 GMT+02:00 Vaclav Petras <wenzeslaus@gmail.com>:

d.mon png width=1500 height=1350
d.rast elevation

ERROR: PNG: input file has incorrect dimensions: expected: 1500x1350 got:
       640x480

I cannot reproduce this behavior:

d.mon png w=1000 h=500 out=/tmp/png.png

d.rast dmt --v
...
png: image size 1000x500

Probably map.png has been created by cairo driver? Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Mon, Mar 28, 2016 at 2:53 PM, Martin Landa <landa.martin@gmail.com>
wrote:

2015-05-04 2:47 GMT+02:00 Vaclav Petras <wenzeslaus@gmail.com>:
> d.mon png width=1500 height=1350
> d.rast elevation
>
> ERROR: PNG: input file has incorrect dimensions: expected: 1500x1350 got:
> 640x480

I cannot reproduce this behavior:

d.mon png w=1000 h=500 out=/tmp/png.png

d.rast dmt --v
...
png: image size 1000x500

Works with output.

d.mon png width=1500 height=1350 output=/tmp/png.png
d.rast elevation --v

Using display driver <png>...
png: truecolor status enabled
png: collecting to file '/tmp/png.png'
png: image size 1500x1350

But using the default file name it fails:

d.mon png width=1500 height=1350
d.rast elevation --v

Using display driver <png>...
png: truecolor status enabled
png: collecting to file '/.../map.png'
png: image size 1500x1350
ERROR: PNG: input file has incorrect dimensions: expected: 1500x1350 got:
       640x480

When I use file command:

ls

[nothing]

d.mon png width=1500 height=1350
file map.png

map.png: PNG image data, 640 x 480, 8-bit/color RGBA, non-interlaced

Probably map.png has been created by cairo driver? Ma

No sure how this works but I'm not starting cairo at the same time.

Thanks for getting back to this,
Vaclav

Hi,

2016-03-28 21:12 GMT+02:00 Vaclav Petras <wenzeslaus@gmail.com>:

should be fixed in r68197. Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa