about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-06-27 02:05:18 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-06-27 02:05:18 +0000
commit3bbf7f47724bc05c32cd9d4b53425765dfe711ed (patch)
tree107fc54f21584c1d225d946d60850ff195daa611 /converter
parentbcfb7ea3c80a10cc948e0e82c801fa9365835e34 (diff)
downloadnetpbm-mirror-3bbf7f47724bc05c32cd9d4b53425765dfe711ed.tar.gz
netpbm-mirror-3bbf7f47724bc05c32cd9d4b53425765dfe711ed.tar.xz
netpbm-mirror-3bbf7f47724bc05c32cd9d4b53425765dfe711ed.zip
Release 10.73.20
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3269 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/other/pngtopam.c5
-rw-r--r--converter/other/pngx.c28
-rw-r--r--converter/other/pngx.h6
3 files changed, 34 insertions, 5 deletions
diff --git a/converter/other/pngtopam.c b/converter/other/pngtopam.c
index 59b29f5f..8743174e 100644
--- a/converter/other/pngtopam.c
+++ b/converter/other/pngtopam.c
@@ -1238,9 +1238,8 @@ static void
 warnNonsquarePixels(struct pngx * const pngxP,
                     int *         const errorLevelP) {
 
-    if (pngx_chunkIsPresent(pngxP, PNG_INFO_pHYs)) {
-        float const r =
-            (float)pngx_xPixelsPerMeter(pngxP) / pngx_yPixelsPerMeter(pngxP);
+    if (pngx_pixelAspectRatioIsKnown(pngxP)) {
+        float const r = pngx_pixelAspectRatio(pngxP);
 
         if (r != 1.0) {
             const char * const baseMsg = "warning - non-square pixels";
diff --git a/converter/other/pngx.c b/converter/other/pngx.c
index a5171066..185b4a27 100644
--- a/converter/other/pngx.c
+++ b/converter/other/pngx.c
@@ -270,15 +270,39 @@ pngx_trns(struct pngx * const pngxP) {
 
 uint32_t
 pngx_xPixelsPerMeter(struct pngx * const pngxP) {
-
+/*----------------------------------------------------------------------------
+  Horizontal pixel density in pixel per meter; 0 if unknown.
+-----------------------------------------------------------------------------*/
     return png_get_x_pixels_per_meter(pngxP->png_ptr, pngxP->info_ptr);
 }
 
 
 
+float
+pngx_pixelAspectRatio(struct pngx * const pngxP) {
+/*----------------------------------------------------------------------------
+  Aspect ratio - y/x.  0.0 if unknown
+-----------------------------------------------------------------------------*/
+    return png_get_pixel_aspect_ratio(pngxP->png_ptr, pngxP->info_ptr);
+}
+
+
+
+bool
+pngx_pixelAspectRatioIsKnown(struct pngx * const pngxP) {
+/*----------------------------------------------------------------------------
+  There is pixel aspect ratio information in the PNG image.
+-----------------------------------------------------------------------------*/
+    return png_get_pixel_aspect_ratio(pngxP->png_ptr, pngxP->info_ptr) != 0.0;
+}
+
+
+
 uint32_t
 pngx_yPixelsPerMeter(struct pngx * const pngxP) {
-
+/*----------------------------------------------------------------------------
+  Vertical pixel density in pixel per meter; 0 if unknown.
+-----------------------------------------------------------------------------*/
     return png_get_y_pixels_per_meter(pngxP->png_ptr, pngxP->info_ptr);
 }
 
diff --git a/converter/other/pngx.h b/converter/other/pngx.h
index cabb0663..81e0dc55 100644
--- a/converter/other/pngx.h
+++ b/converter/other/pngx.h
@@ -112,6 +112,12 @@ pngx_xPixelsPerMeter(struct pngx * const pngxP);
 uint32_t
 pngx_yPixelsPerMeter(struct pngx * const pngxP);
 
+float
+pngx_pixelAspectRatio(struct pngx * const pngxP);
+
+bool
+pngx_pixelAspectRatioIsKnown(struct pngx * const pngxP);
+
 void
 pngx_removeChunk(struct pngx * const pngxP,
                  uint32_t      const chunkType);