Magellan Linux

Annotation of /trunk/libjpeg/patches/libjpeg-6b-debian-extras.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (hide annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years, 1 month ago) by niro
File size: 14166 byte(s)
-import

1 niro 144 diff -Naur jpeg-6b.orig/extra/exifautotran jpeg-6b/extra/exifautotran
2     --- jpeg-6b.orig/extra/exifautotran 1970-01-01 01:00:00.000000000 +0100
3     +++ jpeg-6b/extra/exifautotran 2006-06-11 15:10:54.000000000 +0200
4     @@ -0,0 +1,50 @@
5     +#!/bin/sh
6     +# exifautotran [list of files]
7     +#
8     +# Transforms Exif files so that Orientation becomes 1
9     +#
10     +
11     +trap "if test -n \"\$tempfile\"; then rm -f \"\$tempfile\"; fi" INT QUIT TERM
12     +
13     +for i
14     +do
15     + case $i in
16     + -v|--version) echo "exifautotran"; exit 0;;
17     + -h|--help)
18     + cat <<EOF
19     +exifautotran [list of files]
20     +
21     +Transforms Exif files so that Orientation becomes 1
22     +EOF
23     + exit 0;;
24     + esac
25     +
26     + case `jpegexiforient -n "$i"` in
27     + 1) transform="";;
28     + 2) transform="-flip horizontal";;
29     + 3) transform="-rotate 180";;
30     + 4) transform="-flip vertical";;
31     + 5) transform="-transpose";;
32     + 6) transform="-rotate 90";;
33     + 7) transform="-transverse";;
34     + 8) transform="-rotate 270";;
35     + *) transform="";;
36     + esac
37     + if test -n "$transform"; then
38     + tempfile=`mktemp`;
39     + if test "$?" -ne "0"; then
40     + echo "Failed to create temporary file" >&2
41     + exit 1;
42     + fi
43     + echo Executing: jpegtran -copy all $transform $i >&2
44     + jpegtran -copy all $transform "$i" > $tempfile
45     + if test $? -ne 0; then
46     + echo Error while transforming $i - skipped. >&2
47     + rm "$tempfile"
48     + else
49     + rm "$i"
50     + mv "$tempfile" "$i"
51     + jpegexiforient -1 "$i" > /dev/null
52     + fi
53     + fi
54     +done
55     diff -Naur jpeg-6b.orig/extra/exifautotran.1 jpeg-6b/extra/exifautotran.1
56     --- jpeg-6b.orig/extra/exifautotran.1 1970-01-01 01:00:00.000000000 +0100
57     +++ jpeg-6b/extra/exifautotran.1 2006-06-11 15:10:54.000000000 +0200
58     @@ -0,0 +1,13 @@
59     +.TH EXIFAUTOTRAN "1" "February 2005" "exifautotran" "User Commands"
60     +.SH NAME
61     +exifautotran \- Transforms Exif files so that Orientation becomes 1
62     +.SH DESCRIPTION
63     +exifautotran [list of files]
64     +.PP
65     +Take a list of files as input and transform then in place so that the
66     +Orientation becomes 1.
67     +.SH "AUTHOR"
68     + Guido Vollbeding <guido@jpegclub.org>
69     +.SH "SEE ALSO"
70     +.BR jpegtran(1)
71     +.BR jpegexiforient(1)
72     diff -Naur jpeg-6b.orig/extra/jpegexiforient.1 jpeg-6b/extra/jpegexiforient.1
73     --- jpeg-6b.orig/extra/jpegexiforient.1 1970-01-01 01:00:00.000000000 +0100
74     +++ jpeg-6b/extra/jpegexiforient.1 2006-06-11 15:10:54.000000000 +0200
75     @@ -0,0 +1,69 @@
76     +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35.
77     +.TH JPEGEXIFORIENT "1" "February 2005" "jpegexiforient" "User Commands"
78     +.SH NAME
79     +jpegexiforient \- reads or writes the Exif Orientation Tag
80     +.SH SYNOPSIS
81     +.B jpegexiforient
82     +[\fIswitches\fR] \fIjpegfile\fR
83     +.SH DESCRIPTION
84     +
85     + This is a utility program to get and set the Exif Orientation Tag.
86     + It can be used together with jpegtran in scripts for automatic
87     + orientation correction of digital camera pictures.
88     +
89     + The Exif orientation value gives the orientation of the camera
90     + relative to the scene when the image was captured. The relation
91     + of the '0th row' and '0th column' to visual position is shown as
92     + below.
93     +
94     + Value | 0th Row | 0th Column
95     + ------+-------------+-----------
96     + 1 | top | left side
97     + 2 | top | rigth side
98     + 3 | bottom | rigth side
99     + 4 | bottom | left side
100     + 5 | left side | top
101     + 6 | right side | top
102     + 7 | right side | bottom
103     + 8 | left side | bottom
104     +
105     + For convenience, here is what the letter F would look like if it were
106     + tagged correctly and displayed by a program that ignores the orientation
107     + tag:
108     +
109     + 1 2 3 4
110     +
111     + 888888 888888 88 88
112     + 88 88 88 88
113     + 8888 8888 8888 8888
114     + 88 88 88 88
115     + 88 88 888888 888888
116     +
117     + 5 6 7 8
118     +
119     + 8888888888 88 88 8888888888
120     + 88 88 88 88 88 88 88 88
121     + 88 8888888888 8888888888 88
122     +
123     +jpegexiforient output the Exif Orientation Tag in a JPEG Exif file.
124     +With the options -1 .. -8, it can also be used to set the tag.
125     +
126     +.SS "OPTIONS"
127     +.TP
128     +\fB\-\-help\fR
129     +display this help and exit
130     +.TP
131     +\fB\-\-version\fR
132     +output version information and exit
133     +.TP
134     +\fB\-n\fR
135     +Do not output the trailing newline
136     +.TP
137     +\fB\-1\fR .. \fB\-8\fR
138     +Set orientation value 1 .. 8
139     +.SH "AUTHOR"
140     + Guido Vollbeding <guido@jpegclub.org>
141     +.SH "SEE ALSO"
142     +.BR jpegtran(1)
143     +.BR exifautotran(1)
144     +
145     diff -Naur jpeg-6b.orig/extra/jpegexiforient.c jpeg-6b/extra/jpegexiforient.c
146     --- jpeg-6b.orig/extra/jpegexiforient.c 1970-01-01 01:00:00.000000000 +0100
147     +++ jpeg-6b/extra/jpegexiforient.c 2006-06-11 15:10:54.000000000 +0200
148     @@ -0,0 +1,299 @@
149     +/*
150     + * jpegexiforient.c
151     + *
152     + * This is a utility program to get and set the Exif Orientation Tag.
153     + * It can be used together with jpegtran in scripts for automatic
154     + * orientation correction of digital camera pictures.
155     + *
156     + * The Exif orientation value gives the orientation of the camera
157     + * relative to the scene when the image was captured. The relation
158     + * of the '0th row' and '0th column' to visual position is shown as
159     + * below.
160     + *
161     + * Value | 0th Row | 0th Column
162     + * ------+-------------+-----------
163     + * 1 | top | left side
164     + * 2 | top | rigth side
165     + * 3 | bottom | rigth side
166     + * 4 | bottom | left side
167     + * 5 | left side | top
168     + * 6 | right side | top
169     + * 7 | right side | bottom
170     + * 8 | left side | bottom
171     + *
172     + * For convenience, here is what the letter F would look like if it were
173     + * tagged correctly and displayed by a program that ignores the orientation
174     + * tag:
175     + *
176     + * 1 2 3 4 5 6 7 8
177     + *
178     + * 888888 888888 88 88 8888888888 88 88 8888888888
179     + * 88 88 88 88 88 88 88 88 88 88 88 88
180     + * 8888 8888 8888 8888 88 8888888888 8888888888 88
181     + * 88 88 88 88
182     + * 88 88 888888 888888
183     + *
184     + */
185     +
186     +#include <stdio.h>
187     +#include <stdlib.h>
188     +
189     +static FILE * myfile; /* My JPEG file */
190     +
191     +static unsigned char exif_data[65536L];
192     +
193     +/* Return next input byte, or EOF if no more */
194     +#define NEXTBYTE() getc(myfile)
195     +
196     +/* Error exit handler */
197     +#define ERREXIT(msg) (exit(0))
198     +
199     +/* Read one byte, testing for EOF */
200     +static int
201     +read_1_byte (void)
202     +{
203     + int c;
204     +
205     + c = NEXTBYTE();
206     + if (c == EOF)
207     + ERREXIT("Premature EOF in JPEG file");
208     + return c;
209     +}
210     +
211     +/* Read 2 bytes, convert to unsigned int */
212     +/* All 2-byte quantities in JPEG markers are MSB first */
213     +static unsigned int
214     +read_2_bytes (void)
215     +{
216     + int c1, c2;
217     +
218     + c1 = NEXTBYTE();
219     + if (c1 == EOF)
220     + ERREXIT("Premature EOF in JPEG file");
221     + c2 = NEXTBYTE();
222     + if (c2 == EOF)
223     + ERREXIT("Premature EOF in JPEG file");
224     + return (((unsigned int) c1) << 8) + ((unsigned int) c2);
225     +}
226     +
227     +static const char * progname; /* program name for error messages */
228     +
229     +static void
230     +usage (FILE *out)
231     +/* complain about bad command line */
232     +{
233     + fprintf(out, "jpegexiforient reads or writes the Exif Orientation Tag ");
234     + fprintf(out, "in a JPEG Exif file.\n");
235     +
236     + fprintf(out, "Usage: %s [switches] jpegfile\n", progname);
237     +
238     + fprintf(out, "Switches:\n");
239     + fprintf(out, " --help display this help and exit\n");
240     + fprintf(out, " --version output version information and exit\n");
241     + fprintf(out, " -n Do not output the trailing newline\n");
242     + fprintf(out, " -1 .. -8 Set orientation value 1 .. 8\n");
243     +}
244     +
245     +/*
246     + * The main program.
247     + */
248     +
249     +int
250     +main (int argc, char **argv)
251     +{
252     + int n_flag, set_flag;
253     + unsigned int length, i;
254     + int is_motorola; /* Flag for byte order */
255     + unsigned int offset, number_of_tags, tagnum;
256     +
257     + progname = argv[0];
258     + if (progname == NULL || progname[0] == 0)
259     + progname = "jpegexiforient"; /* in case C library doesn't provide it */
260     +
261     + if (argc < 2) { usage(stderr); return 1; }
262     +
263     + n_flag = 0; set_flag = 0;
264     +
265     + i = 1;
266     + while (argv[i][0] == '-') {
267     + switch (argv[i][1]) {
268     + case '-':
269     + switch (argv[i][2]) {
270     + case 'h': usage(stdout); return 0;
271     + case 'v': fprintf(stdout,"jpegexiforient\n"); return 0;
272     + }
273     + case 'n':
274     + n_flag = 1;
275     + break;
276     + case '1':
277     + case '2':
278     + case '3':
279     + case '4':
280     + case '5':
281     + case '6':
282     + case '7':
283     + case '8':
284     + set_flag = argv[i][1] - '0';
285     + break;
286     + default:
287     + usage(stderr); return 1;
288     + }
289     + if (++i >= argc) { usage(stderr); return 1; }
290     + }
291     +
292     + if (set_flag) {
293     + if ((myfile = fopen(argv[i], "rb+")) == NULL) {
294     + fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
295     + return 0;
296     + }
297     + } else {
298     + if ((myfile = fopen(argv[i], "rb")) == NULL) {
299     + fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
300     + return 0;
301     + }
302     + }
303     +
304     + /* Read File head, check for JPEG SOI + Exif APP1 */
305     + for (i = 0; i < 4; i++)
306     + exif_data[i] = (unsigned char) read_1_byte();
307     + if (exif_data[0] != 0xFF ||
308     + exif_data[1] != 0xD8 ||
309     + exif_data[2] != 0xFF ||
310     + exif_data[3] != 0xE1)
311     + return 0;
312     +
313     + /* Get the marker parameter length count */
314     + length = read_2_bytes();
315     + /* Length includes itself, so must be at least 2 */
316     + /* Following Exif data length must be at least 6 */
317     + if (length < 8)
318     + return 0;
319     + length -= 8;
320     + /* Read Exif head, check for "Exif" */
321     + for (i = 0; i < 6; i++)
322     + exif_data[i] = (unsigned char) read_1_byte();
323     + if (exif_data[0] != 0x45 ||
324     + exif_data[1] != 0x78 ||
325     + exif_data[2] != 0x69 ||
326     + exif_data[3] != 0x66 ||
327     + exif_data[4] != 0 ||
328     + exif_data[5] != 0)
329     + return 0;
330     + /* Read Exif body */
331     + for (i = 0; i < length; i++)
332     + exif_data[i] = (unsigned char) read_1_byte();
333     +
334     + if (length < 12) return 0; /* Length of an IFD entry */
335     +
336     + /* Discover byte order */
337     + if (exif_data[0] == 0x49 && exif_data[1] == 0x49)
338     + is_motorola = 0;
339     + else if (exif_data[0] == 0x4D && exif_data[1] == 0x4D)
340     + is_motorola = 1;
341     + else
342     + return 0;
343     +
344     + /* Check Tag Mark */
345     + if (is_motorola) {
346     + if (exif_data[2] != 0) return 0;
347     + if (exif_data[3] != 0x2A) return 0;
348     + } else {
349     + if (exif_data[3] != 0) return 0;
350     + if (exif_data[2] != 0x2A) return 0;
351     + }
352     +
353     + /* Get first IFD offset (offset to IFD0) */
354     + if (is_motorola) {
355     + if (exif_data[4] != 0) return 0;
356     + if (exif_data[5] != 0) return 0;
357     + offset = exif_data[6];
358     + offset <<= 8;
359     + offset += exif_data[7];
360     + } else {
361     + if (exif_data[7] != 0) return 0;
362     + if (exif_data[6] != 0) return 0;
363     + offset = exif_data[5];
364     + offset <<= 8;
365     + offset += exif_data[4];
366     + }
367     + if (offset > length - 2) return 0; /* check end of data segment */
368     +
369     + /* Get the number of directory entries contained in this IFD */
370     + if (is_motorola) {
371     + number_of_tags = exif_data[offset];
372     + number_of_tags <<= 8;
373     + number_of_tags += exif_data[offset+1];
374     + } else {
375     + number_of_tags = exif_data[offset+1];
376     + number_of_tags <<= 8;
377     + number_of_tags += exif_data[offset];
378     + }
379     + if (number_of_tags == 0) return 0;
380     + offset += 2;
381     +
382     + /* Search for Orientation Tag in IFD0 */
383     + for (;;) {
384     + if (offset > length - 12) return 0; /* check end of data segment */
385     + /* Get Tag number */
386     + if (is_motorola) {
387     + tagnum = exif_data[offset];
388     + tagnum <<= 8;
389     + tagnum += exif_data[offset+1];
390     + } else {
391     + tagnum = exif_data[offset+1];
392     + tagnum <<= 8;
393     + tagnum += exif_data[offset];
394     + }
395     + if (tagnum == 0x0112) break; /* found Orientation Tag */
396     + if (--number_of_tags == 0) return 0;
397     + offset += 12;
398     + }
399     +
400     + if (set_flag) {
401     + /* Set the Orientation value */
402     + if (is_motorola) {
403     + exif_data[offset+2] = 0; /* Format = unsigned short (2 octets) */
404     + exif_data[offset+3] = 3;
405     + exif_data[offset+4] = 0; /* Number Of Components = 1 */
406     + exif_data[offset+5] = 0;
407     + exif_data[offset+6] = 0;
408     + exif_data[offset+7] = 1;
409     + exif_data[offset+8] = 0;
410     + exif_data[offset+9] = (unsigned char)set_flag;
411     + exif_data[offset+10] = 0;
412     + exif_data[offset+11] = 0;
413     + } else {
414     + exif_data[offset+2] = 3; /* Format = unsigned short (2 octets) */
415     + exif_data[offset+3] = 0;
416     + exif_data[offset+4] = 1; /* Number Of Components = 1 */
417     + exif_data[offset+5] = 0;
418     + exif_data[offset+6] = 0;
419     + exif_data[offset+7] = 0;
420     + exif_data[offset+8] = (unsigned char)set_flag;
421     + exif_data[offset+9] = 0;
422     + exif_data[offset+10] = 0;
423     + exif_data[offset+11] = 0;
424     + }
425     + fseek(myfile, (4 + 2 + 6 + 2) + offset, SEEK_SET);
426     + fwrite(exif_data + 2 + offset, 1, 10, myfile);
427     + } else {
428     + /* Get the Orientation value */
429     + if (is_motorola) {
430     + if (exif_data[offset+8] != 0) return 0;
431     + set_flag = exif_data[offset+9];
432     + } else {
433     + if (exif_data[offset+9] != 0) return 0;
434     + set_flag = exif_data[offset+8];
435     + }
436     + if (set_flag > 8) return 0;
437     + }
438     +
439     + /* Write out Orientation value */
440     + if (n_flag)
441     + printf("%c", '0' + set_flag);
442     + else
443     + printf("%c\n", '0' + set_flag);
444     +
445     + /* All done. */
446     + return 0;
447     +}
448     diff -Naur jpeg-6b.orig/extra/Makefile jpeg-6b/extra/Makefile
449     --- jpeg-6b.orig/extra/Makefile 1970-01-01 01:00:00.000000000 +0100
450     +++ jpeg-6b/extra/Makefile 2006-06-11 15:10:54.000000000 +0200
451     @@ -0,0 +1,19 @@
452     +CFLAGS = -O2 -Wall -g
453     +CC = cc
454     +INSTALL = install -m755 -o root -g root
455     +DESTDIR =
456     +prefix = /usr/local
457     +bindir = $(prefix)/bin
458     +mandir = $(prefix)/share/man/man1
459     +
460     +all: jpegexiforient
461     +
462     +jpegexiforient: jpegexiforient.c
463     + $(CC) $(CFLAGS) -o jpegexiforient jpegexiforient.c
464     +clean:
465     + -rm -f jpegexiforient
466     +install:
467     + $(INSTALL) jpegexiforient $(DESTDIR)$(bindir)
468     + $(INSTALL) jpegexiforient.1 $(DESTDIR)$(mandir)
469     + $(INSTALL) exifautotran $(DESTDIR)$(bindir)
470     + $(INSTALL) exifautotran.1 $(DESTDIR)$(mandir)