From 7bebea093a81576f2ee401cbde6b20cd93d303c6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 13 May 2010 20:29:28 +0000 Subject: [PATCH] vipsthumbnail fixes --- ChangeLog | 1 + man/Makefile.am | 1 + man/vips.1 | 2 +- man/vipsthumbnail.1 | 122 ++++++++++++++++++++++++++++++++++ tools/iofuncs/vipsthumbnail.c | 9 ++- 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 man/vipsthumbnail.1 diff --git a/ChangeLog b/ChangeLog index 939ce751..ca89f2dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 12/5/10 started 7.22.0 - bump and rename +- vipsthumbnail has a manualpage and sharpens correctly 21/3/10 started 7.21.3 - added progress feedback to threadpool diff --git a/man/Makefile.am b/man/Makefile.am index 0c776f32..038b0d08 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -16,6 +16,7 @@ man_MANS = \ sines.1 \ squares.1 \ vips.1 \ + vipsthumbnail.1 \ error_exit.3 \ im_abs.3 \ im_acostra.3 \ diff --git a/man/vips.1 b/man/vips.1 index aa095b71..919bb2fb 100644 --- a/man/vips.1 +++ b/man/vips.1 @@ -1,6 +1,6 @@ .TH VIPS 1 "30 June 1993" .SH NAME -vips \- run vips function from UNIX command line +vips \- run vips operations from the command line .SH SYNOPSIS .B vips [flags] [command] [command-args] .SH DESCRIPTION diff --git a/man/vipsthumbnail.1 b/man/vipsthumbnail.1 new file mode 100644 index 00000000..6c427258 --- /dev/null +++ b/man/vipsthumbnail.1 @@ -0,0 +1,122 @@ +.TH VIPSTHUMBNAIL 1 "13 May 2010" +.SH NAME +vipsthumbnail \- make thumbnails of image files +.SH SYNOPSIS +.B vipsthumbnail [flags] imagefile1 imagefile2 ... +.SH DESCRIPTION +.B vipsthumbnail(1) +processes each +.B imagefile +in turn, shrinking each image to fit within a 128 by 128 pixel square. +The shrunk image is written to a new file named +.B tn_imagefile.jpg. +This program is typically quite a bit faster and uses much less memory than +other image thumbnail programs. + +For example: + + $ vipsthumbnail fred.png jim.tif + +will read image files +.B fred.png +and +.B jim.tif +and write thumbnails to the files +.B tn_fred.jpg +and +.B tn_jim.jpg. + + $ vipsthumbnail --size=64 -o thumbnails/%s.png fred.jpg + +will read image file +.B fred.jpg +and write a 64 x 64 pixel thumbnail to the file +.B thumbnails/fred.png. + +.SH OPTIONS +.TP +.B -s N, --size=N +Set the output thumbnail size to +.B N +x +.B N +pixels. The image is shrunk so that it just fits within this area, Images +which are smaller than this are expanded. + +.TP +.B -o FORMAT, --output=FORMAT +Set the output format string. The input filename has any file type suffix +removed, then that value is substitued into +.B FORMAT +replacing +.B %s. +The default value is +.B tn_%s.jpg +meaning JPEG output, with +.B tn_ +prepended. You can add format options too, for example +.B tn_%s.jpg:20 +will write JPEG images with Q set to 20. + +.TP +.B -d N, --disc=N +Set disc use threshold to +.B N. +Images which cannot be opened directly need to be decompressed first. Images +which are smaller than +.B N +are decompressed to memory, images which are larger are decompressed to +temporary files. Use the +.B TMPDIR +environment variable to change the location for temporary files. + +.TP +.B -p I, --interpolator=I +Resample with interpolator +.B I. +Use +.B vips --list classes +to see a list of valid interpolators. The default is +.B bilinear. + +.TP +.B -n, --nosharpen +By default, +.B vipsthumbnail(1) +will sharpen thumbnails slightly to make them look more pleasing. This option +disables this sharpening. + +.TP +.B -e PROFILE, --eprofile=PROFILE +Export thumbnails with this ICC profile. Images are only colour-transformed if +there is both an output and an input profile available. The input profile can +either be embedded in the input image or supplied with the +.B --iprofile +option. + +.TP +.B -i PROFILE, --iprofile=PROFILE +Import images with this ICC profile, if no profile is embdedded in the image. +Images are only colour-transformed if +there is both an output and an input profile available. The output profile +should be supplied with the +.B --oprofile +option. + +.TP +.B -l, --nodelete +Don't delete the profile from the output image. Since all output images will +generally have the same profile, +.B vipsthumbnail(1) +will usually delete it. This option leaves the profile inside the image. + +.TP +.B -v, --verbose +.B vipsthumbnail(1) +normally runs silently, except for warning and error messages. This option +makes it print a list of the operations it performs on each image. + +.SH RETURN VALUE +returns 0 on success and non-zero on error. +.SH SEE ALSO +header(1) diff --git a/tools/iofuncs/vipsthumbnail.c b/tools/iofuncs/vipsthumbnail.c index ff6de7e7..d7327ed7 100644 --- a/tools/iofuncs/vipsthumbnail.c +++ b/tools/iofuncs/vipsthumbnail.c @@ -12,6 +12,9 @@ * - added "--interpolator" * - added "--nosharpen" * - better 'open' logic, test lazy flag now + * 13/5/10 + * - oops hehe residual sharpen test was reversed + * - and the mask coefficients were messed up */ #ifdef HAVE_CONFIG_H @@ -174,9 +177,9 @@ sharpen_filter( void ) if( !mask ) { mask = im_create_imaskv( "sharpen.con", 3, 3, -1, -1, -1, - -1, 8, -1, + -1, 16, -1, -1, -1, -1 ); - mask->scale = 4; + mask->scale = 8; } return( mask ); @@ -223,7 +226,7 @@ shrink_factor( IMAGE *in, IMAGE *out, /* If we are upsampling, don't sharpen, since nearest looks dumb * sharpened. */ - if( residual > 1.0 && !nosharpen ) { + if( residual < 1.0 && !nosharpen ) { if( verbose ) printf( "sharpening thumbnail\n" );