pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/graphics/jpeg Adopt some new features from www.jpegclu...
details: https://anonhg.NetBSD.org/pkgsrc/rev/2a01746931ba
branches: trunk
changeset: 529478:2a01746931ba
user: tnn <tnn%pkgsrc.org@localhost>
date: Tue Jun 05 22:07:25 2007 +0000
description:
Adopt some new features from www.jpegclub.org that have already been
adopted by many Linux distributions as well as FreeBSD ports:
o jpegtran: add "-perfect" switch:
Fail if there are non-transformable edge blocks.
o jpegtran: add "-crop" switch:
Crop to a rectangular subarea.
o jpegtran: correct EXIF handling.
o jpegexiforient: Get and set the Exif Orientation Tag.
o exifautotran: Transforms Exif files so that Orientation becomes 1.
Suggested by dzoe on #NetBSD IRCNet.
diffstat:
graphics/jpeg/Makefile | 8 +-
graphics/jpeg/PLIST | 4 +-
graphics/jpeg/distinfo | 7 +-
graphics/jpeg/files/exifautotran | 38 +
graphics/jpeg/files/jpegexiforient.c | 292 ++++++
graphics/jpeg/patches/patch-ab | 1501 ++++++++++++++++++++++++++++++++++
graphics/jpeg/patches/patch-ac | 12 +
graphics/jpeg/patches/patch-ad | 193 ++++
graphics/jpeg/patches/patch-ae | 182 ++++
graphics/jpeg/patches/patch-af | 52 +
10 files changed, 2285 insertions(+), 4 deletions(-)
diffs (truncated from 2354 to 300 lines):
diff -r a8b95b71eff9 -r 2a01746931ba graphics/jpeg/Makefile
--- a/graphics/jpeg/Makefile Tue Jun 05 20:26:53 2007 +0000
+++ b/graphics/jpeg/Makefile Tue Jun 05 22:07:25 2007 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.35 2006/11/02 18:00:43 joerg Exp $
+# $NetBSD: Makefile,v 1.36 2007/06/05 22:07:25 tnn Exp $
#
DISTNAME= jpegsrc.v6b
PKGNAME= jpeg-6b
-PKGREVISION= 3
+PKGREVISION= 4
CATEGORIES= graphics
MASTER_SITES= ftp://ftp.fu-berlin.de/unix/graphics/jpeg/ \
ftp://ftp.uu.net/graphics/jpeg/
@@ -27,7 +27,11 @@
INSTALL_MAKE_FLAGS+= prefix=${DESTDIR}${PREFIX}
+post-extract:
+ ${CP} ${FILESDIR}/jpegexiforient.c ${WRKSRC}
+
post-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/exifautotran ${PREFIX}/bin
${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/doc/jpeg
${INSTALL_DATA} ${WRKSRC}/*.doc ${DESTDIR}${PREFIX}/share/doc/jpeg
${INSTALL_DATA} ${WRKSRC}/jpegint.h ${DESTDIR}${PREFIX}/include
diff -r a8b95b71eff9 -r 2a01746931ba graphics/jpeg/PLIST
--- a/graphics/jpeg/PLIST Tue Jun 05 20:26:53 2007 +0000
+++ b/graphics/jpeg/PLIST Tue Jun 05 22:07:25 2007 +0000
@@ -1,6 +1,8 @@
-@comment $NetBSD: PLIST,v 1.5 2004/10/30 01:02:43 wiz Exp $
+@comment $NetBSD: PLIST,v 1.6 2007/06/05 22:07:25 tnn Exp $
bin/cjpeg
bin/djpeg
+bin/exifautotran
+bin/jpegexiforient
bin/jpegtran
bin/rdjpgcom
bin/wrjpgcom
diff -r a8b95b71eff9 -r 2a01746931ba graphics/jpeg/distinfo
--- a/graphics/jpeg/distinfo Tue Jun 05 20:26:53 2007 +0000
+++ b/graphics/jpeg/distinfo Tue Jun 05 22:07:25 2007 +0000
@@ -1,6 +1,11 @@
-$NetBSD: distinfo,v 1.5 2006/11/02 18:00:43 joerg Exp $
+$NetBSD: distinfo,v 1.6 2007/06/05 22:07:25 tnn Exp $
SHA1 (jpegsrc.v6b.tar.gz) = 7079f0d6c42fad0cfba382cf6ad322add1ace8f9
RMD160 (jpegsrc.v6b.tar.gz) = 18892206014fbb8cae2a44e281f4ed53feaf7882
Size (jpegsrc.v6b.tar.gz) = 613261 bytes
SHA1 (patch-aa) = ffb4a89925187ebc74487ad8980266d1230a5efb
+SHA1 (patch-ab) = e57da4f693e638cf58b414bfbc50e21d80270109
+SHA1 (patch-ac) = 6c34738effc7df671d4522b4ecca06dab640ed16
+SHA1 (patch-ad) = 73afda7c2c849c93d1c1dd2c632e1e67a1db97dc
+SHA1 (patch-ae) = 4d2b3316df3a6b3ae9c0ef5099620f5f24300cca
+SHA1 (patch-af) = d414c8133878b9fe5f24a6ce008c36112f417e6d
diff -r a8b95b71eff9 -r 2a01746931ba graphics/jpeg/files/exifautotran
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/jpeg/files/exifautotran Tue Jun 05 22:07:25 2007 +0000
@@ -0,0 +1,38 @@
+#! /bin/sh
+#
+# Based on http://www.jpegclub.org/exifautotran.txt
+#
+if [ "$#" = "0" ]
+then
+cat << EOF 1>&2
+usage: exifautotran [list of files]
+Transforms Exif files so that Orientation becomes 1
+EOF
+exit 1
+fi
+
+for i
+do
+ case `jpegexiforient -n "$i"` in
+ 1) transform="";;
+ 2) transform="-flip horizontal";;
+ 3) transform="-rotate 180";;
+ 4) transform="-flip vertical";;
+ 5) transform="-transpose";;
+ 6) transform="-rotate 90";;
+ 7) transform="-transverse";;
+ 8) transform="-rotate 270";;
+ *) transform="";;
+ esac
+ if test -n "$transform"; then
+ echo Executing: jpegtran -copy all $transform $i
+ jpegtran -copy all $transform "$i" > tempfile
+ if test $? -ne 0; then
+ echo Error while transforming $i - skipped.
+ else
+ rm "$i"
+ mv tempfile "$i"
+ jpegexiforient -1 "$i" > /dev/null
+ fi
+ fi
+done
diff -r a8b95b71eff9 -r 2a01746931ba graphics/jpeg/files/jpegexiforient.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/jpeg/files/jpegexiforient.c Tue Jun 05 22:07:25 2007 +0000
@@ -0,0 +1,292 @@
+/*
+ * jpegexiforient.c
+ *
+ * This is a utility program to get and set the Exif Orientation Tag.
+ * It can be used together with jpegtran in scripts for automatic
+ * orientation correction of digital camera pictures.
+ *
+ * The Exif orientation value gives the orientation of the camera
+ * relative to the scene when the image was captured. The relation
+ * of the '0th row' and '0th column' to visual position is shown as
+ * below.
+ *
+ * Value | 0th Row | 0th Column
+ * ------+-------------+-----------
+ * 1 | top | left side
+ * 2 | top | rigth side
+ * 3 | bottom | rigth side
+ * 4 | bottom | left side
+ * 5 | left side | top
+ * 6 | right side | top
+ * 7 | right side | bottom
+ * 8 | left side | bottom
+ *
+ * For convenience, here is what the letter F would look like if it were
+ * tagged correctly and displayed by a program that ignores the orientation
+ * tag:
+ *
+ * 1 2 3 4 5 6 7 8
+ *
+ * 888888 888888 88 88 8888888888 88 88 8888888888
+ * 88 88 88 88 88 88 88 88 88 88 88 88
+ * 8888 8888 8888 8888 88 8888888888 8888888888 88
+ * 88 88 88 88
+ * 88 88 888888 888888
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static FILE * myfile; /* My JPEG file */
+
+static unsigned char exif_data[65536L];
+
+/* Return next input byte, or EOF if no more */
+#define NEXTBYTE() getc(myfile)
+
+/* Error exit handler */
+#define ERREXIT(msg) (exit(0))
+
+/* Read one byte, testing for EOF */
+static int
+read_1_byte (void)
+{
+ int c;
+
+ c = NEXTBYTE();
+ if (c == EOF)
+ ERREXIT("Premature EOF in JPEG file");
+ return c;
+}
+
+/* Read 2 bytes, convert to unsigned int */
+/* All 2-byte quantities in JPEG markers are MSB first */
+static unsigned int
+read_2_bytes (void)
+{
+ int c1, c2;
+
+ c1 = NEXTBYTE();
+ if (c1 == EOF)
+ ERREXIT("Premature EOF in JPEG file");
+ c2 = NEXTBYTE();
+ if (c2 == EOF)
+ ERREXIT("Premature EOF in JPEG file");
+ return (((unsigned int) c1) << 8) + ((unsigned int) c2);
+}
+
+static const char * progname; /* program name for error messages */
+
+static void
+usage (void)
+/* complain about bad command line */
+{
+ fprintf(stderr, "jpegexiforient reads or writes the Exif Orientation Tag ");
+ fprintf(stderr, "in a JPEG Exif file.\n");
+
+ fprintf(stderr, "Usage: %s [switches] jpegfile\n", progname);
+
+ fprintf(stderr, "Switches:\n");
+ fprintf(stderr, " -n Do not output the trailing newline\n");
+ fprintf(stderr, " -1 .. -8 Set orientation value 1 .. 8\n");
+}
+
+/*
+ * The main program.
+ */
+
+int
+main (int argc, char **argv)
+{
+ int n_flag, set_flag;
+ unsigned int length, i;
+ int is_motorola; /* Flag for byte order */
+ unsigned int offset, number_of_tags, tagnum;
+
+ progname = argv[0];
+ if (progname == NULL || progname[0] == 0)
+ progname = "jpegexiforient"; /* in case C library doesn't provide it */
+
+ if (argc < 2) { usage(); return 0; }
+
+ n_flag = 0; set_flag = 0;
+
+ i = 1;
+ while (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'n':
+ n_flag = 1;
+ break;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ set_flag = argv[i][1] - '0';
+ break;
+ default:
+ usage(); return 0;
+ }
+ if (++i >= argc) { usage(); return 0; }
+ }
+
+ if (set_flag) {
+ if ((myfile = fopen(argv[i], "rb+")) == NULL) {
+ fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
+ return 0;
+ }
+ } else {
+ if ((myfile = fopen(argv[i], "rb")) == NULL) {
+ fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
+ return 0;
+ }
+ }
+
+ /* Read File head, check for JPEG SOI + Exif APP1 */
+ for (i = 0; i < 4; i++)
+ exif_data[i] = (unsigned char) read_1_byte();
+ if (exif_data[0] != 0xFF ||
+ exif_data[1] != 0xD8 ||
+ exif_data[2] != 0xFF ||
+ exif_data[3] != 0xE1)
+ return 0;
+
+ /* Get the marker parameter length count */
+ length = read_2_bytes();
+ /* Length includes itself, so must be at least 2 */
+ /* Following Exif data length must be at least 6 */
+ if (length < 8)
+ return 0;
+ length -= 8;
+ /* Read Exif head, check for "Exif" */
+ for (i = 0; i < 6; i++)
+ exif_data[i] = (unsigned char) read_1_byte();
+ if (exif_data[0] != 0x45 ||
+ exif_data[1] != 0x78 ||
+ exif_data[2] != 0x69 ||
+ exif_data[3] != 0x66 ||
+ exif_data[4] != 0 ||
+ exif_data[5] != 0)
+ return 0;
+ /* Read Exif body */
+ for (i = 0; i < length; i++)
+ exif_data[i] = (unsigned char) read_1_byte();
+
+ if (length < 12) return 0; /* Length of an IFD entry */
+
+ /* Discover byte order */
+ if (exif_data[0] == 0x49 && exif_data[1] == 0x49)
+ is_motorola = 0;
+ else if (exif_data[0] == 0x4D && exif_data[1] == 0x4D)
+ is_motorola = 1;
+ else
+ return 0;
+
+ /* Check Tag Mark */
+ if (is_motorola) {
+ if (exif_data[2] != 0) return 0;
+ if (exif_data[3] != 0x2A) return 0;
+ } else {
+ if (exif_data[3] != 0) return 0;
+ if (exif_data[2] != 0x2A) return 0;
+ }
+
+ /* Get first IFD offset (offset to IFD0) */
Home |
Main Index |
Thread Index |
Old Index