From cfcd819246f8eb1b1f1e7d43b7ba91c94329f14b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 4 Nov 2014 09:38:21 +0000 Subject: [PATCH] better default resolution for png load see https://github.com/lovell/sharp/issues/96 --- ChangeLog | 3 +++ libvips/foreign/vipspng.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a09cafd4..90c64d68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +4/11/14 started 7.42.0 +- better default resolution for png load + 25/7/14 started 7.41.0 - start working on --disable-deprecated - fix pngload with libpng >1.6.1 diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index e5cad2a7..d4149fdd 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -339,15 +339,15 @@ png2vips_header( Read *read, VipsImage *out ) /* If we're an INTEL byte order machine and this is 16bits, we need * to swap bytes. */ - if( bit_depth > 8 && !vips_amiMSBfirst() ) + if( bit_depth > 8 && + !vips_amiMSBfirst() ) png_set_swap( read->pPng ); - /* Get resolution. I'm not sure what we should do for UNKNOWN, since - * vips is always pixels/mm. + /* Get resolution. Default to 72 pixels per inch, the usual png value. */ unit_type = PNG_RESOLUTION_METER; - res_x = 1000; - res_y = 1000; + res_x = (72 / 2.54 * 100); + res_y = (72 / 2.54 * 100); png_get_pHYs( read->pPng, read->pInfo, &res_x, &res_y, &unit_type ); switch( unit_type ) { case PNG_RESOLUTION_METER: