This commit is contained in:
John Cupitt 2010-02-05 14:34:38 +00:00
parent f9b29783f5
commit 61d4eddbb4
4 changed files with 88 additions and 75 deletions

View File

@ -1,3 +1,24 @@
16/1/10 started 7.21.2
- "invalidate" is careful to keep images alive, so invalidate callbacks can do
im_close()
- flood_blob could loop if start point == ink
- added im_meta_remove()
- added remove profile option to vipsthumbnail
- added vips_bandfmt_iscomplex() and friends, im_iscomplex() and friends
deprecated
- im_bandjoin()/im_gbandjoin() work with images of varying formats
- added im_copy_native(), deprecated im_copy_from() and friends
- im_check*() name rationalisation
- finally removed old flood stuff
- im_insert*() bandalike and formatalike
- im_*join() bandalike and formatalike
- im_ri2c() bandalike
- im_vips2png() saves 16-bit PNGs, if necessary
- vipsthumbnail has selectable interpolators, optional sharpen
15/1/10 started 7.21.1
- added "written" callbacks, used to implement write to non-vips formats
26/11/09 started 7.21.0
- branch for new dev cycle
- argh, missing init from colour.c (thanks Peter)
@ -18,22 +39,6 @@
- read TIFF images strip-wise, not scanline-wise
- better TIFF YCbCr reading (thanks Ole)
- isanalyze generates fewer silly error messages
- added "written" callbacks, used to implement write to non-vips formats
- "invalidate" is careful to keep images alive, so invalidate callbacks can do
im_close()
- flood_blob could loop if start point == ink
- added im_meta_remove()
- added remove profile option to vipsthumbnail
- added vips_bandfmt_iscomplex() and friends, im_iscomplex() and friends
deprecated
- im_bandjoin()/im_gbandjoin() work with images of varying formats
- added im_copy_native(), deprecated im_copy_from() and friends
- im_check*() name rationalisation
- finally removed old flood stuff
- im_insert*() bandalike and formatalike
- im_*join() bandalike and formatalike
- im_ri2c() bandalike
- im_vips2png() saves 16-bit PNGs if necessary
26/11/09 started 7.20.3
- updated en_GB.po translation

14
TODO
View File

