vips_thumbnail_buffer: add optional open_args argument (#1147)

This commit is contained in:
kleisauke 2019-02-02 09:26:12 +01:00
parent 097bb815b7
commit 05c459cc28

View File

@ -983,6 +983,7 @@ typedef struct _VipsThumbnailBuffer {
VipsThumbnail parent_object; VipsThumbnail parent_object;
VipsArea *buf; VipsArea *buf;
char *open_args;
} VipsThumbnailBuffer; } VipsThumbnailBuffer;
typedef VipsThumbnailClass VipsThumbnailBufferClass; typedef VipsThumbnailClass VipsThumbnailBufferClass;
@ -1004,7 +1005,7 @@ vips_thumbnail_buffer_get_info( VipsThumbnail *thumbnail )
if( !(thumbnail->loader = vips_foreign_find_load_buffer( if( !(thumbnail->loader = vips_foreign_find_load_buffer(
buffer->buf->data, buffer->buf->length )) || buffer->buf->data, buffer->buf->length )) ||
!(image = vips_image_new_from_buffer( !(image = vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", NULL )) ) buffer->buf->data, buffer->buf->length, buffer->open_args, NULL )) )
return( -1 ); return( -1 );
vips_thumbnail_read_header( thumbnail, image ); vips_thumbnail_read_header( thumbnail, image );
@ -1023,7 +1024,7 @@ vips_thumbnail_buffer_open( VipsThumbnail *thumbnail, double factor )
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) { if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
return( vips_image_new_from_buffer( return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", buffer->buf->data, buffer->buf->length, buffer->open_args,
"access", VIPS_ACCESS_SEQUENTIAL, "access", VIPS_ACCESS_SEQUENTIAL,
"shrink", (int) factor, "shrink", (int) factor,
NULL ) ); NULL ) );
@ -1031,7 +1032,7 @@ vips_thumbnail_buffer_open( VipsThumbnail *thumbnail, double factor )
else if( vips_isprefix( "VipsForeignLoadOpenslide", else if( vips_isprefix( "VipsForeignLoadOpenslide",
thumbnail->loader ) ) { thumbnail->loader ) ) {
return( vips_image_new_from_buffer( return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", buffer->buf->data, buffer->buf->length, buffer->open_args,
"access", VIPS_ACCESS_SEQUENTIAL, "access", VIPS_ACCESS_SEQUENTIAL,
"level", (int) factor, "level", (int) factor,
NULL ) ); NULL ) );
@ -1040,21 +1041,21 @@ vips_thumbnail_buffer_open( VipsThumbnail *thumbnail, double factor )
vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) || vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ||
vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) { vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
return( vips_image_new_from_buffer( return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", buffer->buf->data, buffer->buf->length, buffer->open_args,
"access", VIPS_ACCESS_SEQUENTIAL, "access", VIPS_ACCESS_SEQUENTIAL,
"scale", factor, "scale", factor,
NULL ) ); NULL ) );
} }
else if( vips_isprefix( "VipsForeignLoadTiff", thumbnail->loader ) ) { else if( vips_isprefix( "VipsForeignLoadTiff", thumbnail->loader ) ) {
return( vips_image_new_from_buffer( return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", buffer->buf->data, buffer->buf->length, buffer->open_args,
"access", VIPS_ACCESS_SEQUENTIAL, "access", VIPS_ACCESS_SEQUENTIAL,
"page", (int) factor, "page", (int) factor,
NULL ) ); NULL ) );
} }
else { else {
return( vips_image_new_from_buffer( return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "", buffer->buf->data, buffer->buf->length, buffer->open_args,
"access", VIPS_ACCESS_SEQUENTIAL, "access", VIPS_ACCESS_SEQUENTIAL,
NULL ) ); NULL ) );
} }
@ -1083,6 +1084,12 @@ vips_thumbnail_buffer_class_init( VipsThumbnailClass *class )
G_STRUCT_OFFSET( VipsThumbnailBuffer, buf ), G_STRUCT_OFFSET( VipsThumbnailBuffer, buf ),
VIPS_TYPE_BLOB ); VIPS_TYPE_BLOB );
VIPS_ARG_STRING( class, "open_args", 20,
_( "Open arguments" ),
_( "Arguments that are passed on to the underlying loader" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsThumbnailBuffer, open_args ),
"" );
} }
static void static void