add n/page params to webpload

and renumber all optional load args
This commit is contained in:
John Cupitt 2018-11-01 20:43:07 +00:00
parent 23e13ea6ed
commit e106e1d100
15 changed files with 118 additions and 67 deletions

View File

@ -52,11 +52,11 @@ webp2vips( const char *name, IMAGE *out, gboolean header_only )
#ifdef HAVE_LIBWEBP #ifdef HAVE_LIBWEBP
if( header_only ) { 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 ); return( -1 );
} }
else { else {
if( vips__webp_read_file( filename, out, 1 ) ) if( vips__webp_read_file( filename, out, 0, 1, 1 ) )
return( -1 ); return( -1 );
} }
#else #else

View File

@ -144,28 +144,28 @@ vips_foreign_load_csv_class_init( VipsForeignLoadCsvClass *class )
G_STRUCT_OFFSET( VipsForeignLoadCsv, filename ), G_STRUCT_OFFSET( VipsForeignLoadCsv, filename ),
NULL ); NULL );
VIPS_ARG_INT( class, "skip", 10, VIPS_ARG_INT( class, "skip", 20,
_( "Skip" ), _( "Skip" ),
_( "Skip this many lines at the start of the file" ), _( "Skip this many lines at the start of the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadCsv, skip ), G_STRUCT_OFFSET( VipsForeignLoadCsv, skip ),
0, 10000000, 0 ); 0, 10000000, 0 );
VIPS_ARG_INT( class, "lines", 11, VIPS_ARG_INT( class, "lines", 21,
_( "Lines" ), _( "Lines" ),
_( "Read this many lines from the file" ), _( "Read this many lines from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadCsv, lines ), G_STRUCT_OFFSET( VipsForeignLoadCsv, lines ),
-1, 10000000, 0 ); -1, 10000000, 0 );
VIPS_ARG_STRING( class, "whitespace", 12, VIPS_ARG_STRING( class, "whitespace", 22,
_( "Whitespace" ), _( "Whitespace" ),
_( "Set of whitespace characters" ), _( "Set of whitespace characters" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadCsv, whitespace ), G_STRUCT_OFFSET( VipsForeignLoadCsv, whitespace ),
" " ); " " );
VIPS_ARG_STRING( class, "separator", 13, VIPS_ARG_STRING( class, "separator", 23,
_( "Separator" ), _( "Separator" ),
_( "Set of separator characters" ), _( "Set of separator characters" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -1028,42 +1028,42 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class )
VIPS_ARGUMENT_REQUIRED_OUTPUT, VIPS_ARGUMENT_REQUIRED_OUTPUT,
G_STRUCT_OFFSET( VipsForeignLoad, out ) ); G_STRUCT_OFFSET( VipsForeignLoad, out ) );
VIPS_ARG_FLAGS( class, "flags", 6, VIPS_ARG_FLAGS( class, "flags", 106,
_( "Flags" ), _( "Flags" ),
_( "Flags for this file" ), _( "Flags for this file" ),
VIPS_ARGUMENT_OPTIONAL_OUTPUT, VIPS_ARGUMENT_OPTIONAL_OUTPUT,
G_STRUCT_OFFSET( VipsForeignLoad, flags ), G_STRUCT_OFFSET( VipsForeignLoad, flags ),
VIPS_TYPE_FOREIGN_FLAGS, VIPS_FOREIGN_NONE ); VIPS_TYPE_FOREIGN_FLAGS, VIPS_FOREIGN_NONE );
VIPS_ARG_BOOL( class, "memory", 7, VIPS_ARG_BOOL( class, "memory", 107,
_( "Memory" ), _( "Memory" ),
_( "Force open via memory" ), _( "Force open via memory" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoad, memory ), G_STRUCT_OFFSET( VipsForeignLoad, memory ),
FALSE ); FALSE );
VIPS_ARG_ENUM( class, "access", 8, VIPS_ARG_ENUM( class, "access", 108,
_( "Access" ), _( "Access" ),
_( "Required access pattern for this file" ), _( "Required access pattern for this file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoad, access ), G_STRUCT_OFFSET( VipsForeignLoad, access ),
VIPS_TYPE_ACCESS, VIPS_ACCESS_RANDOM ); VIPS_TYPE_ACCESS, VIPS_ACCESS_RANDOM );
VIPS_ARG_BOOL( class, "sequential", 10, VIPS_ARG_BOOL( class, "sequential", 109,
_( "Sequential" ), _( "Sequential" ),
_( "Sequential read only" ), _( "Sequential read only" ),
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
G_STRUCT_OFFSET( VipsForeignLoad, sequential ), G_STRUCT_OFFSET( VipsForeignLoad, sequential ),
FALSE ); FALSE );
VIPS_ARG_BOOL( class, "fail", 11, VIPS_ARG_BOOL( class, "fail", 110,
_( "Fail" ), _( "Fail" ),
_( "Fail on first error" ), _( "Fail on first error" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoad, fail ), G_STRUCT_OFFSET( VipsForeignLoad, fail ),
FALSE ); FALSE );
VIPS_ARG_BOOL( class, "disc", 12, VIPS_ARG_BOOL( class, "disc", 111,
_( "Disc" ), _( "Disc" ),
_( "Open to disc" ), _( "Open to disc" ),
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,

View File

@ -1009,14 +1009,14 @@ vips_foreign_load_gif_class_init( VipsForeignLoadGifClass *class )
vips_foreign_load_gif_get_flags_filename; vips_foreign_load_gif_get_flags_filename;
load_class->get_flags = vips_foreign_load_gif_get_flags; load_class->get_flags = vips_foreign_load_gif_get_flags;
VIPS_ARG_INT( class, "page", 10, VIPS_ARG_INT( class, "page", 20,
_( "Page" ), _( "Page" ),
_( "Load this page from the file" ), _( "Load this page from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadGif, page ), G_STRUCT_OFFSET( VipsForeignLoadGif, page ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_INT( class, "n", 6, VIPS_ARG_INT( class, "n", 21,
_( "n" ), _( "n" ),
_( "Load this many pages" ), _( "Load this many pages" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -133,14 +133,14 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
load_class->get_flags = vips_foreign_load_jpeg_get_flags; load_class->get_flags = vips_foreign_load_jpeg_get_flags;
VIPS_ARG_INT( class, "shrink", 10, VIPS_ARG_INT( class, "shrink", 20,
_( "Shrink" ), _( "Shrink" ),
_( "Shrink factor on load" ), _( "Shrink factor on load" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadJpeg, shrink ), G_STRUCT_OFFSET( VipsForeignLoadJpeg, shrink ),
1, 16, 1 ); 1, 16, 1 );
VIPS_ARG_BOOL( class, "autorotate", 12, VIPS_ARG_BOOL( class, "autorotate", 21,
_( "Autorotate" ), _( "Autorotate" ),
_( "Rotate image using exif orientation" ), _( "Rotate image using exif orientation" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -357,28 +357,28 @@ vips_foreign_load_magick7_class_init( VipsForeignLoadMagick7Class *class )
vips_foreign_load_magick7_get_flags_filename; vips_foreign_load_magick7_get_flags_filename;
load_class->get_flags = vips_foreign_load_magick7_get_flags; load_class->get_flags = vips_foreign_load_magick7_get_flags;
VIPS_ARG_STRING( class, "density", 4, VIPS_ARG_STRING( class, "density", 20,
_( "Density" ), _( "Density" ),
_( "Canvas resolution for rendering vector formats like SVG" ), _( "Canvas resolution for rendering vector formats like SVG" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadMagick7, density ), G_STRUCT_OFFSET( VipsForeignLoadMagick7, density ),
NULL ); NULL );
VIPS_ARG_INT( class, "page", 5, VIPS_ARG_INT( class, "page", 21,
_( "Page" ), _( "Page" ),
_( "Load this page from the file" ), _( "Load this page from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadMagick7, page ), G_STRUCT_OFFSET( VipsForeignLoadMagick7, page ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_INT( class, "n", 6, VIPS_ARG_INT( class, "n", 22,
_( "n" ), _( "n" ),
_( "Load this many pages" ), _( "Load this many pages" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadMagick7, n ), G_STRUCT_OFFSET( VipsForeignLoadMagick7, n ),
-1, 100000, 1 ); -1, 100000, 1 );
VIPS_ARG_BOOL( class, "all_frames", 7, VIPS_ARG_BOOL( class, "all_frames", 23,
_( "all_frames" ), _( "all_frames" ),
_( "Read all frames from an image" ), _( "Read all frames from an image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,

View File

@ -122,28 +122,28 @@ vips_foreign_load_magick_class_init( VipsForeignLoadMagickClass *class )
vips_foreign_load_magick_get_flags_filename; vips_foreign_load_magick_get_flags_filename;
load_class->get_flags = vips_foreign_load_magick_get_flags; 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" ), _( "all_frames" ),
_( "Read all frames from an image" ), _( "Read all frames from an image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
G_STRUCT_OFFSET( VipsForeignLoadMagick, all_frames ), G_STRUCT_OFFSET( VipsForeignLoadMagick, all_frames ),
FALSE ); FALSE );
VIPS_ARG_STRING( class, "density", 5, VIPS_ARG_STRING( class, "density", 21,
_( "Density" ), _( "Density" ),
_( "Canvas resolution for rendering vector formats like SVG" ), _( "Canvas resolution for rendering vector formats like SVG" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadMagick, density ), G_STRUCT_OFFSET( VipsForeignLoadMagick, density ),
NULL ); NULL );
VIPS_ARG_INT( class, "page", 6, VIPS_ARG_INT( class, "page", 22,
_( "Page" ), _( "Page" ),
_( "Load this page from the file" ), _( "Load this page from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadMagick, page ), G_STRUCT_OFFSET( VipsForeignLoadMagick, page ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_INT( class, "n", 7, VIPS_ARG_INT( class, "n", 23,
_( "n" ), _( "n" ),
_( "Load this many pages" ), _( "Load this many pages" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -190,21 +190,21 @@ vips_foreign_load_openslide_class_init( VipsForeignLoadOpenslideClass *class )
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, filename ), G_STRUCT_OFFSET( VipsForeignLoadOpenslide, filename ),
NULL ); NULL );
VIPS_ARG_INT( class, "level", 10, VIPS_ARG_INT( class, "level", 20,
_( "Level" ), _( "Level" ),
_( "Load this level from the file" ), _( "Load this level from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, level ), G_STRUCT_OFFSET( VipsForeignLoadOpenslide, level ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_BOOL( class, "autocrop", 11, VIPS_ARG_BOOL( class, "autocrop", 21,
_( "Autocrop" ), _( "Autocrop" ),
_( "Crop to image bounds" ), _( "Crop to image bounds" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, autocrop ), G_STRUCT_OFFSET( VipsForeignLoadOpenslide, autocrop ),
FALSE ); FALSE );
VIPS_ARG_STRING( class, "associated", 12, VIPS_ARG_STRING( class, "associated", 22,
_( "Associated" ), _( "Associated" ),
_( "Load this associated image" ), _( "Load this associated image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -467,35 +467,35 @@ vips_foreign_load_pdf_class_init( VipsForeignLoadPdfClass *class )
load_class->get_flags = vips_foreign_load_pdf_get_flags; load_class->get_flags = vips_foreign_load_pdf_get_flags;
load_class->load = vips_foreign_load_pdf_load; load_class->load = vips_foreign_load_pdf_load;
VIPS_ARG_INT( class, "page", 10, VIPS_ARG_INT( class, "page", 20,
_( "Page" ), _( "Page" ),
_( "Load this page from the file" ), _( "Load this page from the file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadPdf, page_no ), G_STRUCT_OFFSET( VipsForeignLoadPdf, page_no ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_INT( class, "n", 11, VIPS_ARG_INT( class, "n", 21,
_( "n" ), _( "n" ),
_( "Load this many pages" ), _( "Load this many pages" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadPdf, n ), G_STRUCT_OFFSET( VipsForeignLoadPdf, n ),
-1, 100000, 1 ); -1, 100000, 1 );
VIPS_ARG_DOUBLE( class, "dpi", 12, VIPS_ARG_DOUBLE( class, "dpi", 22,
_( "DPI" ), _( "DPI" ),
_( "Render at this DPI" ), _( "Render at this DPI" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadPdf, dpi ), G_STRUCT_OFFSET( VipsForeignLoadPdf, dpi ),
0.001, 100000.0, 72.0 ); 0.001, 100000.0, 72.0 );
VIPS_ARG_DOUBLE( class, "scale", 13, VIPS_ARG_DOUBLE( class, "scale", 23,
_( "Scale" ), _( "Scale" ),
_( "Scale output by this factor" ), _( "Scale output by this factor" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadPdf, scale ), G_STRUCT_OFFSET( VipsForeignLoadPdf, scale ),
0.001, 100000.0, 1.0 ); 0.001, 100000.0, 1.0 );
VIPS_ARG_BOXED( class, "background", 14, VIPS_ARG_BOXED( class, "background", 24,
_( "Background" ), _( "Background" ),
_( "Background value" ), _( "Background value" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -228,24 +228,24 @@ extern const char *vips__webp_suffs[];
int vips__iswebp_buffer( const void *buf, size_t len ); int vips__iswebp_buffer( const void *buf, size_t len );
int vips__iswebp( const char *filename ); int vips__iswebp( const char *filename );
int vips__webp_read_file_header( const char *name, VipsImage *out, int shrink ); int vips__webp_read_file_header( const char *name, VipsImage *out,
int vips__webp_read_file( const char *name, VipsImage *out, int shrink ); 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, int vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
VipsImage *out, int shrink ); int page, int n, int shrink );
int vips__webp_read_buffer( const void *buf, size_t len, int vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out,
VipsImage *out, int shrink ); int page, int n, int shrink );
int vips__webp_write_file( VipsImage *out, const char *filename, int vips__webp_write_file( VipsImage *out, const char *filename,
int Q, gboolean lossless, VipsForeignWebpPreset preset, int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless, gboolean smart_subsample, gboolean near_lossless,
int alpha_q, int alpha_q, gboolean strip );
gboolean strip );
int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len, int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len,
int Q, gboolean lossless, VipsForeignWebpPreset preset, int Q, gboolean lossless, VipsForeignWebpPreset preset,
gboolean smart_subsample, gboolean near_lossless, gboolean smart_subsample, gboolean near_lossless,
int alpha_q, int alpha_q, gboolean strip );
gboolean strip );
int vips__openslide_isslide( const char *filename ); int vips__openslide_isslide( const char *filename );
int vips__openslide_read_header( const char *filename, VipsImage *out, int vips__openslide_read_header( const char *filename, VipsImage *out,

View File

@ -119,28 +119,28 @@ vips_foreign_load_raw_class_init( VipsForeignLoadRawClass *class )
G_STRUCT_OFFSET( VipsForeignLoadRaw, filename ), G_STRUCT_OFFSET( VipsForeignLoadRaw, filename ),
NULL ); NULL );
VIPS_ARG_INT( class, "width", 10, VIPS_ARG_INT( class, "width", 20,
_( "Width" ), _( "Width" ),
_( "Image width in pixels" ), _( "Image width in pixels" ),
VIPS_ARGUMENT_REQUIRED_INPUT, VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadRaw, width ), G_STRUCT_OFFSET( VipsForeignLoadRaw, width ),
0, VIPS_MAX_COORD, 0 ); 0, VIPS_MAX_COORD, 0 );
VIPS_ARG_INT( class, "height", 11, VIPS_ARG_INT( class, "height", 21,
_( "Height" ), _( "Height" ),
_( "Image height in pixels" ), _( "Image height in pixels" ),
VIPS_ARGUMENT_REQUIRED_INPUT, VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadRaw, height ), G_STRUCT_OFFSET( VipsForeignLoadRaw, height ),
0, VIPS_MAX_COORD, 0 ); 0, VIPS_MAX_COORD, 0 );
VIPS_ARG_INT( class, "bands", 12, VIPS_ARG_INT( class, "bands", 22,
_( "Bands" ), _( "Bands" ),
_( "Number of bands in image" ), _( "Number of bands in image" ),
VIPS_ARGUMENT_REQUIRED_INPUT, VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadRaw, bands ), G_STRUCT_OFFSET( VipsForeignLoadRaw, bands ),
0, VIPS_MAX_COORD, 0 ); 0, VIPS_MAX_COORD, 0 );
VIPS_ARG_UINT64( class, "offset", 13, VIPS_ARG_UINT64( class, "offset", 23,
_( "Size of header" ), _( "Size of header" ),
_( "Offset in bytes from start of file" ), _( "Offset in bytes from start of file" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -425,14 +425,14 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class )
load_class->get_flags = vips_foreign_load_svg_get_flags; load_class->get_flags = vips_foreign_load_svg_get_flags;
load_class->load = vips_foreign_load_svg_load; load_class->load = vips_foreign_load_svg_load;
VIPS_ARG_DOUBLE( class, "dpi", 11, VIPS_ARG_DOUBLE( class, "dpi", 21,
_( "DPI" ), _( "DPI" ),
_( "Render at this DPI" ), _( "Render at this DPI" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadSvg, dpi ), G_STRUCT_OFFSET( VipsForeignLoadSvg, dpi ),
0.001, 100000.0, 72.0 ); 0.001, 100000.0, 72.0 );
VIPS_ARG_DOUBLE( class, "scale", 12, VIPS_ARG_DOUBLE( class, "scale", 22,
_( "Scale" ), _( "Scale" ),
_( "Scale output by this factor" ), _( "Scale output by this factor" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -95,21 +95,21 @@ vips_foreign_load_tiff_class_init( VipsForeignLoadTiffClass *class )
object_class->nickname = "tiffload_base"; object_class->nickname = "tiffload_base";
object_class->description = _( "load tiff" ); object_class->description = _( "load tiff" );
VIPS_ARG_INT( class, "page", 10, VIPS_ARG_INT( class, "page", 20,
_( "Page" ), _( "Page" ),
_( "Load this page from the image" ), _( "Load this page from the image" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadTiff, page ), G_STRUCT_OFFSET( VipsForeignLoadTiff, page ),
0, 100000, 0 ); 0, 100000, 0 );
VIPS_ARG_INT( class, "n", 11, VIPS_ARG_INT( class, "n", 21,
_( "n" ), _( "n" ),
_( "Load this many pages" ), _( "Load this many pages" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadTiff, n ), G_STRUCT_OFFSET( VipsForeignLoadTiff, n ),
-1, 100000, 1 ); -1, 100000, 1 );
VIPS_ARG_BOOL( class, "autorotate", 12, VIPS_ARG_BOOL( class, "autorotate", 22,
_( "Autorotate" ), _( "Autorotate" ),
_( "Rotate image using orientation tag" ), _( "Rotate image using orientation tag" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -75,6 +75,14 @@ typedef struct {
const void *data; const void *data;
gint64 length; 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. /* Shrink-on-load factor. Use this to set scaled_width.
*/ */
int shrink; int shrink;
@ -146,7 +154,8 @@ read_free( Read *read )
} }
static 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; 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->filename = g_strdup( filename );
read->data = data; read->data = data;
read->length = length; read->length = length;
read->page = page;
read->n = n;
read->shrink = shrink; read->shrink = shrink;
read->fd = 0; read->fd = 0;
read->idec = NULL; read->idec = NULL;
@ -274,11 +285,12 @@ read_header( Read *read, VipsImage *out )
} }
int 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; Read *read;
if( !(read = read_new( filename, NULL, 0, shrink )) ) { if( !(read = read_new( filename, NULL, 0, page, n, shrink )) ) {
vips_error( "webp2vips", vips_error( "webp2vips",
_( "unable to open \"%s\"" ), filename ); _( "unable to open \"%s\"" ), filename );
return( -1 ); return( -1 );
@ -324,11 +336,12 @@ read_image( Read *read, VipsImage *out )
} }
int 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; Read *read;
if( !(read = read_new( filename, NULL, 0, shrink )) ) { if( !(read = read_new( filename, NULL, 0, page, n, shrink )) ) {
vips_error( "webp2vips", vips_error( "webp2vips",
_( "unable to open \"%s\"" ), filename ); _( "unable to open \"%s\"" ), filename );
return( -1 ); return( -1 );
@ -344,11 +357,11 @@ vips__webp_read_file( const char *filename, VipsImage *out, int shrink )
int int
vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out, vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
int shrink ) int page, int n, int shrink )
{ {
Read *read; Read *read;
if( !(read = read_new( NULL, buf, len, shrink )) ) { if( !(read = read_new( NULL, buf, len, page, n, shrink )) ) {
vips_error( "webp2vips", vips_error( "webp2vips",
"%s", _( "unable to open buffer" ) ); "%s", _( "unable to open buffer" ) );
return( -1 ); return( -1 );
@ -366,11 +379,11 @@ vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out,
int int
vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out, vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out,
int shrink ) int page, int n, int shrink )
{ {
Read *read; Read *read;
if( !(read = read_new( NULL, buf, len, shrink )) ) { if( !(read = read_new( NULL, buf, len, page, n, shrink )) ) {
vips_error( "webp2vips", vips_error( "webp2vips",
"%s", _( "unable to open buffer" ) ); "%s", _( "unable to open buffer" ) );
return( -1 ); return( -1 );

View File

@ -4,6 +4,8 @@
* - from pngload.c * - from pngload.c
* 28/2/16 * 28/2/16
* - add @shrink * - add @shrink
* 1/11/18
* - add @page, @n
*/ */
/* /*
@ -54,6 +56,14 @@
typedef struct _VipsForeignLoadWebp { typedef struct _VipsForeignLoadWebp {
VipsForeignLoad parent_object; VipsForeignLoad parent_object;
/* Load this page (frame number).
*/
int page;
/* Load this many pages.
*/
int n;
/* Shrink by this much during load. /* Shrink by this much during load.
*/ */
int shrink; int shrink;
@ -96,7 +106,21 @@ vips_foreign_load_webp_class_init( VipsForeignLoadWebpClass *class )
load_class->get_flags = vips_foreign_load_webp_get_flags; 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" ),
_( "Shrink factor on load" ), _( "Shrink factor on load" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
@ -108,6 +132,7 @@ vips_foreign_load_webp_class_init( VipsForeignLoadWebpClass *class )
static void static void
vips_foreign_load_webp_init( VipsForeignLoadWebp *webp ) vips_foreign_load_webp_init( VipsForeignLoadWebp *webp )
{ {
webp->n = 1;
webp->shrink = 1; webp->shrink = 1;
} }
@ -144,7 +169,7 @@ vips_foreign_load_webp_file_header( VipsForeignLoad *load )
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load; VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
if( vips__webp_read_file_header( file->filename, load->out, if( vips__webp_read_file_header( file->filename, load->out,
webp->shrink ) ) webp->page, webp->n, webp->shrink ) )
return( -1 ); return( -1 );
VIPS_SETSTR( load->out->filename, file->filename ); VIPS_SETSTR( load->out->filename, file->filename );
@ -158,7 +183,8 @@ vips_foreign_load_webp_file_load( VipsForeignLoad *load )
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load; VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) 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( -1 );
return( 0 ); return( 0 );
@ -222,7 +248,8 @@ vips_foreign_load_webp_buffer_header( VipsForeignLoad *load )
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load; VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
if( vips__webp_read_buffer_header( buffer->buf->data, 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( -1 );
return( 0 ); return( 0 );
@ -235,7 +262,8 @@ vips_foreign_load_webp_buffer_load( VipsForeignLoad *load )
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load; VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
if( vips__webp_read_buffer( buffer->buf->data, buffer->buf->length, 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( -1 );
return( 0 ); return( 0 );
@ -287,14 +315,22 @@ vips_foreign_load_webp_buffer_init( VipsForeignLoadWebpBuffer *buffer )
* *
* Optional arguments: * Optional arguments:
* *
* * @page: %gint, page (frame) to read
* * @n: %gint, load this many pages
* * @shrink: %gint, shrink by this much on load * * @shrink: %gint, shrink by this much on load
* *
* Read a WebP file into a VIPS image. * 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. * Use @shrink to specify a shrink-on-load factor.
* *
* If libwebpmux is available, image metadata is also read. The loader supports * The loader supports ICC, EXIF and XMP metadata.
* ICC, EXIF and XMP metadata.
* *
* See also: vips_image_new_from_file(). * See also: vips_image_new_from_file().
* *
@ -322,6 +358,8 @@ vips_webpload( const char *filename, VipsImage **out, ... )
* *
* Optional arguments: * Optional arguments:
* *
* * @page: %gint, page (frame) to read
* * @n: %gint, load this many pages
* * @shrink: %gint, shrink by this much on load * * @shrink: %gint, shrink by this much on load
* *
* Read a WebP-formatted memory block into a VIPS image. Exactly as * Read a WebP-formatted memory block into a VIPS image. Exactly as