add an intent option to thumbnail
"intent" lets you set the rendering intent for any ICC conversions -- the default is the (more correct) relative, but "perceptual" can look better see https://github.com/jcupitt/libvips/issues/714
This commit is contained in:
parent
820c279697
commit
5a37d3e809
@ -14,6 +14,7 @@
|
|||||||
- remove lcms1 support, it had bitrotted
|
- remove lcms1 support, it had bitrotted
|
||||||
- `join` tagged as seq
|
- `join` tagged as seq
|
||||||
- support tiffsave_buffer for pyramids, thanks bubba
|
- support tiffsave_buffer for pyramids, thanks bubba
|
||||||
|
- thumbnail and vipsthumbnail have an option for rendering intent, thanks kleisauke
|
||||||
|
|
||||||
29/8/17 started 8.5.9
|
29/8/17 started 8.5.9
|
||||||
- make --fail stop jpeg read on any libjpeg warning, thanks @mceachen
|
- make --fail stop jpeg read on any libjpeg warning, thanks @mceachen
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
* - add FORCE
|
* - add FORCE
|
||||||
* 29/5/17
|
* 29/5/17
|
||||||
* - don't cache (thanks tomasc)
|
* - don't cache (thanks tomasc)
|
||||||
|
* 30/8/17
|
||||||
|
* - add intent option, thanks kleisauke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,6 +83,7 @@ typedef struct _VipsThumbnail {
|
|||||||
gboolean linear;
|
gboolean linear;
|
||||||
char *export_profile;
|
char *export_profile;
|
||||||
char *import_profile;
|
char *import_profile;
|
||||||
|
VipsIntent intent;
|
||||||
|
|
||||||
/* Set by subclasses to the input image.
|
/* Set by subclasses to the input image.
|
||||||
*/
|
*/
|
||||||
@ -375,6 +378,7 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
if( vips_icc_import( in, &t[1],
|
if( vips_icc_import( in, &t[1],
|
||||||
"input_profile", thumbnail->import_profile,
|
"input_profile", thumbnail->import_profile,
|
||||||
"embedded", TRUE,
|
"embedded", TRUE,
|
||||||
|
"intent", thumbnail->intent,
|
||||||
"pcs", VIPS_PCS_XYZ,
|
"pcs", VIPS_PCS_XYZ,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -442,6 +446,7 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
g_info( "exporting to device space with a profile" );
|
g_info( "exporting to device space with a profile" );
|
||||||
if( vips_icc_export( in, &t[7],
|
if( vips_icc_export( in, &t[7],
|
||||||
"output_profile", thumbnail->export_profile,
|
"output_profile", thumbnail->export_profile,
|
||||||
|
"intent", thumbnail->intent,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
in = t[7];
|
in = t[7];
|
||||||
@ -470,6 +475,7 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
|
|
||||||
if( vips_icc_transform( in, &t[7],
|
if( vips_icc_transform( in, &t[7],
|
||||||
thumbnail->export_profile,
|
thumbnail->export_profile,
|
||||||
|
"intent", thumbnail->intent,
|
||||||
"embedded", TRUE,
|
"embedded", TRUE,
|
||||||
NULL ) ) {
|
NULL ) ) {
|
||||||
g_warning( _( "unable to import with "
|
g_warning( _( "unable to import with "
|
||||||
@ -489,6 +495,7 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
if( vips_icc_transform( in, &t[7],
|
if( vips_icc_transform( in, &t[7],
|
||||||
thumbnail->export_profile,
|
thumbnail->export_profile,
|
||||||
"input_profile", thumbnail->import_profile,
|
"input_profile", thumbnail->import_profile,
|
||||||
|
"intent", thumbnail->intent,
|
||||||
"embedded", FALSE,
|
"embedded", FALSE,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -630,6 +637,13 @@ vips_thumbnail_class_init( VipsThumbnailClass *class )
|
|||||||
G_STRUCT_OFFSET( VipsThumbnail, export_profile ),
|
G_STRUCT_OFFSET( VipsThumbnail, export_profile ),
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
|
VIPS_ARG_ENUM( class, "intent", 120,
|
||||||
|
_( "Intent" ),
|
||||||
|
_( "Rendering intent" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsThumbnail, intent ),
|
||||||
|
VIPS_TYPE_INTENT, VIPS_INTENT_RELATIVE );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -638,6 +652,7 @@ vips_thumbnail_init( VipsThumbnail *thumbnail )
|
|||||||
thumbnail->width = 1;
|
thumbnail->width = 1;
|
||||||
thumbnail->height = 1;
|
thumbnail->height = 1;
|
||||||
thumbnail->auto_rotate = TRUE;
|
thumbnail->auto_rotate = TRUE;
|
||||||
|
thumbnail->intent = VIPS_INTENT_RELATIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _VipsThumbnailFile {
|
typedef struct _VipsThumbnailFile {
|
||||||
@ -745,6 +760,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
|||||||
* * @linear: %gboolean, perform shrink in linear light
|
* * @linear: %gboolean, perform shrink in linear light
|
||||||
* * @import_profile: %gchararray, fallback import ICC profile
|
* * @import_profile: %gchararray, fallback import ICC profile
|
||||||
* * @export_profile: %gchararray, export ICC profile
|
* * @export_profile: %gchararray, export ICC profile
|
||||||
|
* * @intent: #VipsIntent, rendering intent
|
||||||
*
|
*
|
||||||
* Make a thumbnail from a file. Shrinking is done in three stages: using any
|
* Make a thumbnail from a file. Shrinking is done in three stages: using any
|
||||||
* shrink-on-load features available in the file import library, using a block
|
* shrink-on-load features available in the file import library, using a block
|
||||||
@ -786,6 +802,9 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
|||||||
* input image has no ICC profile, or if the profile embedded in the
|
* input image has no ICC profile, or if the profile embedded in the
|
||||||
* input image is broken.
|
* input image is broken.
|
||||||
*
|
*
|
||||||
|
* Use @intent to set the rendering intent for any ICC transform. The default
|
||||||
|
* is #VIPS_INTENT_RELATIVE.
|
||||||
|
*
|
||||||
* See also: vips_thumbnail_buffer().
|
* See also: vips_thumbnail_buffer().
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
@ -917,6 +936,7 @@ vips_thumbnail_buffer_init( VipsThumbnailBuffer *buffer )
|
|||||||
* * @linear: %gboolean, perform shrink in linear light
|
* * @linear: %gboolean, perform shrink in linear light
|
||||||
* * @import_profile: %gchararray, fallback import ICC profile
|
* * @import_profile: %gchararray, fallback import ICC profile
|
||||||
* * @export_profile: %gchararray, export ICC profile
|
* * @export_profile: %gchararray, export ICC profile
|
||||||
|
* * @intent: #VipsIntent, rendering intent
|
||||||
*
|
*
|
||||||
* Exacty as vips_thumbnail(), but read from a memory buffer.
|
* Exacty as vips_thumbnail(), but read from a memory buffer.
|
||||||
*
|
*
|
||||||
@ -1031,6 +1051,7 @@ vips_thumbnail_image_init( VipsThumbnailImage *image )
|
|||||||
* * @linear: %gboolean, perform shrink in linear light
|
* * @linear: %gboolean, perform shrink in linear light
|
||||||
* * @import_profile: %gchararray, fallback import ICC profile
|
* * @import_profile: %gchararray, fallback import ICC profile
|
||||||
* * @export_profile: %gchararray, export ICC profile
|
* * @export_profile: %gchararray, export ICC profile
|
||||||
|
* * @intent: #VipsIntent, rendering intent
|
||||||
*
|
*
|
||||||
* Exacty as vips_thumbnail(), but read from an existing image.
|
* Exacty as vips_thumbnail(), but read from an existing image.
|
||||||
*
|
*
|
||||||
|
@ -92,6 +92,8 @@
|
|||||||
* - support VipSize restrictions
|
* - support VipSize restrictions
|
||||||
* 4/5/17
|
* 4/5/17
|
||||||
* - add ! geo modifier
|
* - add ! geo modifier
|
||||||
|
* 30/8/17
|
||||||
|
* - add --intent
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -125,6 +127,7 @@ static gboolean linear_processing = FALSE;
|
|||||||
static gboolean crop_image = FALSE;
|
static gboolean crop_image = FALSE;
|
||||||
static char *smartcrop_image = NULL;
|
static char *smartcrop_image = NULL;
|
||||||
static gboolean rotate_image = FALSE;
|
static gboolean rotate_image = FALSE;
|
||||||
|
static char *thumbnail_intent = NULL;
|
||||||
|
|
||||||
/* Deprecated and unused.
|
/* Deprecated and unused.
|
||||||
*/
|
*/
|
||||||
@ -162,6 +165,10 @@ static GOptionEntry options[] = {
|
|||||||
G_OPTION_ARG_STRING, &smartcrop_image,
|
G_OPTION_ARG_STRING, &smartcrop_image,
|
||||||
N_( "shrink and crop to fill SIZE using STRATEGY" ),
|
N_( "shrink and crop to fill SIZE using STRATEGY" ),
|
||||||
N_( "STRATEGY" ) },
|
N_( "STRATEGY" ) },
|
||||||
|
{ "intent", 'n', 0,
|
||||||
|
G_OPTION_ARG_STRING, &thumbnail_intent,
|
||||||
|
N_( "ICC transform with INTENT" ),
|
||||||
|
N_( "INTENT" ) },
|
||||||
{ "rotate", 't', 0,
|
{ "rotate", 't', 0,
|
||||||
G_OPTION_ARG_NONE, &rotate_image,
|
G_OPTION_ARG_NONE, &rotate_image,
|
||||||
N_( "auto-rotate" ), NULL },
|
N_( "auto-rotate" ), NULL },
|
||||||
@ -245,18 +252,28 @@ thumbnail_process( VipsObject *process, const char *filename )
|
|||||||
{
|
{
|
||||||
VipsInteresting interesting;
|
VipsInteresting interesting;
|
||||||
VipsImage *image;
|
VipsImage *image;
|
||||||
|
VipsIntent intent;
|
||||||
|
|
||||||
interesting = VIPS_INTERESTING_NONE;
|
interesting = VIPS_INTERESTING_NONE;
|
||||||
if( crop_image )
|
if( crop_image )
|
||||||
interesting = VIPS_INTERESTING_CENTRE;
|
interesting = VIPS_INTERESTING_CENTRE;
|
||||||
if( smartcrop_image ) {
|
if( smartcrop_image ) {
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if( (n = vips_enum_from_nick( "vipsthumbnail",
|
if( (n = vips_enum_from_nick( "vipsthumbnail",
|
||||||
VIPS_TYPE_INTERESTING, smartcrop_image )) < 0 )
|
VIPS_TYPE_INTERESTING, smartcrop_image )) < 0 )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
interesting = n;
|
interesting = n;
|
||||||
}
|
}
|
||||||
|
intent = VIPS_INTENT_RELATIVE;
|
||||||
|
if( thumbnail_intent ) {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if( (n = vips_enum_from_nick( "vipsthumbnail",
|
||||||
|
VIPS_TYPE_INTENT, thumbnail_intent )) < 0 )
|
||||||
|
return( -1 );
|
||||||
|
intent = n;
|
||||||
|
}
|
||||||
|
|
||||||
if( vips_thumbnail( filename, &image, thumbnail_width,
|
if( vips_thumbnail( filename, &image, thumbnail_width,
|
||||||
"height", thumbnail_height,
|
"height", thumbnail_height,
|
||||||
@ -266,6 +283,7 @@ thumbnail_process( VipsObject *process, const char *filename )
|
|||||||
"linear", linear_processing,
|
"linear", linear_processing,
|
||||||
"import_profile", import_profile,
|
"import_profile", import_profile,
|
||||||
"export_profile", export_profile,
|
"export_profile", export_profile,
|
||||||
|
"intent", intent,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user