From 19bd17fa608f782c23b1ac50987e741d85668d5b Mon Sep 17 00:00:00 2001 From: Stéphane Aulery Date: Fri, 24 Oct 2014 01:42:35 +0200 Subject: Trimming pictures by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, crop images with unconventional dimensions. Adds an option (-np) to disable this behavior. Signed-off-by: Stéphane Aulery Signed-off-by: Gerd Hoffmann --- exiftran.c | 5 +++++ exiftran.man | 7 +++++++ exiftran.man.fr | 7 +++++++ jpegtools.c | 5 ++++- jpegtools.h | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/exiftran.c b/exiftran.c index 3669814..410d937 100644 --- a/exiftran.c +++ b/exiftran.c @@ -95,6 +95,7 @@ usage(FILE *fp, char *name) " -nt don't rotate exif thumbnail\n" " -ni don't rotate jpeg image\n" " -no don't update the orientation tag\n" + " -np don't pare lost edges\n" "\n" "other options:\n" " -h print this help text\n" @@ -122,6 +123,7 @@ int main(int argc, char *argv[]) unsigned int flags = JFLAG_TRANSFORM_IMAGE | JFLAG_TRANSFORM_THUMBNAIL | + JFLAG_TRANSFORM_TRIM | JFLAG_UPDATE_ORIENTATION; int dump = 0; int i, c, rc; @@ -168,6 +170,9 @@ int main(int argc, char *argv[]) case 'o': flags &= ~JFLAG_UPDATE_ORIENTATION; break; + case 'p': + flags &= ~JFLAG_TRANSFORM_TRIM; + break; default: fprintf(stderr,"unknown option -n%c\n",optarg[0]); exit(1); diff --git a/exiftran.man b/exiftran.man index 06470d8..1889f88 100644 --- a/exiftran.man +++ b/exiftran.man @@ -69,6 +69,13 @@ Don't update the orientation tag. By default .BR exiftran sets the orientation to "1" (no transformation needed) to avoid other exif-aware applications try to rotate the already-rotated image again. +.TP +.B -np +Don't pare lost edges. By default +.BR exiftran +don't preserve image size of the images that do not meet a +multiple of 8 pixels. He prefers to cut a strip of a few pixels rather than +offering a damaged image. Use this option if you want them all the same. \# \# .SH "OTHER OPTIONS" diff --git a/exiftran.man.fr b/exiftran.man.fr index 4f4003c..65cdfeb 100644 --- a/exiftran.man.fr +++ b/exiftran.man.fr @@ -72,6 +72,13 @@ Ne pas mettre à jour la propriété d'orientation. Par défaut positionne l'orientation à "1" (aucune transformation nécessaire) pour empêcher d'autres logiciels de manipulation des données exif d'essayer de pivoter l'image qui l'est déjà. +.TP +.B -np +Ne pas couper les bordures perdus. Par défaut +.BR exiftran +ne préserve pas la dimension des images qui ne respectent pas un multiple de 8 +pixels. Il préfère couper une bande de quelques pixels plutôt que d'offrir une +image détériorée. Utilisez cette options si vous les voulez tout de même. \# \# .SH "AUTRES OPTIONS" diff --git a/jpegtools.c b/jpegtools.c index f2c1791..692567e 100644 --- a/jpegtools.c +++ b/jpegtools.c @@ -430,7 +430,10 @@ static int do_transform(struct jpeg_decompress_struct *src, memset(&transformoption,0,sizeof(transformoption)); transformoption.transform = transform; - transformoption.trim = FALSE; + if (!(flags & JFLAG_TRANSFORM_TRIM)) + transformoption.trim = TRUE; + else + transformoption.trim = FALSE; transformoption.force_grayscale = FALSE; /* Any space needed by a transform option must be requested before diff --git a/jpegtools.h b/jpegtools.h index 78035b0..964f3c3 100644 --- a/jpegtools.h +++ b/jpegtools.h @@ -2,6 +2,7 @@ /* various flags */ #define JFLAG_TRANSFORM_IMAGE 0x0001 #define JFLAG_TRANSFORM_THUMBNAIL 0x0002 +#define JFLAG_TRANSFORM_TRIM 0x0004 #define JFLAG_UPDATE_COMMENT 0x0010 #define JFLAG_UPDATE_ORIENTATION 0x0020 -- cgit