Discussion:
[PATCH] Write density (resolution) JFIF header information with JPEG files.
(too old to reply)
Aaron Muir Hamilton
2017-05-01 20:15:23 UTC
Permalink
Raw Message
---
frontend/scanimage.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/frontend/scanimage.c b/frontend/scanimage.c
index ffb9f105..e5562815 100644
--- a/frontend/scanimage.c
+++ b/frontend/scanimage.c
@@ -1213,7 +1213,7 @@ write_png_header (SANE_Frame format, int width, int height, int depth, int dpi,

#ifdef HAVE_LIBJPEG
static void
-write_jpeg_header (SANE_Frame format, int width, int height, FILE *ofp, struct jpeg_compress_struct *cinfo, struct jpeg_error_mgr *jerr)
+write_jpeg_header (SANE_Frame format, int width, int height, int dpi, FILE *ofp, struct jpeg_compress_struct *cinfo, struct jpeg_error_mgr *jerr)
{
cinfo->err = jpeg_std_error(jerr);
jpeg_create_compress(cinfo);
@@ -1238,6 +1238,11 @@ write_jpeg_header (SANE_Frame format, int width, int height, FILE *ofp, struct j
}

jpeg_set_defaults(cinfo);
+ /* jpeg_set_defaults overrides density, be careful. */
+ cinfo->density_unit = 1; /* Inches */
+ cinfo->X_density = cinfo->Y_density = dpi;
+ cinfo->write_JFIF_header = TRUE;
+
jpeg_set_quality(cinfo, 75, TRUE);
jpeg_start_compress(cinfo, TRUE);
}
@@ -1393,7 +1398,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBJPEG
case OUTPUT_JPEG:
write_jpeg_header (parm.format, parm.pixels_per_line,
- parm.lines, ofp, &cinfo, &jerr);
+ parm.lines, resolution_value,
+ ofp, &cinfo, &jerr);
break;
#endif
}
@@ -1665,7 +1671,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBJPEG
case OUTPUT_JPEG:
write_jpeg_header (parm.format, parm.pixels_per_line,
- parm.lines, ofp, &cinfo, &jerr);
+ parm.lines, resolution_value,
+ ofp, &cinfo, &jerr);
break;
#endif
}
--
2.12.2
--
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-05-04 09:43:25 UTC
Permalink
Raw Message
Hi Aaron,

Thanks, I pushed your patch in 801558f.
--
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...