[Thread Prev][Thread Next][Index]

Re: [ferret_users] PyFerret: DPI info for PNG output



Hi Karl,

On Wed, Jan 22, 2020 at 9:30 AM Karl Smith - NOAA Affiliate <karl.smith@xxxxxxxx> wrote:
[ . . . ] there currently is no attempt to assign such a value when creating raster image files (such as PNG and JPEG.)  I do now see in Qt there are the QImage.setDotsPerMeterX and QImage.setDotsPerMeterY methods which presumably set these values (and hopefully not anything more than that).  So I can try adding that in.

Thank you for your positive response.  It's not an urgent issue at all.  It's just that It would be a nice enhancement, I think.

When PyFerret does need DPI values, for displayed windows it does get the values for the window using the physicalDpiX and physicalDpiY methods of the QMainWindow.  For windows that are not displayed (so using the "-nodisplay" command-line option for PyFerret), the default value of 96 DPI is assigned since there is no display to obtain a value from, and that value was pretty standard at the time.

What I (think I) found after my initial email message was that the PNG file from a "-nodisplay" run does not include DPI info whereas that from a displayed run includes "28.35 x 28.35 pixels/cm" in its header(*footnote), which corresponds to 72 x 72 pixels/inch.

Regards,
Ryo
--------------------
(*footnote)  For the curious, the "identify" command of the ImageMagick suit displays these pieces of information:
$ identify -verbose tmp0200.png | grep Units
  Units: PixelsPerCentimeter
$ identify -verbose tmp0200.png | grep Resolution
  Resolution: 28.35x28.35
Also, open the image with GIMP and go to "Image" > "Image Properties".  (On the other hand, "Image" > "Metadata" > "View Metadata" shows the image's Exif header, which seems to include a low-precision version of resolution info such as "28 x 28 pixels/cm".)
 

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement