diff --git a/ChangeLog b/ChangeLog index bd179405..b277da44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,10 @@ - deprecate "properties" option to dzsave (now always on) - always set the min stack size for pthreads, if we can - add fail-on to thumbnail +- add "gap" option to vips_reduce[hv]() and vips_resize() [kleisauke] +- add "ceil" option to vips_shrink() [kleisauke] +- quality improvements for image resizing [kleisauke] + 26/11/21 started 8.12.3 - better arg checking for hist_find_ndim [travisbell] diff --git a/libvips/resample/reduce.c b/libvips/resample/reduce.c index 31fb3a68..531898ed 100644 --- a/libvips/resample/reduce.c +++ b/libvips/resample/reduce.c @@ -138,7 +138,7 @@ typedef struct _VipsReduce { VipsResample parent_instance; - double hshrink; /* Shrink factors */ + double hshrink; /* Shrink factors */ double vshrink; double gap; /* Reduce gap */ diff --git a/libvips/resample/reduceh.cpp b/libvips/resample/reduceh.cpp index a70ebe0f..dca40161 100644 --- a/libvips/resample/reduceh.cpp +++ b/libvips/resample/reduceh.cpp @@ -65,7 +65,7 @@ typedef struct _VipsReduceh { VipsResample parent_instance; - double hshrink; /* Reduce factor */ + double hshrink; /* Reduce factor */ double gap; /* Reduce gap */ /* The thing we use to make the kernel. @@ -477,8 +477,8 @@ vips_reduceh_build( VipsObject *object ) /* The int part of our reduce. */ - int_hshrink = VIPS_MAX( 1, - VIPS_FLOOR( (double) in->Xsize / width / reduceh->gap ) ); + int_hshrink = VIPS_MAX( 1, VIPS_FLOOR( + (double) in->Xsize / width / reduceh->gap ) ); if( int_hshrink > 1 ) { g_info( "shrinkh by %d", int_hshrink ); diff --git a/libvips/resample/reducev.cpp b/libvips/resample/reducev.cpp index 74f1b269..f201f6fd 100644 --- a/libvips/resample/reducev.cpp +++ b/libvips/resample/reducev.cpp @@ -105,7 +105,7 @@ typedef struct _VipsReducev { VipsResample parent_instance; double vshrink; /* Reduce factor */ - double gap; /* Reduce gap */ + double gap; /* Reduce gap */ /* The thing we use to make the kernel. */ @@ -846,8 +846,8 @@ vips_reducev_build( VipsObject *object ) /* The int part of our reduce. */ - int_vshrink = VIPS_MAX( 1, - VIPS_FLOOR( (double) in->Ysize / height / reducev->gap ) ); + int_vshrink = VIPS_MAX( 1, VIPS_FLOOR( + (double) in->Ysize / height / reducev->gap ) ); if( int_vshrink > 1 ) { g_info( "shrinkv by %d", int_vshrink ); diff --git a/libvips/resample/resize.c b/libvips/resample/resize.c index 67f41037..ec54b682 100644 --- a/libvips/resample/resize.c +++ b/libvips/resample/resize.c @@ -178,10 +178,12 @@ vips_resize_build( VipsObject *object ) target_width = VIPS_ROUND_UINT( in->Xsize * hscale ); target_height = VIPS_ROUND_UINT( in->Ysize * vscale ); - int_hshrink = - VIPS_FLOOR( (double) in->Xsize / target_width / resize->gap ); - int_vshrink = - VIPS_FLOOR( (double) in->Ysize / target_height / resize->gap ); + int_hshrink = VIPS_FLOOR( + (double) in->Xsize / target_width / + resize->gap ); + int_vshrink = VIPS_FLOOR( + (double) in->Ysize / target_height / + resize->gap ); } int_hshrink = VIPS_MAX( 1, int_hshrink ); diff --git a/libvips/resample/shrink.c b/libvips/resample/shrink.c index 68d6e1eb..5dabe197 100644 --- a/libvips/resample/shrink.c +++ b/libvips/resample/shrink.c @@ -65,7 +65,7 @@ typedef struct _VipsShrink { double hshrink; /* Shrink factors */ double vshrink; - gboolean ceil; /* Round operation */ + gboolean ceil; /* Round operation */ } VipsShrink; @@ -95,21 +95,21 @@ vips_shrink_build( VipsObject *object ) /* Shrink by int factors, reduce to final size. */ if( vips_reducev( resample->in, &t[0], shrink->vshrink, - "gap", 1.0, - NULL ) || + "gap", 1.0, + NULL ) || vips_reduceh( t[0], &t[1], shrink->hshrink, - "gap", 1.0, - NULL ) || + "gap", 1.0, + NULL ) || vips_image_write( t[1], resample->out ) ) return( -1 ); } else { if( vips_shrinkv( resample->in, &t[0], shrink->vshrink, - "ceil", shrink->ceil, - NULL ) || + "ceil", shrink->ceil, + NULL ) || vips_shrinkh( t[0], &t[1], shrink->hshrink, - "ceil", shrink->ceil, - NULL ) || + "ceil", shrink->ceil, + NULL ) || vips_image_write( t[1], resample->out ) ) return( -1 ); } diff --git a/libvips/resample/shrinkh.c b/libvips/resample/shrinkh.c index 71449674..f4a665c3 100644 --- a/libvips/resample/shrinkh.c +++ b/libvips/resample/shrinkh.c @@ -278,7 +278,8 @@ vips_shrinkh_build( VipsObject *object ) */ resample->out->Xsize = shrink->ceil ? VIPS_CEIL( (double) resample->in->Xsize / shrink->hshrink ) : - VIPS_ROUND_UINT( (double) resample->in->Xsize / shrink->hshrink ); + VIPS_ROUND_UINT( + (double) resample->in->Xsize / shrink->hshrink ); if( resample->out->Xsize <= 0 ) { vips_error( class->nickname, "%s", _( "image has shrunk to nothing" ) ); diff --git a/libvips/resample/shrinkv.c b/libvips/resample/shrinkv.c index 28880cfd..9c01540d 100644 --- a/libvips/resample/shrinkv.c +++ b/libvips/resample/shrinkv.c @@ -383,7 +383,8 @@ vips_shrinkv_build( VipsObject *object ) */ t[2]->Ysize = shrink->ceil ? VIPS_CEIL( (double) resample->in->Ysize / shrink->vshrink ) : - VIPS_ROUND_UINT( (double) resample->in->Ysize / shrink->vshrink ); + VIPS_ROUND_UINT( + (double) resample->in->Ysize / shrink->vshrink ); if( t[2]->Ysize <= 0 ) { vips_error( class->nickname, "%s", _( "image has shrunk to nothing" ) );