@ -1,17 +1,3 @@
- vipsthumbnail should let you supply an interpolator instead of bilinear
eg. --interpolator "yafrsmooth{2}"
make the sharpening optional?
- im__convert_saveable() (in im_copy.c) always makes an 8-bit image
this means we can't save 16-bit PNG!
- how about im_invalidate_area()? we currently repaint the whole window on
every paint action in nip2 :-(

View File

@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(m4)
# user-visible library versioning
IM_MAJOR_VERSION=7
IM_MINOR_VERSION=21
IM_MICRO_VERSION=1
IM_MICRO_VERSION=2
IM_VERSION=$IM_MAJOR_VERSION.$IM_MINOR_VERSION.$IM_MICRO_VERSION
IM_VERSION_STRING=$IM_VERSION-`date`
@ -22,9 +22,9 @@ PACKAGE=vips
# interface changes backwards compatible?: increment age
# interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=28
LIBRARY_REVISION=3
LIBRARY_AGE=13
LIBRARY_CURRENT=29
LIBRARY_REVISION=0
LIBRARY_AGE=14
AM_INIT_AUTOMAKE($PACKAGE,$VERSION)

View File

@ -22,13 +22,15 @@
#include <vips/vips.h>
static gboolean verbose = FALSE;
static int use_disc_threshold = 1024 * 1024;
static int thumbnail_size = 128;
static char *thumbnail_format = "tn_%s.jpg";
static int use_disc_threshold = 1024 * 1024;
static char *interpolator = "bilinear";;
static gboolean nosharpen = FALSE;
static char *export_profile = NULL;
static char *import_profile = NULL;
static gboolean delete_profile = FALSE;
static gboolean verbose = FALSE;
static GOptionEntry options[] = {
{ "size", 's', 0, G_OPTION_ARG_INT, &thumbnail_size,
@ -37,6 +39,10 @@ static GOptionEntry options[] = {
N_( "set thumbnail format to S" ), "S" },
{ "disc", 'd', 0, G_OPTION_ARG_INT, &use_disc_threshold,
N_( "set disc use threshold to N" ), "N" },
{ "interpolator", 'p', 0, G_OPTION_ARG_STRING, &interpolator,
N_( "resample with interpolator I" ), "I" },
{ "nosharpen", 'n', 0, G_OPTION_ARG_NONE, &nosharpen,
N_( "don't sharpen thumbnail" ), NULL },
{ "eprofile", 'e', 0, G_OPTION_ARG_STRING, &export_profile,
N_( "export with profile P" ), "P" },
{ "iprofile", 'i', 0, G_OPTION_ARG_STRING, &import_profile,
@ -102,7 +108,7 @@ open_image( const char *filename )
*
* We shrink in two stages: first, a shrink with a block average. This can
* only accurately shrink by integer factors. We then do a second shrink with
* bilinear interpolation to get the exact size we want.
* a supplied interpolator to get the exact size we want.
*/
static int
calculate_shrink( int width, int height, double *residual )
@ -134,12 +140,8 @@ calculate_shrink( int width, int height, double *residual )
return( shrink );
}
/* We use bilinear interpolation for the final shrink. VIPS has higher-order
* interpolators, but they are only built if a C++ compiler is available.
* Bilinear can look a little 'soft', so after shrinking, we need to sharpen a
* little.
*
* This is a simple sharpen filter.
/* Some interpolators look a little soft, so we have an optional sharpening
* stage.
*/
static INTMASK *
sharpen_filter( void )
@ -158,28 +160,11 @@ sharpen_filter( void )
}
static int
shrink_factor( IMAGE *in, IMAGE *out )
shrink_factor( IMAGE *in, IMAGE *out,
int shrink, double residual, VipsInterpolate *interp )
{
IMAGE *t[9];
IMAGE *x;
int shrink;
double residual;
VipsInterpolate *interp;
shrink = calculate_shrink( in->Xsize, in->Ysize, &residual );
/* For images smaller than the thumbnail, we upscale with nearest
* neighbor. Otherwise we makes thumbnails that look fuzzy and awful.
*/
if( residual > 1.0 )
interp = vips_interpolate_nearest_static();
else
interp = vips_interpolate_bilinear_static();
if( verbose ) {
printf( "integer shrink by %d\n", shrink );
printf( "residual scale by %g\n", residual );
}
if( im_open_local_array( out, t, 9, "thumbnail", "p" ) )
return( -1 );
@ -215,7 +200,10 @@ shrink_factor( IMAGE *in, IMAGE *out )
/* If we are upsampling, don't sharpen, since nearest looks dumb
* sharpened.
*/
if( residual > 1.0 ) {
if( residual > 1.0 && !nosharpen ) {
if( verbose )
printf( "sharpening thumbnail\n" );
if( im_conv( x, t[4], sharpen_filter() ) )
return( -1 );
x = t[4];
@ -229,38 +217,41 @@ shrink_factor( IMAGE *in, IMAGE *out )
(im_header_get_typeof( x, IM_META_ICC_NAME ) ||
import_profile) ) {
if( im_header_get_typeof( x, IM_META_ICC_NAME ) ) {
if( verbose )
printf( "importing with embedded profile\n" );
if( im_icc_import_embedded( x, t[5],
IM_INTENT_RELATIVE_COLORIMETRIC ) )
return( -1 );
if( verbose )
printf( "importing with embedded profile\n" );
}
else {
if( verbose )
printf( "importing with profile %s\n",
import_profile );
if( im_icc_import( x, t[5],
import_profile,
IM_INTENT_RELATIVE_COLORIMETRIC ) )
return( -1 );
if( verbose )
printf( "importing with profile %s\n",
import_profile );
}
if( verbose )
printf( "exporting with profile %s\n", export_profile );
if( im_icc_export_depth( t[5], t[6],
8, export_profile,
IM_INTENT_RELATIVE_COLORIMETRIC ) )
return( -1 );
if( verbose )
printf( "exporting with profile %s\n", export_profile );
x = t[6];
}
if( delete_profile ) {
if( im_meta_remove( x, IM_META_ICC_NAME ) && verbose )
if( verbose )
printf( "deleting profile from output image\n" );
if( im_meta_remove( x, IM_META_ICC_NAME ) )
return( -1 );
}
if( im_copy( x, out ) )
@ -269,6 +260,37 @@ shrink_factor( IMAGE *in, IMAGE *out )
return( 0 );
}
static int
thumbnail3( IMAGE *in, IMAGE *out )
{
int shrink;
double residual;
VipsInterpolate *interp;
int result;
shrink = calculate_shrink( in->Xsize, in->Ysize, &residual );
/* For images smaller than the thumbnail, we upscale with nearest
* neighbor. Otherwise we makes thumbnails that look fuzzy and awful.
*/
if( !(interp = VIPS_INTERPOLATE( vips_object_new_from_string(
"VipsInterpolate",
residual > 1.0 ? "nearest" : interpolator ) )) )
return( -1 );
if( verbose ) {
printf( "integer shrink by %d\n", shrink );
printf( "residual scale by %g\n", residual );
printf( "%s interpolation\n", VIPS_OBJECT( interp )->nickname );
}
result = shrink_factor( in, out, shrink, residual, interp );
g_object_unref( interp );
return( result );
}
/* Given (eg.) "/poop/somefile.png", make the thumbnail name,
* "/poop/tn_somefile.jpg".
*/
@ -317,7 +339,7 @@ thumbnail2( const char *filename )
return( -1 );
}
result = shrink_factor( in, out );
result = thumbnail3( in, out );
g_free( tn_filename );
im_close( out );