Grapics Device Resolution Limits

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Grapics Device Resolution Limits

Dario Strbenac-2
Good day,

Could the documentation of graphics devices give some explanation of how big the bitmap limits are? For example,

> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")

Results in Error: unable to start png() device, but the help page of devices doesn't explain that there are any limits or how they are determined. The wording of the error message could also be improved, to explain that the resolution is too high or the dimensions are too large.

> sessionInfo()
R version 3.3.2 Patched (2017-02-07 r72138)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grapics Device Resolution Limits

Martin Maechler
>>>>> Dario Strbenac <[hidden email]>
>>>>>     on Fri, 10 Feb 2017 02:00:08 +0000 writes:

    > Good day,
    > Could the documentation of graphics devices give some explanation of how big the bitmap limits are? For example,

    >> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")

    > Results in Error: unable to start png() device,

This is amazing to me.  I see

------------------------------------------------------------------------------
> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
> plot(1)
> dev.off()
null device
          1
> file.info("Figure1A.png")[1:5]
              size isdir mode               mtime               ctime
Figure1A.png 41272 FALSE  644 2017-02-10 17:40:42 2017-02-10 17:40:42
>
------------------------------------------------------------------------------

in three different versions of R I've tried (all were 64-bit Linux).
Note how *small* the file is.
Now, I've also tried a 32-bit version of Linux (Ubuntu 14.04 LTS) and get
a similar result (not exactly the same number of bytes for the file size).


> but the help page of devices doesn't explain that there are any limits or how they are determined. The wording of the error message could also be improved, to explain that the resolution is too high or the dimensions are too large.

If one/some of those who can reproduce the problem in their
versions of R  provide (concise and not hard to read) patches to
the source of R, we'd probably gratefully accept them..

Martin Maechler

    >> sessionInfo()
    > R version 3.3.2 Patched (2017-02-07 r72138)
    > Platform: i386-w64-mingw32/i386 (32-bit)
    > Running under: Windows 7 (build 7601) Service Pack 1

    > --------------------------------------
    > Dario Strbenac
    > University of Sydney
    > Camperdown NSW 2050
    > Australia

    > ______________________________________________
    > [hidden email] mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grapics Device Resolution Limits

R devel mailing list
In reply to this post by Dario Strbenac-2
Were you suppressing warnings?  I get a warning along with the "unable
to start device 'png'" in some cases where it fails.  E.g., on Linux

> png("Figure1A.png", h = 7, w = 7, res = 1e5, units = "cm")
Error in png("Figure1A.png", h = 7, w = 7, res = 1e+05, units = "cm") :
  unable to start device 'png'
In addition: Warning message:
In png("Figure1A.png", h = 7, w = 7, res = 1e+05, units = "cm") :
  cairo error 'invalid value (typically too big) for the size of the
input (surface, pattern, etc.)'

or on Windows

> png("Figure1A.png", h = 7, w = 7, res = 100000, units = "cm")
Error in png("Figure1A.png", h = 7, w = 7, res = 1e+05, units = "cm") :
  unable to start png() device
In addition: Warning messages:
1: In png("Figure1A.png", h = 7, w = 7, res = 1e+05, units = "cm") :
  unable to allocate bitmap
2: In png("Figure1A.png", h = 7, w = 7, res = 1e+05, units = "cm") :
  opening device failed

or when the current directory is not writable (or does not exist)

> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
> plot(1:5)
Error in plot.new() : could not open file 'Figure1A.png'




Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Feb 9, 2017 at 6:00 PM, Dario Strbenac
<[hidden email]> wrote:

> Good day,
>
> Could the documentation of graphics devices give some explanation of how big the bitmap limits are? For example,
>
>> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>
> Results in Error: unable to start png() device, but the help page of devices doesn't explain that there are any limits or how they are determined. The wording of the error message could also be improved, to explain that the resolution is too high or the dimensions are too large.
>
>> sessionInfo()
> R version 3.3.2 Patched (2017-02-07 r72138)
> Platform: i386-w64-mingw32/i386 (32-bit)
> Running under: Windows 7 (build 7601) Service Pack 1
>
> --------------------------------------
> Dario Strbenac
> University of Sydney
> Camperdown NSW 2050
> Australia
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grapics Device Resolution Limits

