setting the dpi of an image generated by the image package

806 views
Skip to first unread message

plno...@gmail.com

unread,
Jul 9, 2013, 9:51:02 PM7/9/13
to golan...@googlegroups.com
I'm writing an image composition engine for layering several PNGs on Bing map tiles, which will usually be printed out. One of the requirements of this system is that via the API, a DPI quality can be specified along with a resolution. For example, one could request a 1920x1200 sized image at a quality of 300dpi. Does the Go "image" package support setting DPI of images generated by NewNRGBA, or any other mechanism?

With PIL (Python Imaging Library) this is possible, but I'm not seeing anything about DPI in the Go docs.

Thanks in advance!

Patrick

plno...@gmail.com

unread,
Jul 10, 2013, 12:17:55 AM7/10/13
to golan...@googlegroups.com
Also, should be PPI not DPI.

Nigel Tao

unread,
Jul 10, 2013, 1:13:30 AM7/10/13
to plno...@gmail.com, golang-nuts
On Wed, Jul 10, 2013 at 11:51 AM, <plno...@gmail.com> wrote:
> Does the Go "image" package support setting DPI of images
> generated by NewNRGBA, or any other mechanism?

The standard image package covers the basics but doesn't include a way
to set PPI metadata. I'm guessing that it's implied by the pHYs
ancillary chunk. You could eitiher fork the image/png package or just
insert the pHYs chunk into the resultant bytes at an appropriate spot,
like after the IHDR chunk.

http://www.w3.org/TR/PNG/#11pHYs

plno...@gmail.com

unread,
Jul 10, 2013, 1:33:46 AM7/10/13
to golan...@googlegroups.com, plno...@gmail.com
Thanks for the reply Nigel - I'll see if I can make this work.

Patrick

ako...@gmail.com

unread,
Dec 27, 2014, 2:42:54 PM12/27/14
to golan...@googlegroups.com, plno...@gmail.com
Hello Patrick, have you figured out how to set PPI on an image? Would you be able to share it? I have the same requirement.
thanks
Konstantin

среда, 10 июля 2013 г., 1:33:46 UTC-4 пользователь Patrick Nordahl написал:
Reply all
Reply to author
Forward
0 new messages