Discussion:
[PATCH] Include physical resolution (pHYs section) in PNG output.
(too old to reply)
Aaron Muir Hamilton
2017-04-16 09:06:48 UTC
Permalink
Raw Message
---
frontend/scanimage.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/frontend/scanimage.c b/frontend/scanimage.c
index 77c2288..432c2ea 100644
--- a/frontend/scanimage.c
+++ b/frontend/scanimage.c
@@ -1165,9 +1165,12 @@ write_pnm_header (SANE_Frame format, int width, int height, int depth, FILE *ofp

#ifdef HAVE_LIBPNG
static void
-write_png_header (SANE_Frame format, int width, int height, int depth, FILE *ofp, png_structp* png_ptr, png_infop* info_ptr)
+write_png_header (SANE_Frame format, int width, int height, int depth, int dpi, FILE *ofp, png_structp* png_ptr, png_infop* info_ptr)
{
int color_type;
+ /* PNG does not have imperial reference units, so we must convert to metric. */
+ /* There are nominally 39.3700787401575 inches in a meter. */
+ const double pixels_per_meter = dpi * 39.3700787401575;

*png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -1200,6 +1203,10 @@ write_png_header (SANE_Frame format, int width, int height, int depth, FILE *ofp
depth, color_type, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);

+ png_set_pHYs(*png_ptr, *info_ptr,
+ pixels_per_meter, pixels_per_meter,
+ PNG_RESOLUTION_METER);
+
png_write_info(*png_ptr, *info_ptr);
}
#endif
@@ -1379,7 +1386,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBPNG
case OUTPUT_PNG:
write_png_header (parm.format, parm.pixels_per_line,
- parm.lines, parm.depth, ofp, &png_ptr, &info_ptr);
+ parm.lines, parm.depth, resolution_value,
+ ofp, &png_ptr, &info_ptr);
break;
#endif
#ifdef HAVE_LIBJPEG
@@ -1635,7 +1643,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBPNG
case OUTPUT_PNG:
write_png_header (parm.format, parm.pixels_per_line,
- image.height, parm.depth, ofp, &png_ptr, &info_ptr);
+ image.height, parm.depth, resolution_value,
+ ofp, &png_ptr, &info_ptr);
break;
#endif
#ifdef HAVE_LIBJPEG
--
1.8.3.1
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Olaf Meeuwissen
2017-04-27 12:49:00 UTC
Permalink
Raw Message
Hi Aaron,

Thanks for the patch. It's on its way to the Alioth repository.
Bonus points for a similar patch for JPEG "densities". TIFF is already
been taken care of.

Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Aaron Muir Hamilton
2017-04-28 11:26:44 UTC
Permalink
Raw Message
Pleased to make your acquaintance, Olaf.

Thank you for reviewing the patches and taking them upstream,
I have an equivalent patch for JPEG output on the boil.

Not to put you on the spot, but it seems like a lot of time has passed
since the last release was tagged, despite there apparently being quite
a bit of development since then.

I'm wondering who is empowered to tag a release; I think it would be a
good time to make one. 2015-10-04 was quite a while ago, and I know that
at least Archlinux has a downstream patch (authored in 2013, but not
included in 1.0.25) which seems to be integrated in master. [1]

[1]: https://git.archlinux.org/svntogit/packages.git/plain/trunk/segfault-avahi-fix-kodakio.patch?h=packages/sane

おつかれさま。
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to san
Olaf Meeuwissen
2017-04-30 13:08:33 UTC
Permalink
Raw Message
Hi Aaron,
Post by Aaron Muir Hamilton
Pleased to make your acquaintance, Olaf.
Same here.
Post by Aaron Muir Hamilton
Thank you for reviewing the patches and taking them upstream,
I have an equivalent patch for JPEG output on the boil.
Good. You have until 2017-05-07 to get it in the next release.
Post by Aaron Muir Hamilton
Not to put you on the spot, but it seems like a lot of time has passed
since the last release was tagged, despite there apparently being quite
a bit of development since then.
I'm wondering who is empowered to tag a release;
As you may have noticed, Allan here posted a time schedule.
Post by Aaron Muir Hamilton
I think it would be a good time to make one. 2015-10-04 was quite a
while ago, and I know that at least Archlinux has a downstream patch
(authored in 2013, but not included in 1.0.25) which seems to be
integrated in master. [1]
[1]: https://git.archlinux.org/svntogit/packages.git/plain/trunk/segfault-avahi-fix-kodakio.patch?h=packages/sane
おつかれさま。
JPEGの解像度パッチをよろしく!

Now let's keep the conversation in the lingua franca of the software
developer world so that everyone can participate again ;-)

Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Loading...