Prof Brian Ripley
In reply to this post by Martin Maechler
Note that there are at least 5 separate png() devices, so Linux was not
using the (default) device used on Windows.

In general, the device-limits info is not on the help page because we do
not know it.  On Windows the default device limits depend on the OS
version, 32/64-bit, RAM and the graphics hardware.  This sounds like the
last: you were asking for 49 megapixels which is far larger than the
largest screens.  (Or all but the highest-end digital cameras, so one
could well ask what you can usefully do with such an image.)

Normally you will get warning(s) accompanying that Error, but it might
just be

Warning: unable to allocate bitmap
Warning: opening device failed

The first of those is reporting what the GraphApp toolkit said, talking
directly to Windows GDI (and look at the Windows documentation for e.g.
CreateCompatibleBitmap to see that no limits are mentioned).


Even on Windows you have the option of using other png() devices:

png(filename = "Rplot03d.png",
     width = 480, height = 480, units = "px", pointsize = 12,
     bg = "white", res = NA, family = "", restoreConsole = TRUE,
     type = c("windows", "cairo", "cairo-png"), antialias)

Try the other 2 types: the cairo devices do not use your graphics
hardware nor MicroSoft's GDI. (The other 2 devices are Xlib on a
Unix-alike and Quartz on macOS.)


On 10/02/2017 16:54, Martin Maechler wrote:

>>>>>> Dario Strbenac <[hidden email]>
>>>>>>     on Fri, 10 Feb 2017 02:00:08 +0000 writes:
>
>     > Good day,
>     > Could the documentation of graphics devices give some explanation of how big the bitmap limits are? For example,
>
>     >> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>
>     > Results in Error: unable to start png() device,
>
> This is amazing to me.  I see
>
> ------------------------------------------------------------------------------
>> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>> plot(1)
>> dev.off()
> null device
>           1
>> file.info("Figure1A.png")[1:5]
>               size isdir mode               mtime               ctime
> Figure1A.png 41272 FALSE  644 2017-02-10 17:40:42 2017-02-10 17:40:42
>>
> ------------------------------------------------------------------------------
>
> in three different versions of R I've tried (all were 64-bit Linux).
> Note how *small* the file is.
> Now, I've also tried a 32-bit version of Linux (Ubuntu 14.04 LTS) and get
> a similar result (not exactly the same number of bytes for the file size).
>
>
>> but the help page of devices doesn't explain that there are any limits or how they are determined. The wording of the error message could also be improved, to explain that the resolution is too high or the dimensions are too large.
>
> If one/some of those who can reproduce the problem in their
> versions of R  provide (concise and not hard to read) patches to
> the source of R, we'd probably gratefully accept them..
>
> Martin Maechler
>
>     >> sessionInfo()
>     > R version 3.3.2 Patched (2017-02-07 r72138)
>     > Platform: i386-w64-mingw32/i386 (32-bit)
>     > Running under: Windows 7 (build 7601) Service Pack 1
>
>     > --------------------------------------
>     > Dario Strbenac
>     > University of Sydney
>     > Camperdown NSW 2050
>     > Australia

--
Brian D. Ripley,                  [hidden email]
Emeritus Professor of Applied Statistics, University of Oxford

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grapics Device Resolution Limits

Prof Brian Ripley
On 10/02/2017 19:27, Prof Brian Ripley wrote:
> Note that there are at least 5 separate png() devices, so Linux was not
> using the (default) device used on Windows.
>
> In general, the device-limits info is not on the help page because we do
> not know it.  On Windows the default device limits depend on the OS
> version, 32/64-bit, RAM and the graphics hardware.  This sounds like the
> last: you were asking for 49 megapixels which is far larger than the
> largest screens.  (Or all but the highest-end digital cameras, so one
> could well ask what you can usefully do with such an image.)

