add n/page params to webpload
and renumber all optional load args
This commit is contained in:
parent
23e13ea6ed
commit
e106e1d100
@ -52,11 +52,11 @@ webp2vips( const char *name, IMAGE *out, gboolean header_only )
|
||||
|
||||
#ifdef HAVE_LIBWEBP
|
||||
if( header_only ) {
|
||||
if( vips__webp_read_file_header( filename, out, 1 ) )
|
||||
if( vips__webp_read_file_header( filename, out, 0, 1, 1 ) )
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
if( vips__webp_read_file( filename, out, 1 ) )
|
||||
if( vips__webp_read_file( filename, out, 0, 1, 1 ) )
|
||||
return( -1 );
|
||||
}
|
||||
#else
|
||||
|
@ -144,28 +144,28 @@ vips_foreign_load_csv_class_init( VipsForeignLoadCsvClass *class )
|
||||
G_STRUCT_OFFSET( VipsForeignLoadCsv, filename ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_INT( class, "skip", 10,
|
||||
VIPS_ARG_INT( class, "skip", 20,
|
||||
_( "Skip" ),
|
||||
_( "Skip this many lines at the start of the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadCsv, skip ),
|
||||
0, 10000000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "lines", 11,
|
||||
VIPS_ARG_INT( class, "lines", 21,
|
||||
_( "Lines" ),
|
||||
_( "Read this many lines from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadCsv, lines ),
|
||||
-1, 10000000, 0 );
|
||||
|
||||
VIPS_ARG_STRING( class, "whitespace", 12,
|
||||
VIPS_ARG_STRING( class, "whitespace", 22,
|
||||
_( "Whitespace" ),
|
||||
_( "Set of whitespace characters" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadCsv, whitespace ),
|
||||
" " );
|
||||
|
||||
VIPS_ARG_STRING( class, "separator", 13,
|
||||
VIPS_ARG_STRING( class, "separator", 23,
|
||||
_( "Separator" ),
|
||||
_( "Set of separator characters" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -1028,42 +1028,42 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class )
|
||||
VIPS_ARGUMENT_REQUIRED_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, out ) );
|
||||
|
||||
VIPS_ARG_FLAGS( class, "flags", 6,
|
||||
VIPS_ARG_FLAGS( class, "flags", 106,
|
||||
_( "Flags" ),
|
||||
_( "Flags for this file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, flags ),
|
||||
VIPS_TYPE_FOREIGN_FLAGS, VIPS_FOREIGN_NONE );
|
||||
|
||||
VIPS_ARG_BOOL( class, "memory", 7,
|
||||
VIPS_ARG_BOOL( class, "memory", 107,
|
||||
_( "Memory" ),
|
||||
_( "Force open via memory" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, memory ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_ENUM( class, "access", 8,
|
||||
VIPS_ARG_ENUM( class, "access", 108,
|
||||
_( "Access" ),
|
||||
_( "Required access pattern for this file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, access ),
|
||||
VIPS_TYPE_ACCESS, VIPS_ACCESS_RANDOM );
|
||||
|
||||
VIPS_ARG_BOOL( class, "sequential", 10,
|
||||
VIPS_ARG_BOOL( class, "sequential", 109,
|
||||
_( "Sequential" ),
|
||||
_( "Sequential read only" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, sequential ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_BOOL( class, "fail", 11,
|
||||
VIPS_ARG_BOOL( class, "fail", 110,
|
||||
_( "Fail" ),
|
||||
_( "Fail on first error" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoad, fail ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_BOOL( class, "disc", 12,
|
||||
VIPS_ARG_BOOL( class, "disc", 111,
|
||||
_( "Disc" ),
|
||||
_( "Open to disc" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
|
||||
|
@ -1009,14 +1009,14 @@ vips_foreign_load_gif_class_init( VipsForeignLoadGifClass *class )
|
||||
vips_foreign_load_gif_get_flags_filename;
|
||||
load_class->get_flags = vips_foreign_load_gif_get_flags;
|
||||
|
||||
VIPS_ARG_INT( class, "page", 10,
|
||||
VIPS_ARG_INT( class, "page", 20,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadGif, page ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 6,
|
||||
VIPS_ARG_INT( class, "n", 21,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -133,14 +133,14 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
|
||||
|
||||
load_class->get_flags = vips_foreign_load_jpeg_get_flags;
|
||||
|
||||
VIPS_ARG_INT( class, "shrink", 10,
|
||||
VIPS_ARG_INT( class, "shrink", 20,
|
||||
_( "Shrink" ),
|
||||
_( "Shrink factor on load" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadJpeg, shrink ),
|
||||
1, 16, 1 );
|
||||
|
||||
VIPS_ARG_BOOL( class, "autorotate", 12,
|
||||
VIPS_ARG_BOOL( class, "autorotate", 21,
|
||||
_( "Autorotate" ),
|
||||
_( "Rotate image using exif orientation" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -357,28 +357,28 @@ vips_foreign_load_magick7_class_init( VipsForeignLoadMagick7Class *class )
|
||||
vips_foreign_load_magick7_get_flags_filename;
|
||||
load_class->get_flags = vips_foreign_load_magick7_get_flags;
|
||||
|
||||
VIPS_ARG_STRING( class, "density", 4,
|
||||
VIPS_ARG_STRING( class, "density", 20,
|
||||
_( "Density" ),
|
||||
_( "Canvas resolution for rendering vector formats like SVG" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick7, density ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_INT( class, "page", 5,
|
||||
VIPS_ARG_INT( class, "page", 21,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick7, page ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 6,
|
||||
VIPS_ARG_INT( class, "n", 22,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick7, n ),
|
||||
-1, 100000, 1 );
|
||||
|
||||
VIPS_ARG_BOOL( class, "all_frames", 7,
|
||||
VIPS_ARG_BOOL( class, "all_frames", 23,
|
||||
_( "all_frames" ),
|
||||
_( "Read all frames from an image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
|
||||
|
@ -122,28 +122,28 @@ vips_foreign_load_magick_class_init( VipsForeignLoadMagickClass *class )
|
||||
vips_foreign_load_magick_get_flags_filename;
|
||||
load_class->get_flags = vips_foreign_load_magick_get_flags;
|
||||
|
||||
VIPS_ARG_BOOL( class, "all_frames", 4,
|
||||
VIPS_ARG_BOOL( class, "all_frames", 20,
|
||||
_( "all_frames" ),
|
||||
_( "Read all frames from an image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick, all_frames ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_STRING( class, "density", 5,
|
||||
VIPS_ARG_STRING( class, "density", 21,
|
||||
_( "Density" ),
|
||||
_( "Canvas resolution for rendering vector formats like SVG" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick, density ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_INT( class, "page", 6,
|
||||
VIPS_ARG_INT( class, "page", 22,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadMagick, page ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 7,
|
||||
VIPS_ARG_INT( class, "n", 23,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -190,21 +190,21 @@ vips_foreign_load_openslide_class_init( VipsForeignLoadOpenslideClass *class )
|
||||
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, filename ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_INT( class, "level", 10,
|
||||
VIPS_ARG_INT( class, "level", 20,
|
||||
_( "Level" ),
|
||||
_( "Load this level from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, level ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_BOOL( class, "autocrop", 11,
|
||||
VIPS_ARG_BOOL( class, "autocrop", 21,
|
||||
_( "Autocrop" ),
|
||||
_( "Crop to image bounds" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, autocrop ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_STRING( class, "associated", 12,
|
||||
VIPS_ARG_STRING( class, "associated", 22,
|
||||
_( "Associated" ),
|
||||
_( "Load this associated image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -467,35 +467,35 @@ vips_foreign_load_pdf_class_init( VipsForeignLoadPdfClass *class )
|
||||
load_class->get_flags = vips_foreign_load_pdf_get_flags;
|
||||
load_class->load = vips_foreign_load_pdf_load;
|
||||
|
||||
VIPS_ARG_INT( class, "page", 10,
|
||||
VIPS_ARG_INT( class, "page", 20,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadPdf, page_no ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 11,
|
||||
VIPS_ARG_INT( class, "n", 21,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadPdf, n ),
|
||||
-1, 100000, 1 );
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "dpi", 12,
|
||||
VIPS_ARG_DOUBLE( class, "dpi", 22,
|
||||
_( "DPI" ),
|
||||
_( "Render at this DPI" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadPdf, dpi ),
|
||||
0.001, 100000.0, 72.0 );
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "scale", 13,
|
||||
VIPS_ARG_DOUBLE( class, "scale", 23,
|
||||
_( "Scale" ),
|
||||
_( "Scale output by this factor" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadPdf, scale ),
|
||||
0.001, 100000.0, 1.0 );
|
||||
|
||||
VIPS_ARG_BOXED( class, "background", 14,
|
||||
VIPS_ARG_BOXED( class, "background", 24,
|
||||
_( "Background" ),
|
||||
_( "Background value" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -228,24 +228,24 @@ extern const char *vips__webp_suffs[];
|
||||
int vips__iswebp_buffer( const void *buf, size_t len );
|
||||
int vips__iswebp( const char *filename );
|
||||
|
||||
int vips__webp_read_file_header( const char *name, VipsImage *out, int shrink );
|
||||
int vips__webp_read_file( const char *name, VipsImage *out, int shrink );
|
||||
int vips__webp_read_file_header( const char *name, VipsImage *out,
|
||||
int page, int n, int shrink );
|
||||
int vips__webp_read_file( const char *name, VipsImage *out,
|
||||
int page, int n, int shrink );
|
||||
|
||||
int vips__webp_read_buffer_header( const void *buf, size_t len,
|
||||
VipsImage *out, int shrink );
|
||||
int vips__webp_read_buffer( const void *buf, size_t len,
|
||||
VipsImage *out, int shrink );
|
||||
int vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
|
||||
int page, int n, int shrink );
|
||||
int vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out,
|
||||
int page, int n, int shrink );
|
||||
|
||||
int vips__webp_write_file( VipsImage *out, const char *filename,
|
||||
int Q, gboolean lossless, VipsForeignWebpPreset preset,
|
||||
gboolean smart_subsample, gboolean near_lossless,
|
||||
int alpha_q,
|
||||
gboolean strip );
|
||||
int alpha_q, gboolean strip );
|
||||
int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len,
|
||||
int Q, gboolean lossless, VipsForeignWebpPreset preset,
|
||||
gboolean smart_subsample, gboolean near_lossless,
|
||||
int alpha_q,
|
||||
gboolean strip );
|
||||
int alpha_q, gboolean strip );
|
||||
|
||||
int vips__openslide_isslide( const char *filename );
|
||||
int vips__openslide_read_header( const char *filename, VipsImage *out,
|
||||
|
@ -119,28 +119,28 @@ vips_foreign_load_raw_class_init( VipsForeignLoadRawClass *class )
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, filename ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_INT( class, "width", 10,
|
||||
VIPS_ARG_INT( class, "width", 20,
|
||||
_( "Width" ),
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, width ),
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 11,
|
||||
VIPS_ARG_INT( class, "height", 21,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, height ),
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "bands", 12,
|
||||
VIPS_ARG_INT( class, "bands", 22,
|
||||
_( "Bands" ),
|
||||
_( "Number of bands in image" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, bands ),
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_UINT64( class, "offset", 13,
|
||||
VIPS_ARG_UINT64( class, "offset", 23,
|
||||
_( "Size of header" ),
|
||||
_( "Offset in bytes from start of file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -425,14 +425,14 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class )
|
||||
load_class->get_flags = vips_foreign_load_svg_get_flags;
|
||||
load_class->load = vips_foreign_load_svg_load;
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "dpi", 11,
|
||||
VIPS_ARG_DOUBLE( class, "dpi", 21,
|
||||
_( "DPI" ),
|
||||
_( "Render at this DPI" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadSvg, dpi ),
|
||||
0.001, 100000.0, 72.0 );
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "scale", 12,
|
||||
VIPS_ARG_DOUBLE( class, "scale", 22,
|
||||
_( "Scale" ),
|
||||
_( "Scale output by this factor" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -95,21 +95,21 @@ vips_foreign_load_tiff_class_init( VipsForeignLoadTiffClass *class )
|
||||
object_class->nickname = "tiffload_base";
|
||||
object_class->description = _( "load tiff" );
|
||||
|
||||
VIPS_ARG_INT( class, "page", 10,
|
||||
VIPS_ARG_INT( class, "page", 20,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadTiff, page ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 11,
|
||||
VIPS_ARG_INT( class, "n", 21,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadTiff, n ),
|
||||
-1, 100000, 1 );
|
||||
|
||||
VIPS_ARG_BOOL( class, "autorotate", 12,
|
||||
VIPS_ARG_BOOL( class, "autorotate", 22,
|
||||
_( "Autorotate" ),
|
||||
_( "Rotate image using orientation tag" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
|
@ -75,6 +75,14 @@ typedef struct {
|
||||
const void *data;
|
||||
gint64 length;
|
||||
|
||||
/* Load this page (frame number).
|
||||
*/
|
||||
int page;
|
||||
|
||||
/* Load this many pages.
|
||||
*/
|
||||
int n;
|
||||
|
||||
/* Shrink-on-load factor. Use this to set scaled_width.
|
||||
*/
|
||||
int shrink;
|
||||
@ -146,7 +154,8 @@ read_free( Read *read )
|
||||
}
|
||||
|
||||
static Read *
|
||||
read_new( const char *filename, const void *data, size_t length, int shrink )
|
||||
read_new( const char *filename, const void *data, size_t length,
|
||||
int page, int n, int shrink )
|
||||
{
|
||||
Read *read;
|
||||
|
||||
@ -156,6 +165,8 @@ read_new( const char *filename, const void *data, size_t length, int shrink )
|
||||
read->filename = g_strdup( filename );
|
||||
read->data = data;
|
||||
read->length = length;
|
||||
read->page = page;
|
||||
read->n = n;
|
||||
read->shrink = shrink;
|
||||
read->fd = 0;
|
||||
read->idec = NULL;
|
||||
@ -274,11 +285,12 @@ read_header( Read *read, VipsImage *out )
|
||||
}
|
||||
|
||||
int
|
||||
vips__webp_read_file_header( const char *filename, VipsImage *out, int shrink )
|
||||
vips__webp_read_file_header( const char *filename, VipsImage *out,
|
||||
int page, int n, int shrink )
|
||||
{
|
||||
Read *read;
|
||||
|
||||
if( !(read = read_new( filename, NULL, 0, shrink )) ) {
|
||||
if( !(read = read_new( filename, NULL, 0, page, n, shrink )) ) {
|
||||
vips_error( "webp2vips",
|
||||
_( "unable to open \"%s\"" ), filename );
|
||||
return( -1 );
|
||||
@ -324,11 +336,12 @@ read_image( Read *read, VipsImage *out )
|
||||
}
|
||||
|
||||
int
|
||||
vips__webp_read_file( const char *filename, VipsImage *out, int shrink )
|
||||
vips__webp_read_file( const char *filename, VipsImage *out,
|
||||
int page, int n, int shrink )
|
||||
{
|
||||
Read *read;
|
||||
|
||||
if( !(read = read_new( filename, NULL, 0, shrink )) ) {
|
||||
if( !(read = read_new( filename, NULL, 0, page, n, shrink )) ) {
|
||||
vips_error( "webp2vips",
|
||||
_( "unable to open \"%s\"" ), filename );
|
||||
return( -1 );
|
||||
@ -344,11 +357,11 @@ vips__webp_read_file( const char *filename, VipsImage *out, int shrink )
|
||||
|
||||
int
|
||||
vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
|
||||
int shrink )
|
||||
int page, int n, int shrink )
|
||||
{
|
||||
Read *read;
|
||||
|
||||
if( !(read = read_new( NULL, buf, len, shrink )) ) {
|
||||
if( !(read = read_new( NULL, buf, len, page, n, shrink )) ) {
|
||||
vips_error( "webp2vips",
|
||||
"%s", _( "unable to open buffer" ) );
|
||||
return( -1 );
|
||||
@ -366,11 +379,11 @@ vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
|
||||
|
||||
int
|
||||
vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out,
|
||||
int shrink )
|
||||
int page, int n, int shrink )
|
||||
{
|
||||
Read *read;
|
||||
|
||||
if( !(read = read_new( NULL, buf, len, shrink )) ) {
|
||||
if( !(read = read_new( NULL, buf, len, page, n, shrink )) ) {
|
||||
vips_error( "webp2vips",
|
||||
"%s", _( "unable to open buffer" ) );
|
||||
return( -1 );
|
||||
|
@ -4,6 +4,8 @@
|
||||
* - from pngload.c
|
||||
* 28/2/16
|
||||
* - add @shrink
|
||||
* 1/11/18
|
||||
* - add @page, @n
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -54,6 +56,14 @@
|
||||
typedef struct _VipsForeignLoadWebp {
|
||||
VipsForeignLoad parent_object;
|
||||
|
||||
/* Load this page (frame number).
|
||||
*/
|
||||
int page;
|
||||
|
||||
/* Load this many pages.
|
||||
*/
|
||||
int n;
|
||||
|
||||
/* Shrink by this much during load.
|
||||
*/
|
||||
int shrink;
|
||||
@ -96,7 +106,21 @@ vips_foreign_load_webp_class_init( VipsForeignLoadWebpClass *class )
|
||||
|
||||
load_class->get_flags = vips_foreign_load_webp_get_flags;
|
||||
|
||||
VIPS_ARG_INT( class, "shrink", 10,
|
||||
VIPS_ARG_INT( class, "page", 20,
|
||||
_( "Page" ),
|
||||
_( "Load this page from the file" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadWebp, page ),
|
||||
0, 100000, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "n", 21,
|
||||
_( "n" ),
|
||||
_( "Load this many pages" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadWebp, n ),
|
||||
-1, 100000, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "shrink", 22,
|
||||
_( "Shrink" ),
|
||||
_( "Shrink factor on load" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
@ -108,6 +132,7 @@ vips_foreign_load_webp_class_init( VipsForeignLoadWebpClass *class )
|
||||
static void
|
||||
vips_foreign_load_webp_init( VipsForeignLoadWebp *webp )
|
||||
{
|
||||
webp->n = 1;
|
||||
webp->shrink = 1;
|
||||
}
|
||||
|
||||
@ -144,7 +169,7 @@ vips_foreign_load_webp_file_header( VipsForeignLoad *load )
|
||||
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
||||
|
||||
if( vips__webp_read_file_header( file->filename, load->out,
|
||||
webp->shrink ) )
|
||||
webp->page, webp->n, webp->shrink ) )
|
||||
return( -1 );
|
||||
|
||||
VIPS_SETSTR( load->out->filename, file->filename );
|
||||
@ -158,7 +183,8 @@ vips_foreign_load_webp_file_load( VipsForeignLoad *load )
|
||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
||||
|
||||
if( vips__webp_read_file( file->filename, load->real, webp->shrink ) )
|
||||
if( vips__webp_read_file( file->filename, load->real,
|
||||
webp->page, webp->n, webp->shrink ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
@ -222,7 +248,8 @@ vips_foreign_load_webp_buffer_header( VipsForeignLoad *load )
|
||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||
|
||||
if( vips__webp_read_buffer_header( buffer->buf->data,
|
||||
buffer->buf->length, load->out, webp->shrink ) )
|
||||
buffer->buf->length, load->out,
|
||||
webp->page, webp->n, webp->shrink ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
@ -235,7 +262,8 @@ vips_foreign_load_webp_buffer_load( VipsForeignLoad *load )
|
||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||
|
||||
if( vips__webp_read_buffer( buffer->buf->data, buffer->buf->length,
|
||||
load->real, webp->shrink ) )
|
||||
load->real,
|
||||
webp->page, webp->n, webp->shrink ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
@ -287,14 +315,22 @@ vips_foreign_load_webp_buffer_init( VipsForeignLoadWebpBuffer *buffer )
|
||||
*
|
||||
* Optional arguments:
|
||||
*
|
||||
* * @page: %gint, page (frame) to read
|
||||
* * @n: %gint, load this many pages
|
||||
* * @shrink: %gint, shrink by this much on load
|
||||
*
|
||||
* Read a WebP file into a VIPS image.
|
||||
*
|
||||
* Use @page to select a page to render, numbering from zero.
|
||||
*
|
||||
* Use @n to select the number of pages to render. The default is 1. Pages are
|
||||
* rendered in a vertical column, with each individual page aligned to the
|
||||
* left. Set to -1 to mean "until the end of the document". Use vips_grid()
|
||||
* to change page layout.
|
||||
*
|
||||
* Use @shrink to specify a shrink-on-load factor.
|
||||
*
|
||||
* If libwebpmux is available, image metadata is also read. The loader supports
|
||||
* ICC, EXIF and XMP metadata.
|
||||
* The loader supports ICC, EXIF and XMP metadata.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
@ -322,6 +358,8 @@ vips_webpload( const char *filename, VipsImage **out, ... )
|
||||
*
|
||||
* Optional arguments:
|
||||
*
|
||||
* * @page: %gint, page (frame) to read
|
||||
* * @n: %gint, load this many pages
|
||||
* * @shrink: %gint, shrink by this much on load
|
||||
*
|
||||
* Read a WebP-formatted memory block into a VIPS image. Exactly as
|
||||
|
Loading…
Reference in New Issue
Block a user