add fail-on to thumbnail
see https://github.com/libvips/libvips/discussions/2781
This commit is contained in:
parent
43db3985d0
commit
f06c9f3bcf
@ -18,6 +18,7 @@
|
|||||||
- update libnsgif API [tlsa]
|
- update libnsgif API [tlsa]
|
||||||
- deprecate "properties" option to dzsave (now always on)
|
- deprecate "properties" option to dzsave (now always on)
|
||||||
- always set the min stack size for pthreads, if we can
|
- always set the min stack size for pthreads, if we can
|
||||||
|
- add fail-on to thumbnail
|
||||||
|
|
||||||
26/11/21 started 8.12.3
|
26/11/21 started 8.12.3
|
||||||
- better arg checking for hist_find_ndim [travisbell]
|
- better arg checking for hist_find_ndim [travisbell]
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
* mode
|
* mode
|
||||||
* 14/4/22
|
* 14/4/22
|
||||||
* - add a seq to thumbnail_image to stop cache thrashing
|
* - add a seq to thumbnail_image to stop cache thrashing
|
||||||
|
* 28/4/22
|
||||||
|
* - add fail-on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -113,6 +115,7 @@ typedef struct _VipsThumbnail {
|
|||||||
char *export_profile;
|
char *export_profile;
|
||||||
char *import_profile;
|
char *import_profile;
|
||||||
VipsIntent intent;
|
VipsIntent intent;
|
||||||
|
VipsFailOn fail_on;
|
||||||
|
|
||||||
/* Bits of info we read from the input image when we get the header of
|
/* Bits of info we read from the input image when we get the header of
|
||||||
* the original.
|
* the original.
|
||||||
@ -1017,6 +1020,13 @@ vips_thumbnail_class_init( VipsThumbnailClass *class )
|
|||||||
G_STRUCT_OFFSET( VipsThumbnail, intent ),
|
G_STRUCT_OFFSET( VipsThumbnail, intent ),
|
||||||
VIPS_TYPE_INTENT, VIPS_INTENT_RELATIVE );
|
VIPS_TYPE_INTENT, VIPS_INTENT_RELATIVE );
|
||||||
|
|
||||||
|
VIPS_ARG_ENUM( class, "fail-on", 121,
|
||||||
|
_( "Fail on" ),
|
||||||
|
_( "Error level to fail on" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsThumbnail, fail_on ),
|
||||||
|
VIPS_TYPE_FAIL_ON, VIPS_FAIL_ON_NONE );
|
||||||
|
|
||||||
/* BOOL args which default TRUE arguments don't work with the
|
/* BOOL args which default TRUE arguments don't work with the
|
||||||
* command-line -- GOption does not allow --auto-rotate=false.
|
* command-line -- GOption does not allow --auto-rotate=false.
|
||||||
*
|
*
|
||||||
@ -1039,6 +1049,7 @@ vips_thumbnail_init( VipsThumbnail *thumbnail )
|
|||||||
thumbnail->height = 1;
|
thumbnail->height = 1;
|
||||||
thumbnail->auto_rotate = TRUE;
|
thumbnail->auto_rotate = TRUE;
|
||||||
thumbnail->intent = VIPS_INTENT_RELATIVE;
|
thumbnail->intent = VIPS_INTENT_RELATIVE;
|
||||||
|
thumbnail->fail_on = VIPS_FAIL_ON_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _VipsThumbnailFile {
|
typedef struct _VipsThumbnailFile {
|
||||||
@ -1084,6 +1095,7 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
|
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"shrink", (int) factor,
|
"shrink", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
@ -1091,6 +1103,7 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
thumbnail->loader ) ) {
|
thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"level", (int) factor,
|
"level", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
@ -1099,6 +1112,7 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
|
vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"scale", 1.0 / factor,
|
"scale", 1.0 / factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
@ -1108,6 +1122,7 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
if( thumbnail->page_pyramid )
|
if( thumbnail->page_pyramid )
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"page", (int) factor,
|
"page", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
else
|
else
|
||||||
@ -1122,27 +1137,32 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
if( thumbnail->subifd_pyramid )
|
if( thumbnail->subifd_pyramid )
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"subifd", (int) factor,
|
"subifd", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
else if( thumbnail->page_pyramid )
|
else if( thumbnail->page_pyramid )
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"page", (int) factor,
|
"page", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
else
|
else
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
else if( vips_isprefix( "VipsForeignLoadHeif", thumbnail->loader ) ) {
|
else if( vips_isprefix( "VipsForeignLoadHeif", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
"thumbnail", (int) factor,
|
"thumbnail", (int) factor,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"fail-on", thumbnail->fail_on,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1194,6 +1214,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
|||||||
* * @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
|
* * @intent: #VipsIntent, rendering intent
|
||||||
|
* * @fail_on: #VipsFailOn, load error types to fail on
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -1238,6 +1259,9 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
|||||||
* Use @intent to set the rendering intent for any ICC transform. The default
|
* Use @intent to set the rendering intent for any ICC transform. The default
|
||||||
* is #VIPS_INTENT_RELATIVE.
|
* is #VIPS_INTENT_RELATIVE.
|
||||||
*
|
*
|
||||||
|
* Use @fail_on to control the types of error that will cause loading to fail.
|
||||||
|
* The default is #VIPS_FAIL_ON_NONE, ie. thumbnail is permissive.
|
||||||
|
*
|
||||||
* See also: vips_thumbnail_buffer().
|
* See also: vips_thumbnail_buffer().
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
@ -1439,6 +1463,7 @@ vips_thumbnail_buffer_init( VipsThumbnailBuffer *buffer )
|
|||||||
* * @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
|
* * @intent: #VipsIntent, rendering intent
|
||||||
|
* * @fail_on: #VipsFailOn, load error types to fail on
|
||||||
* * @option_string: %gchararray, extra loader options
|
* * @option_string: %gchararray, extra loader options
|
||||||
*
|
*
|
||||||
* Exactly as vips_thumbnail(), but read from a memory buffer. One extra
|
* Exactly as vips_thumbnail(), but read from a memory buffer. One extra
|
||||||
@ -1652,6 +1677,7 @@ vips_thumbnail_source_init( VipsThumbnailSource *source )
|
|||||||
* * @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
|
* * @intent: #VipsIntent, rendering intent
|
||||||
|
* * @fail_on: #VipsFailOn, load error types to fail on
|
||||||
* * @option_string: %gchararray, extra loader options
|
* * @option_string: %gchararray, extra loader options
|
||||||
*
|
*
|
||||||
* Exactly as vips_thumbnail(), but read from a source. One extra
|
* Exactly as vips_thumbnail(), but read from a source. One extra
|
||||||
@ -1768,6 +1794,7 @@ vips_thumbnail_image_init( VipsThumbnailImage *image )
|
|||||||
* * @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
|
* * @intent: #VipsIntent, rendering intent
|
||||||
|
* * @fail_on: #VipsFailOn, load error types to fail on
|
||||||
*
|
*
|
||||||
* Exactly as vips_thumbnail(), but read from an existing image.
|
* Exactly as vips_thumbnail(), but read from an existing image.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user