have a more formal max image dimension
we now have VIPS_MAX_COORD for maximum image dimension, set to 10m pixels ... we could go up to 2bn, but 10m seems a reasonable max, at least for now see https://github.com/jcupitt/libvips/issues/355
This commit is contained in:
parent
848adca836
commit
1504ca7cdc
@ -434,14 +434,14 @@ vips_max_class_init( VipsMaxClass *class )
|
||||
_( "Horizontal position of maximum" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsMax, x ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "y", 3,
|
||||
_( "y" ),
|
||||
_( "Vertical position of maximum" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsMax, y ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "size", 4,
|
||||
_( "Size" ),
|
||||
|
@ -437,14 +437,14 @@ vips_min_class_init( VipsMinClass *class )
|
||||
_( "Horizontal position of minimum" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsMin, x ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "y", 3,
|
||||
_( "y" ),
|
||||
_( "Vertical position of minimum" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsMin, y ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "size", 4,
|
||||
_( "Size" ),
|
||||
|
@ -285,21 +285,21 @@ vips_copy_class_init( VipsCopyClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsCopy, width ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 4,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsCopy, height ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "bands", 5,
|
||||
_( "Bands" ),
|
||||
_( "Number of bands in image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsCopy, bands ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_ENUM( class, "format", 6,
|
||||
_( "Format" ),
|
||||
@ -341,14 +341,14 @@ vips_copy_class_init( VipsCopyClass *class )
|
||||
_( "Horizontal offset of origin" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsCopy, xoffset ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "yoffset", 12,
|
||||
_( "Yoffset" ),
|
||||
_( "Vertical offset of origin" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsCopy, yoffset ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -126,14 +126,14 @@ vips_wrap_class_init( VipsWrapClass *class )
|
||||
_( "Left edge of input in output" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsWrap, x ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "y", 4,
|
||||
_( "y" ),
|
||||
_( "Top edge of input in output" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsWrap, y ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -130,21 +130,21 @@ vips_black_class_init( VipsBlackClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsBlack, width ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 5,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsBlack, height ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "bands", 6,
|
||||
_( "Bands" ),
|
||||
_( "Number of bands in image" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsBlack, bands ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -103,14 +103,14 @@ vips_fractsurf_class_init( VipsFractsurfClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsFractsurf, width ),
|
||||
1, 1000000, 64 );
|
||||
1, VIPS_MAX_COORD, 64 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 5,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsFractsurf, height ),
|
||||
1, 1000000, 64 );
|
||||
1, VIPS_MAX_COORD, 64 );
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "fractal_dimension", 8,
|
||||
_( "Fractal dimension" ),
|
||||
|
@ -154,14 +154,14 @@ vips_gaussnoise_class_init( VipsGaussnoiseClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsGaussnoise, width ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 5,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsGaussnoise, height ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_DOUBLE( class, "mean", 6,
|
||||
_( "Mean" ),
|
||||
|
@ -144,14 +144,14 @@ vips_point_class_init( VipsPointClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsPoint, width ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 3,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsPoint, height ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_BOOL( class, "uchar", 4,
|
||||
_( "Uchar" ),
|
||||
|
@ -298,7 +298,7 @@ vips_text_class_init( VipsTextClass *class )
|
||||
_( "Maximum image width in pixels" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsText, width ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_ENUM( class, "align", 7,
|
||||
_( "Align" ),
|
||||
|
@ -194,35 +194,35 @@ vips_xyz_class_init( VipsXyzClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsXyz, width ),
|
||||
1, 1000000, 64 );
|
||||
1, VIPS_MAX_COORD, 64 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 5,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsXyz, height ),
|
||||
1, 1000000, 64 );
|
||||
1, VIPS_MAX_COORD, 64 );
|
||||
|
||||
VIPS_ARG_INT( class, "csize", 6,
|
||||
_( "csize" ),
|
||||
_( "Size of third dimension" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsXyz, csize ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "dsize", 7,
|
||||
_( "dsize" ),
|
||||
_( "Size of fourth dimension" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsXyz, dsize ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "esize", 8,
|
||||
_( "esize" ),
|
||||
_( "Size of fifth dimension" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsXyz, esize ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -124,21 +124,21 @@ vips_foreign_load_raw_class_init( VipsForeignLoadRawClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, width ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 11,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, height ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "bands", 12,
|
||||
_( "Bands" ),
|
||||
_( "Number of bands in image" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, bands ),
|
||||
0, 1000000, 0 );
|
||||
0, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_UINT64( class, "offset", 13,
|
||||
_( "Size of header" ),
|
||||
|
@ -1126,9 +1126,9 @@ parse_header( ReadTiff *rtiff, VipsImage *out )
|
||||
*/
|
||||
|
||||
if( width <= 0 ||
|
||||
width > 10000000 ||
|
||||
width > VIPS_MAX_COORD ||
|
||||
height <= 0 ||
|
||||
height > 10000000 ) {
|
||||
height > VIPS_MAX_COORD ) {
|
||||
vips_error( "tiff2vips",
|
||||
"%s", _( "width/height out of range" ) );
|
||||
return( -1 );
|
||||
|
@ -313,14 +313,14 @@ vips_hist_local_class_init( VipsHistLocalClass *class )
|
||||
_( "Window width in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsHistLocal, width ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 5,
|
||||
_( "Height" ),
|
||||
_( "Window height in pixels" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsHistLocal, height ),
|
||||
1, 1000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -47,6 +47,15 @@ extern "C" {
|
||||
#define VIPS_MAGIC_INTEL (0xb6a6f208U)
|
||||
#define VIPS_MAGIC_SPARC (0x08f2a6b6U)
|
||||
|
||||
/* We have a maximum value for a coordinate at various points for sanity
|
||||
* checking. For example, vips_black() has a max with and height. We use int
|
||||
* for width/height so we could go up to 2bn, but it's good to have a lower
|
||||
* value set so we can see crazy numbers early.
|
||||
*
|
||||
* This was 1m for a while, but someone found a use for a 4m wide image.
|
||||
*/
|
||||
#define VIPS_MAX_COORD (10000000)
|
||||
|
||||
typedef enum {
|
||||
VIPS_DEMAND_STYLE_ERROR = -1,
|
||||
VIPS_DEMAND_STYLE_SMALLTILE,
|
||||
|
@ -1119,21 +1119,21 @@ vips_image_class_init( VipsImageClass *class )
|
||||
_( "Image width in pixels" ),
|
||||
VIPS_ARGUMENT_SET_ALWAYS,
|
||||
G_STRUCT_OFFSET( VipsImage, Xsize ),
|
||||
1, 1000000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "height", 3,
|
||||
_( "Height" ),
|
||||
_( "Image height in pixels" ),
|
||||
VIPS_ARGUMENT_SET_ALWAYS,
|
||||
G_STRUCT_OFFSET( VipsImage, Ysize ),
|
||||
1, 1000000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_INT( class, "bands", 4,
|
||||
_( "Bands" ),
|
||||
_( "Number of bands in image" ),
|
||||
VIPS_ARGUMENT_SET_ALWAYS,
|
||||
G_STRUCT_OFFSET( VipsImage, Bands ),
|
||||
1, 1000000000, 1 );
|
||||
1, VIPS_MAX_COORD, 1 );
|
||||
|
||||
VIPS_ARG_ENUM( class, "format", 5,
|
||||
_( "Format" ),
|
||||
@ -1175,14 +1175,14 @@ vips_image_class_init( VipsImageClass *class )
|
||||
_( "Horizontal offset of origin" ),
|
||||
VIPS_ARGUMENT_SET_ALWAYS,
|
||||
G_STRUCT_OFFSET( VipsImage, Xoffset ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_INT( class, "yoffset", 11,
|
||||
_( "Yoffset" ),
|
||||
_( "Vertical offset of origin" ),
|
||||
VIPS_ARGUMENT_SET_ALWAYS,
|
||||
G_STRUCT_OFFSET( VipsImage, Yoffset ),
|
||||
-1000000, 1000000, 0 );
|
||||
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0 );
|
||||
|
||||
VIPS_ARG_STRING( class, "filename", 12,
|
||||
_( "Filename" ),
|
||||
|
Loading…
Reference in New Issue
Block a user