texlive[43039] Build/source/texk/dvipdfm-x: dvipdfm-x/jpegimage.c:
commits+kakuto at tug.org
commits+kakuto at tug.org
Tue Jan 24 05:34:51 CET 2017
Revision: 43039
http://tug.org/svn/texlive?view=revision&revision=43039
Author: kakuto
Date: 2017-01-24 05:34:51 +0100 (Tue, 24 Jan 2017)
Log Message:
-----------
dvipdfm-x/jpegimage.c: Support Exif tags 0x5110, 0x5111 and 0x5112 in order to avoid warnings for some kind of jpeg images. Changes are borrowed from writejpg.w by Luigi.
Modified Paths:
--------------
trunk/Build/source/texk/dvipdfm-x/ChangeLog
trunk/Build/source/texk/dvipdfm-x/jpegimage.c
Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog 2017-01-24 01:05:33 UTC (rev 43038)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog 2017-01-24 04:34:51 UTC (rev 43039)
@@ -1,3 +1,9 @@
+2017-01-24 Akira Kakuto <kakuto at fuk.kindai.ac.jp>
+
+ * jpegimage.c: Support Exif tags 0x5110, 0x5111, and 0x5112 in order to
+ avoid warnings for some kind of jpeg images. Changes are borrowed from
+ writejpg.w by Luigi in the recent LuaTeX.
+
2016-12-29 Hironobu Yamashita <h.y.acetaminophen at gmail.com>
* cid_basefont.h: Add data for STHeiti-Regular-Acro, and correct
Modified: trunk/Build/source/texk/dvipdfm-x/jpegimage.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/jpegimage.c 2017-01-24 01:05:33 UTC (rev 43038)
+++ trunk/Build/source/texk/dvipdfm-x/jpegimage.c 2017-01-24 04:34:51 UTC (rev 43039)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -608,6 +608,9 @@
#define JPEG_EXIF_TAG_XRESOLUTION 282
#define JPEG_EXIF_TAG_YRESOLUTION 283
#define JPEG_EXIF_TAG_RESOLUTIONUNIT 296
+#define JPEG_EXIF_TAG_RESUNIT_MS 0x5110
+#define JPEG_EXIF_TAG_XRES_MS 0x5111
+#define JPEG_EXIF_TAG_YRES_MS 0x5112
static size_t
read_APP1_Exif (struct JPEG_info *j_info, FILE *fp, size_t length)
{
@@ -619,8 +622,12 @@
int endian;
int num_fields;
int value = 0, offset;
- double xres = 72.0, yres = 72.0;
- double res_unit = 1.0;
+ double xres = 0.0, yres = 0.0;
+ double res_unit = 0.0;
+ unsigned int xres_ms = 0;
+ unsigned int yres_ms = 0;
+ double res_unit_ms = 0.0;
+ double exifxdpi = 0.0, exifydpi = 0.0;
fread(buffer, length, 1, fp);
if (length < 10)
@@ -715,6 +722,34 @@
else if (value == 3)
res_unit = 2.54; /* cm */
break;
+ case JPEG_EXIF_TAG_RESUNIT_MS: /* PixelUnit */
+ if (type != JPEG_EXIF_TYPE_BYTE || count != 1) {
+ WARN("%s: Invalid data for ResolutionUnit in Exif chunk.", JPEG_DEBUG_STR);
+ goto err;
+ }
+ value = read_exif_bytes(&p, 1, endian);
+ p += 3;
+ if (value == 1)
+ res_unit_ms = 0.0254; /* Unit is meter */
+ else
+ res_unit_ms = 0.0;
+ break;
+ case JPEG_EXIF_TAG_XRES_MS: /* PixelPerUnitX */
+ if (type != JPEG_EXIF_TYPE_LONG || count != 1) {
+ WARN("%s: Invalid data for PixelPerUnitX in Exif chunk.", JPEG_DEBUG_STR);
+ goto err;
+ }
+ value = read_exif_bytes(&p, 4, endian);
+ xres_ms = value;
+ break;
+ case JPEG_EXIF_TAG_YRES_MS: /* PixelPerUnitY */
+ if (type != JPEG_EXIF_TYPE_LONG || count != 1) {
+ WARN("%s: Invalid data for PixelPerUnitY in Exif chunk.", JPEG_DEBUG_STR);
+ goto err;
+ }
+ value = read_exif_bytes(&p, 4, endian);
+ yres_ms = value;
+ break;
default:
/* 40901 ColorSpace and 42240 Gamma unsupported... */
p += 4;
@@ -726,18 +761,35 @@
goto err;
}
+/* Calculate Exif resolution, if given.
+ */
+ if (xres > 0.0 && yres > 0.0) {
+ exifxdpi = xres * res_unit;
+ exifydpi = yres * res_unit;
+ } else if (xres_ms > 0 && yres_ms > 0 && res_unit_ms > 0.0) {
+ exifxdpi = xres_ms * res_unit_ms;
+ exifydpi = yres_ms * res_unit_ms;
+ } else {
+ exifxdpi = 72.0 * res_unit;
+ exifydpi = 72.0 * res_unit;
+ }
+
/* Do not overwrite j_info->xdpi and j_info->ydpi if they are
* already determined in JFIF.
*/
if (j_info->xdpi < 0.1 && j_info->ydpi < 0.1) {
- j_info->xdpi = xres * res_unit;
- j_info->ydpi = yres * res_unit;
+ j_info->xdpi = exifxdpi;
+ j_info->ydpi = exifydpi;
} else {
- if (j_info->xdpi != xres * res_unit ||
- j_info->ydpi != yres * res_unit) {
+ double xxx1 = floor(exifxdpi+0.5);
+ double xxx2 = floor(j_info->xdpi+0.5);
+ double yyy1 = floor(exifydpi+0.5);
+ double yyy2 = floor(j_info->ydpi+0.5);
+
+ if (xxx1 != xxx2 || yyy1 != yyy2) {
WARN("%s: Inconsistent resolution may have " \
"specified in Exif and JFIF: %gx%g - %gx%g", JPEG_DEBUG_STR,
- xres * res_unit, yres * res_unit, j_info->xdpi, j_info->ydpi);
+ xxx1, yyy1, xxx2, yyy2);
}
}
More information about the tex-live-commits
mailing list