vipsthumbnail defaults to bicubic + noshapen
if bicubic is available
This commit is contained in:
parent
ebec31fe4a
commit
f1df91eebb
@ -5,6 +5,8 @@
|
|||||||
- add "autocrop" option to openslide load
|
- add "autocrop" option to openslide load
|
||||||
- argh fix affine, again
|
- argh fix affine, again
|
||||||
- pngsave in interlaced mode make a copy of the whole image
|
- pngsave in interlaced mode make a copy of the whole image
|
||||||
|
- vipsthumbnail shrinks to 1/2 window_size
|
||||||
|
- vipsthumbnail defaults to bicubic + nosharpen
|
||||||
|
|
||||||
4/7/14 started 7.40.4
|
4/7/14 started 7.40.4
|
||||||
- fix vips_rawsave_fd(), thanks aferrero2707
|
- fix vips_rawsave_fd(), thanks aferrero2707
|
||||||
|
11
TODO
11
TODO
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
- try:
|
- try:
|
||||||
|
|
||||||
$ vipsthumbnail Chicago.png --vips-concurrency=1
|
$ vipsthumbnail Chicago.png --vips-concurrency=1
|
||||||
@ -9,16 +10,6 @@
|
|||||||
|
|
||||||
- bicubic adds noise to 255/255/255, why? try babe.jpg background
|
- bicubic adds noise to 255/255/255, why? try babe.jpg background
|
||||||
|
|
||||||
- experiment with size down to two sizes above in vipsthumbnail
|
|
||||||
|
|
||||||
how does this affect speed and sharpness?
|
|
||||||
|
|
||||||
do shrink / VIPS_MAX( window_size / 2, 1 )
|
|
||||||
|
|
||||||
find shrink needs a copy of the interpolator: make a single interp during
|
|
||||||
startup
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@
|
|||||||
* unlike the main image wrt. rotation / colour / etc.
|
* unlike the main image wrt. rotation / colour / etc.
|
||||||
* 30/6/14
|
* 30/6/14
|
||||||
* - fix interlaced thumbnail output, thanks lovell
|
* - fix interlaced thumbnail output, thanks lovell
|
||||||
|
* 3/8/14
|
||||||
|
* - box shrink less, use interpolator more, if the window_size is large
|
||||||
|
* enough
|
||||||
|
* - default to bicubic + nosharpen if bicubic is available
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -68,6 +72,10 @@
|
|||||||
|
|
||||||
#define ORIENTATION ("exif-ifd0-Orientation")
|
#define ORIENTATION ("exif-ifd0-Orientation")
|
||||||
|
|
||||||
|
/* Default settings. We change the default to bicubic + nosharpen in main() if
|
||||||
|
* this vips has been compiled with bicubic support.
|
||||||
|
*/
|
||||||
|
|
||||||
static char *thumbnail_size = "128";
|
static char *thumbnail_size = "128";
|
||||||
static int thumbnail_width = 128;
|
static int thumbnail_width = 128;
|
||||||
static int thumbnail_height = 128;
|
static int thumbnail_height = 128;
|
||||||
@ -170,14 +178,20 @@ get_angle( VipsImage *im )
|
|||||||
* We shrink in two stages: first, a shrink with a block average. This can
|
* 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
|
* only accurately shrink by integer factors. We then do a second shrink with
|
||||||
* a supplied interpolator to get the exact size we want.
|
* a supplied interpolator to get the exact size we want.
|
||||||
|
*
|
||||||
|
* We aim to do the second shrink by roughly half the interpolator's
|
||||||
|
* window_size.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
calculate_shrink( VipsImage *im, double *residual )
|
calculate_shrink( VipsImage *im, double *residual,
|
||||||
|
VipsInterpolate *interp )
|
||||||
{
|
{
|
||||||
VipsAngle angle = get_angle( im );
|
VipsAngle angle = get_angle( im );
|
||||||
gboolean rotate = angle == VIPS_ANGLE_90 || angle == VIPS_ANGLE_270;
|
gboolean rotate = angle == VIPS_ANGLE_90 || angle == VIPS_ANGLE_270;
|
||||||
int width = rotate_image && rotate ? im->Ysize : im->Xsize;
|
int width = rotate_image && rotate ? im->Ysize : im->Xsize;
|
||||||
int height = rotate_image && rotate ? im->Xsize : im->Ysize;
|
int height = rotate_image && rotate ? im->Xsize : im->Ysize;
|
||||||
|
const int window_size =
|
||||||
|
interp ? vips_interpolate_get_window_size( interp ) : 2;
|
||||||
|
|
||||||
VipsDirection direction;
|
VipsDirection direction;
|
||||||
|
|
||||||
@ -211,9 +225,11 @@ calculate_shrink( VipsImage *im, double *residual )
|
|||||||
*/
|
*/
|
||||||
double factor2 = factor < 1.0 ? 1.0 : factor;
|
double factor2 = factor < 1.0 ? 1.0 : factor;
|
||||||
|
|
||||||
/* Int component of shrink.
|
/* Int component of factor2.
|
||||||
|
*
|
||||||
|
* We want to shrink by less for interpolators with larger windows.
|
||||||
*/
|
*/
|
||||||
int shrink = floor( factor2 );
|
int shrink = floor( factor2 ) / VIPS_MAX( window_size / 2, 1 );
|
||||||
|
|
||||||
if( residual &&
|
if( residual &&
|
||||||
direction == VIPS_DIRECTION_HORIZONTAL ) {
|
direction == VIPS_DIRECTION_HORIZONTAL ) {
|
||||||
@ -243,7 +259,7 @@ calculate_shrink( VipsImage *im, double *residual )
|
|||||||
static int
|
static int
|
||||||
thumbnail_find_jpegshrink( VipsImage *im )
|
thumbnail_find_jpegshrink( VipsImage *im )
|
||||||
{
|
{
|
||||||
int shrink = calculate_shrink( im, NULL );
|
int shrink = calculate_shrink( im, NULL, NULL );
|
||||||
|
|
||||||
/* We can't use pre-shrunk images in linear mode. libjpeg shrinks in Y
|
/* We can't use pre-shrunk images in linear mode. libjpeg shrinks in Y
|
||||||
* (of YCbCR), not linear space.
|
* (of YCbCR), not linear space.
|
||||||
@ -324,7 +340,7 @@ thumbnail_interpolator( VipsObject *process, VipsImage *in )
|
|||||||
double residual;
|
double residual;
|
||||||
VipsInterpolate *interp;
|
VipsInterpolate *interp;
|
||||||
|
|
||||||
calculate_shrink( in, &residual );
|
calculate_shrink( in, &residual, NULL );
|
||||||
|
|
||||||
/* For images smaller than the thumbnail, we upscale with nearest
|
/* For images smaller than the thumbnail, we upscale with nearest
|
||||||
* neighbor. Otherwise we makes thumbnails that look fuzzy and awful.
|
* neighbor. Otherwise we makes thumbnails that look fuzzy and awful.
|
||||||
@ -430,7 +446,7 @@ thumbnail_shrink( VipsObject *process, VipsImage *in,
|
|||||||
return( NULL );
|
return( NULL );
|
||||||
in = t[2];
|
in = t[2];
|
||||||
|
|
||||||
shrink = calculate_shrink( in, &residual );
|
shrink = calculate_shrink( in, &residual, interp );
|
||||||
|
|
||||||
vips_info( "vipsthumbnail", "integer shrink by %d", shrink );
|
vips_info( "vipsthumbnail", "integer shrink by %d", shrink );
|
||||||
|
|
||||||
@ -670,6 +686,14 @@ main( int argc, char **argv )
|
|||||||
textdomain( GETTEXT_PACKAGE );
|
textdomain( GETTEXT_PACKAGE );
|
||||||
setlocale( LC_ALL, "" );
|
setlocale( LC_ALL, "" );
|
||||||
|
|
||||||
|
/* Does this vips have bicubic? Default to that + nosharpen if it
|
||||||
|
* does.
|
||||||
|
*/
|
||||||
|
if( vips_type_find( "VipsInterpolate", "bicubic" ) ) {
|
||||||
|
interpolator = "bicubic";
|
||||||
|
convolution_mask = "none";
|
||||||
|
}
|
||||||
|
|
||||||
context = g_option_context_new( _( "- thumbnail generator" ) );
|
context = g_option_context_new( _( "- thumbnail generator" ) );
|
||||||
|
|
||||||
g_option_context_add_main_entries( context, options, GETTEXT_PACKAGE );
|
g_option_context_add_main_entries( context, options, GETTEXT_PACKAGE );
|
||||||
|
Loading…
Reference in New Issue
Block a user