Scratch that: res is in ppi so the image should be 2755px square: still
rather large.

> Normally you will get warning(s) accompanying that Error, but it might
> just be
>
> Warning: unable to allocate bitmap
> Warning: opening device failed
>
> The first of those is reporting what the GraphApp toolkit said, talking
> directly to Windows GDI (and look at the Windows documentation for e.g.
> CreateCompatibleBitmap to see that no limits are mentioned).
>
>
> Even on Windows you have the option of using other png() devices:
>
> png(filename = "Rplot03d.png",
>     width = 480, height = 480, units = "px", pointsize = 12,
>     bg = "white", res = NA, family = "", restoreConsole = TRUE,
>     type = c("windows", "cairo", "cairo-png"), antialias)
>
> Try the other 2 types: the cairo devices do not use your graphics
> hardware nor MicroSoft's GDI. (The other 2 devices are Xlib on a
> Unix-alike and Quartz on macOS.)
>
>
> On 10/02/2017 16:54, Martin Maechler wrote:
>>>>>>> Dario Strbenac <[hidden email]>
>>>>>>>     on Fri, 10 Feb 2017 02:00:08 +0000 writes:
>>
>>     > Good day,
>>     > Could the documentation of graphics devices give some
>> explanation of how big the bitmap limits are? For example,
>>
>>     >> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>>
>>     > Results in Error: unable to start png() device,
>>
>> This is amazing to me.  I see
>>
>> ------------------------------------------------------------------------------
>>
>>> png("Figure1A.png", h = 7, w = 7, res = 1000, units = "cm")
>>> plot(1)
>>> dev.off()
>> null device
>>           1
>>> file.info("Figure1A.png")[1:5]
>>               size isdir mode               mtime               ctime
>> Figure1A.png 41272 FALSE  644 2017-02-10 17:40:42 2017-02-10 17:40:42
>>>
>> ------------------------------------------------------------------------------
>>
>>
>> in three different versions of R I've tried (all were 64-bit Linux).
>> Note how *small* the file is.
>> Now, I've also tried a 32-bit version of Linux (Ubuntu 14.04 LTS) and get
>> a similar result (not exactly the same number of bytes for the file
>> size).
>>
>>
>>> but the help page of devices doesn't explain that there are any
>>> limits or how they are determined. The wording of the error message
>>> could also be improved, to explain that the resolution is too high or
>>> the dimensions are too large.
>>
>> If one/some of those who can reproduce the problem in their
>> versions of R  provide (concise and not hard to read) patches to
>> the source of R, we'd probably gratefully accept them..
>>
>> Martin Maechler
>>
>>     >> sessionInfo()
>>     > R version 3.3.2 Patched (2017-02-07 r72138)
>>     > Platform: i386-w64-mingw32/i386 (32-bit)
>>     > Running under: Windows 7 (build 7601) Service Pack 1
>>
>>     > --------------------------------------
>>     > Dario Strbenac
>>     > University of Sydney
>>     > Camperdown NSW 2050
>>     > Australia
>


--
Brian D. Ripley,                  [hidden email]
Emeritus Professor of Applied Statistics, University of Oxford

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grapics Device Resolution Limits

Dario Strbenac-2
Good day,

> In general, the device-limits info is not on the help page because we do not know it.

It seems like it would be near-impossible to do in a cross-platform way.

> Normally you will get warning(s) accompanying that Error ...
> Warning: unable to allocate bitmap
> Warning: opening device failed

Yes, I saw those but omitted them from the question.

> Note that there are at least 5 separate png() devices, so Linux was not using the (default) device used on Windows.

That explains it.

> Try the other 2 types: the cairo devices do not use your graphics hardware nor MicroSoft's GDI.

Indeed, it works with the cairo backend.

> ... one could well ask what you can usefully do with such an image.

Unfortunately, some scientific journals have unrealistic figure requirements, e.g. http://www.jidonline.org/content/authorinfo#idp1498768

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel