From 08dac03701ed1440cf8c39d40747140a3bd1dcef Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Wed, 2 Nov 2022 00:05:56 +0000 Subject: [PATCH 01/11] Add resvg --- libvips/foreign/foreign.c | 1046 +++++++++++++++++++------------------ libvips/foreign/svgload.c | 307 +++++++---- meson.build | 11 + meson_options.txt | 5 + 4 files changed, 747 insertions(+), 622 deletions(-) diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index eeadfe8c68..1517c142b6 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -81,41 +81,41 @@ * @include: vips/vips.h * @title: VipsForeign * - * This set of operations load and save images in a variety of formats. + * This set of operations load and save images in a variety of formats. * * The operations share a base class that offers a simple way to search for a * subclass of #VipsForeign which can load a certain file (see - * vips_foreign_find_load()) or buffer (see vips_foreign_find_load_buffer()), + * vips_foreign_find_load()) or buffer (see vips_foreign_find_load_buffer()), * or which could be used to save an image to a * certain file type (see vips_foreign_find_save() and * vips_foreign_find_save_buffer()). You can then run these * operations using vips_call() and friends to perform the load or save. * * vips_image_write_to_file() and vips_image_new_from_file() and friends use - * these functions to automate file load and save. + * these functions to automate file load and save. * * You can also invoke the operations directly, for example: * * |[ - * vips_tiffsave (my_image, "frank.anything", + * vips_tiffsave (my_image, "frank.anything", * "compression", VIPS_FOREIGN_TIFF_COMPRESSION_JPEG, * NULL); * ]| * * To add support for a new file format to vips, simply define a new subclass - * of #VipsForeignLoad or #VipsForeignSave. + * of #VipsForeignLoad or #VipsForeignSave. * - * If you define a new operation which is a subclass of #VipsForeign, support + * If you define a new operation which is a subclass of #VipsForeign, support * for it automatically appears in all VIPS user-interfaces. It will also be * transparently supported by vips_image_new_from_file() and friends. * * VIPS comes with VipsForeign for TIFF, JPEG, PNG, Analyze, PPM, OpenEXR, CSV, - * Matlab, Radiance, RAW, FITS, WebP, SVG, PDF, GIF and VIPS. It also includes - * import filters which can load with libMagick and with OpenSlide. + * Matlab, Radiance, RAW, FITS, WebP, SVG, PDF, GIF and VIPS. It also includes + * import filters which can load with libMagick and with OpenSlide. * * ## Writing a new loader * - * Add a new loader to VIPS by subclassing #VipsForeignLoad. Subclasses need to + * Add a new loader to VIPS by subclassing #VipsForeignLoad. Subclasses need to * implement at least @header(). * * @header() must set at least the header fields of @out. @load(), if defined, @@ -124,7 +124,7 @@ * The suffix list is used to select a format to save a file in, and to pick a * loader if you don't define is_a(). * - * You should also define @nickname and @description in #VipsObject. + * You should also define @nickname and @description in #VipsObject. * * As a complete example, here's code for a PNG loader, minus the actual * calls to libpng. @@ -132,59 +132,59 @@ * |[ * typedef struct _VipsForeignLoadPng { * VipsForeignLoad parent_object; - * - * char *filename; + * + * char *filename; * } VipsForeignLoadPng; - * + * * typedef VipsForeignLoadClass VipsForeignLoadPngClass; - * - * G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png, + * + * G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png, * VIPS_TYPE_FOREIGN_LOAD ); - * + * * static VipsForeignFlags * vips_foreign_load_png_get_flags_filename( const char *filename ) * { * VipsForeignFlags flags; - * + * * flags = 0; * if( vips__png_isinterlaced( filename ) ) * flags = VIPS_FOREIGN_PARTIAL; * else * flags = VIPS_FOREIGN_SEQUENTIAL; - * + * * return( flags ); * } - * + * * static VipsForeignFlags * vips_foreign_load_png_get_flags( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * return( vips_foreign_load_png_get_flags_filename( png->filename ) ); * } - * + * * static int * vips_foreign_load_png_header( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * if( vips__png_header( png->filename, load->out ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static int * vips_foreign_load_png_load( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * if( vips__png_read( png->filename, load->real ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static void * vips_foreign_load_png_class_init( VipsForeignLoadPngClass *class ) * { @@ -192,40 +192,40 @@ * VipsObjectClass *object_class = (VipsObjectClass *) class; * VipsForeignClass *foreign_class = (VipsForeignClass *) class; * VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class; - * + * * gobject_class->set_property = vips_object_set_property; * gobject_class->get_property = vips_object_get_property; - * + * * object_class->nickname = "pngload"; * object_class->description = _( "load png from file" ); - * + * * foreign_class->suffs = vips__png_suffs; - * + * * load_class->is_a = vips__png_ispng; - * load_class->get_flags_filename = + * load_class->get_flags_filename = * vips_foreign_load_png_get_flags_filename; * load_class->get_flags = vips_foreign_load_png_get_flags; * load_class->header = vips_foreign_load_png_header; * load_class->load = vips_foreign_load_png_load; - * - * VIPS_ARG_STRING( class, "filename", 1, + * + * VIPS_ARG_STRING( class, "filename", 1, * _( "Filename" ), * _( "Filename to load from" ), - * VIPS_ARGUMENT_REQUIRED_INPUT, + * VIPS_ARGUMENT_REQUIRED_INPUT, * G_STRUCT_OFFSET( VipsForeignLoadPng, filename ), * NULL ); * } - * + * * static void * vips_foreign_load_png_init( VipsForeignLoadPng *png ) * { * } * ]| - * + * * ## Writing a new saver * * Call your saver in the class' @build() method after chaining up. The - * prepared image should be ready for you to save in @ready. + * prepared image should be ready for you to save in @ready. * * As a complete example, here's the code for the CSV saver, minus the calls * to the actual save routines. @@ -233,32 +233,32 @@ * |[ * typedef struct _VipsForeignSaveCsv { * VipsForeignSave parent_object; - * - * char *filename; + * + * char *filename; * const char *separator; * } VipsForeignSaveCsv; - * + * * typedef VipsForeignSaveClass VipsForeignSaveCsvClass; - * - * G_DEFINE_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv, + * + * G_DEFINE_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv, * VIPS_TYPE_FOREIGN_SAVE ); - * + * * static int * vips_foreign_save_csv_build( VipsObject *object ) * { * VipsForeignSave *save = (VipsForeignSave *) object; * VipsForeignSaveCsv *csv = (VipsForeignSaveCsv *) object; - * + * * if( VIPS_OBJECT_CLASS( vips_foreign_save_csv_parent_class )-> * build( object ) ) * return( -1 ); - * + * * if( vips__csv_write( save->ready, csv->filename, csv->separator ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static void * vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class ) * { @@ -266,35 +266,35 @@ * VipsObjectClass *object_class = (VipsObjectClass *) class; * VipsForeignClass *foreign_class = (VipsForeignClass *) class; * VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class; - * + * * gobject_class->set_property = vips_object_set_property; * gobject_class->get_property = vips_object_get_property; - * + * * object_class->nickname = "csvsave"; * object_class->description = _( "save image to csv file" ); * object_class->build = vips_foreign_save_csv_build; - * + * * foreign_class->suffs = vips__foreign_csv_suffs; - * + * * save_class->saveable = VIPS_SAVEABLE_MONO; - * // no need to define ->format_table, we don't want the input + * // no need to define ->format_table, we don't want the input * // cast for us - * - * VIPS_ARG_STRING( class, "filename", 1, + * + * VIPS_ARG_STRING( class, "filename", 1, * _( "Filename" ), * _( "Filename to save to" ), - * VIPS_ARGUMENT_REQUIRED_INPUT, + * VIPS_ARGUMENT_REQUIRED_INPUT, * G_STRUCT_OFFSET( VipsForeignSaveCsv, filename ), * NULL ); - * - * VIPS_ARG_STRING( class, "separator", 13, - * _( "Separator" ), + * + * VIPS_ARG_STRING( class, "separator", 13, + * _( "Separator" ), * _( "Separator characters" ), * VIPS_ARGUMENT_OPTIONAL_INPUT, * G_STRUCT_OFFSET( VipsForeignSaveCsv, separator ), - * "\t" ); + * "\t" ); * } - * + * * static void * vips_foreign_save_csv_init( VipsForeignSaveCsv *csv ) * { @@ -303,12 +303,12 @@ * ]| */ -/* Use this to link images to the load operation that made them. +/* Use this to link images to the load operation that made them. */ -static GQuark vips__foreign_load_operation = 0; +static GQuark vips__foreign_load_operation = 0; /** - * VipsForeignFlags: + * VipsForeignFlags: * @VIPS_FOREIGN_NONE: no flags set * @VIPS_FOREIGN_PARTIAL: the image may be read lazilly * @VIPS_FOREIGN_BIGENDIAN: image pixels are most-significant byte first @@ -317,11 +317,11 @@ static GQuark vips__foreign_load_operation = 0; * Some hints about the image loader. * * #VIPS_FOREIGN_PARTIAL means that the image can be read directly from the - * file without needing to be unpacked to a temporary image first. + * file without needing to be unpacked to a temporary image first. * * #VIPS_FOREIGN_SEQUENTIAL means that the loader supports lazy reading, but * only top-to-bottom (sequential) access. Formats like PNG can read sets of - * scanlines, for example, but only in order. + * scanlines, for example, but only in order. * * If neither PARTIAL or SEQUENTIAL is set, the loader only supports whole * image read. Setting both PARTIAL and SEQUENTIAL is an error. @@ -337,7 +337,7 @@ static void vips_foreign_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) { VipsForeignClass *class = VIPS_FOREIGN_CLASS( object_class ); - VipsOperationClass *operation_class = + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( object_class ); VIPS_OBJECT_CLASS( vips_foreign_parent_class )-> @@ -382,7 +382,7 @@ vips_foreign_init( VipsForeign *object ) { } -/* To iterate over supported files we build a temp list of subclasses of +/* To iterate over supported files we build a temp list of subclasses of * VipsForeign, sort by priority, iterate, and free. */ @@ -391,9 +391,9 @@ file_add_class( VipsForeignClass *class, GSList **files ) { /* We exclude "rawload" as it has a different API. */ - if( !vips_isprefix( "rawload", VIPS_OBJECT_CLASS( class )->nickname ) ) - /* Append so we don't reverse the list of files. Sort will - * not reorder items of equal priority. + if( !vips_isprefix( "rawload", VIPS_OBJECT_CLASS( class )->nickname ) ) + /* Append so we don't reverse the list of files. Sort will + * not reorder items of equal priority. */ *files = g_slist_append( *files, class ); @@ -414,7 +414,7 @@ file_compare( VipsForeignClass *a, VipsForeignClass *b, void *user_data ) * @b: user data * * Apply a function to every #VipsForeignClass that VIPS knows about. Foreigns - * are presented to the function in priority order. + * are presented to the function in priority order. * * Like all VIPS map functions, if @fn returns %NULL, iteration continues. If * it returns non-%NULL, iteration terminates and that value is returned. The @@ -431,7 +431,7 @@ vips_foreign_map( const char *base, VipsSListMap2Fn fn, void *a, void *b ) void *result; files = NULL; - (void) vips_class_map_all( g_type_from_name( base ), + (void) vips_class_map_all( g_type_from_name( base ), (VipsClassMapFn) file_add_class, (void *) &files ); files = g_slist_sort( files, (GCompareFunc) file_compare ); @@ -502,7 +502,7 @@ vips_foreign_load_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) /* Can this VipsForeign open this file? */ static void * -vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, +vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, const char *filename, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class ); @@ -511,11 +511,11 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, /* Ignore the buffer and source loaders. */ if( vips_ispostfix( object_class->nickname, "_buffer" ) || - vips_ispostfix( object_class->nickname, "_source" ) ) + vips_ispostfix( object_class->nickname, "_source" ) ) return( NULL ); #ifdef DEBUG - printf( "vips_foreign_find_load_sub: %s\n", + printf( "vips_foreign_find_load_sub: %s\n", VIPS_OBJECT_CLASS( class )->nickname ); #endif /*DEBUG*/ @@ -523,19 +523,19 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, * otherwise fall back to checking the filename suffix. */ if( load_class->is_a ) { - if( load_class->is_a( filename ) ) + if( load_class->is_a( filename ) ) return( load_class ); #ifdef DEBUG - printf( "vips_foreign_find_load_sub: is_a failed\n" ); + printf( "vips_foreign_find_load_sub: is_a failed\n" ); #endif /*DEBUG*/ } else if( class->suffs ) { if( vips_filename_suffix_match( filename, class->suffs ) ) return( load_class ); } - else - g_warning( "loader %s has no is_a method and no suffix list", + else + g_warning( "loader %s has no is_a method and no suffix list", object_class->nickname ); return( NULL ); @@ -546,7 +546,7 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, * @filename: file to find a loader for * * Searches for an operation you could use to load @filename. Any trailing - * options on @filename are stripped and ignored. + * options on @filename are stripped and ignored. * * See also: vips_foreign_find_load_buffer(), vips_image_new_from_file(). * @@ -564,27 +564,27 @@ vips_foreign_find_load( const char *name ) /* Very common, so make a better error message for this case. */ if( !vips_existsf( "%s", filename ) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "file \"%s\" does not exist" ), name ); return( NULL ); } if( vips_isdirf( "%s", filename ) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "\"%s\" is a directory" ), name ); return( NULL ); } - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - (VipsSListMap2Fn) vips_foreign_find_load_sub, + (VipsSListMap2Fn) vips_foreign_find_load_sub, (void *) filename, NULL )) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "\"%s\" is not a known file format" ), name ); return( NULL ); } #ifdef DEBUG - printf( "vips_foreign_find_load: selected %s\n", + printf( "vips_foreign_find_load: selected %s\n", VIPS_OBJECT_CLASS( load_class )->nickname ); #endif /*DEBUG*/ @@ -592,7 +592,7 @@ vips_foreign_find_load( const char *name ) } /* Kept for compat with earlier version of the vip8 API. Use - * vips_image_new_from_file() now. + * vips_image_new_from_file() now. */ int @@ -609,7 +609,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... ) return( -1 ); va_start( ap, out ); - result = vips_call_split_option_string( operation_name, option_string, + result = vips_call_split_option_string( operation_name, option_string, ap, filename, out ); va_end( ap ); @@ -619,7 +619,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... ) /* Can this VipsForeign open this buffer? */ static void * -vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, +vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, const void **buf, size_t *len ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class ); @@ -630,11 +630,11 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, return( NULL ); if( load_class->is_a_buffer ) { - if( load_class->is_a_buffer( *buf, *len ) ) + if( load_class->is_a_buffer( *buf, *len ) ) return( load_class ); } else - g_warning( "loader %s has no is_a_buffer method", + g_warning( "loader %s has no is_a_buffer method", object_class->nickname ); return( NULL ); @@ -642,18 +642,18 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, /** * vips_foreign_find_load_buffer: - * @data: (array length=size) (element-type guint8) (transfer none): start of + * @data: (array length=size) (element-type guint8) (transfer none): start of * memory buffer * @size: (type gsize): number of bytes in @data * * Searches for an operation you could use to load a memory buffer. To see the * range of buffer loaders supported by your vips, try something like: - * + * * vips -l | grep load_buffer * * See also: vips_image_new_from_buffer(). * - * Returns: (transfer none): the name of an operation on success, %NULL on + * Returns: (transfer none): the name of an operation on success, %NULL on * error. */ const char * @@ -661,12 +661,12 @@ vips_foreign_find_load_buffer( const void *data, size_t size ) { VipsForeignLoadClass *load_class; - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - (VipsSListMap2Fn) vips_foreign_find_load_buffer_sub, + (VipsSListMap2Fn) vips_foreign_find_load_buffer_sub, &data, &size )) ) { - vips_error( "VipsForeignLoad", - "%s", _( "buffer is not in a known format" ) ); + vips_error( "VipsForeignLoad", + "%s", _( "buffer is not in a known format" ) ); return( NULL ); } @@ -693,11 +693,11 @@ vips_foreign_find_load_source_sub( void *item, void *a, void *b ) */ (void) vips_source_rewind( source ); - if( load_class->is_a_source( source ) ) + if( load_class->is_a_source( source ) ) return( load_class ); } - else - g_warning( "loader %s has no is_a_source method", + else + g_warning( "loader %s has no is_a_source method", object_class->nickname ); return( NULL ); @@ -709,12 +709,12 @@ vips_foreign_find_load_source_sub( void *item, void *a, void *b ) * * Searches for an operation you could use to load a source. To see the * range of source loaders supported by your vips, try something like: - * + * * vips -l | grep load_source * * See also: vips_image_new_from_source(). * - * Returns: (transfer none): the name of an operation on success, %NULL on + * Returns: (transfer none): the name of an operation on success, %NULL on * error. */ const char * @@ -722,18 +722,18 @@ vips_foreign_find_load_source( VipsSource *source ) { VipsForeignLoadClass *load_class; - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - vips_foreign_find_load_source_sub, + vips_foreign_find_load_source_sub, source, NULL )) ) { - vips_error( "VipsForeignLoad", - "%s", _( "source is not in a known format" ) ); + vips_error( "VipsForeignLoad", + "%s", _( "source is not in a known format" ) ); return( NULL ); } /* All source loaders should be NOCACHE. */ - g_assert( VIPS_OPERATION_CLASS( load_class )->flags & + g_assert( VIPS_OPERATION_CLASS( load_class )->flags & VIPS_OPERATION_NOCACHE ); return( G_OBJECT_CLASS_NAME( load_class ) ); @@ -749,17 +749,17 @@ vips_foreign_find_load_source( VipsSource *source ) * * Returns: %TRUE if @filename can be loaded by @loader. */ -gboolean +gboolean vips_foreign_is_a( const char *loader, const char *filename ) { const VipsObjectClass *class; VipsForeignLoadClass *load_class; - if( !(class = vips_class_find( "VipsForeignLoad", loader )) ) + if( !(class = vips_class_find( "VipsForeignLoad", loader )) ) return( FALSE ); load_class = VIPS_FOREIGN_LOAD_CLASS( class ); if( load_class->is_a && - load_class->is_a( filename ) ) + load_class->is_a( filename ) ) return( TRUE ); return( FALSE ); @@ -823,21 +823,21 @@ vips_foreign_is_a_source( const char *loader, VipsSource *source ) * @loader: name of loader to use for test * @filename: file to test * - * Return the flags for @filename using @loader. + * Return the flags for @filename using @loader. * @loader is something like "tiffload" or "VipsForeignLoadTiff". * * Returns: the flags for @filename. */ -VipsForeignFlags +VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename ) { const VipsObjectClass *class; if( (class = vips_class_find( "VipsForeignLoad", loader )) ) { - VipsForeignLoadClass *load_class = + VipsForeignLoadClass *load_class = VIPS_FOREIGN_LOAD_CLASS( class ); - if( load_class->get_flags_filename ) + if( load_class->get_flags_filename ) return( load_class->get_flags_filename( filename ) ); } @@ -854,7 +854,7 @@ vips_foreign_load_new_from_string( const char *string ) if( !(file_op = vips_foreign_find_load( string )) ) return( NULL ); type = g_type_from_name( file_op ); - g_assert( type ); + g_assert( type ); load = VIPS_FOREIGN_LOAD( g_object_new( type, NULL ) ); g_object_set( load, @@ -897,7 +897,7 @@ vips_foreign_load_temp( VipsForeignLoad *load ) /* If it can do sequential access and it's been requested, we can open * directly. */ - if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && + if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && load->access != VIPS_ACCESS_RANDOM ) { #ifdef DEBUG printf( "vips_foreign_load_temp: partial sequential temp\n" ); @@ -906,7 +906,7 @@ vips_foreign_load_temp( VipsForeignLoad *load ) return( vips_image_new() ); } - /* We open via disc if the uncompressed image will be larger than + /* We open via disc if the uncompressed image will be larger than * vips_get_disc_threshold() */ if( image_size > disc_threshold ) { @@ -938,7 +938,7 @@ vips_foreign_load_iscompat( VipsImage *a, VipsImage *b ) a->Coding != b->Coding || a->BandFmt != b->BandFmt ) { vips_error( "VipsForeignLoad", - "%s", _( "images do not match" ) ); + "%s", _( "images do not match" ) ); return( FALSE ); } @@ -968,25 +968,25 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) #endif /*DEBUG*/ /* Read the image in. This may involve a long computation and - * will finish with load->real holding the decompressed image. + * will finish with load->real holding the decompressed image. * * We want our caller to be able to see this computation on * @out, so eval signals on ->real need to appear on ->out. */ load->real->progress_signal = load->out; - /* Note the load object on the image. Loaders can use + /* Note the load object on the image. Loaders can use * this to signal invalidate if they hit a load error. See * vips_foreign_load_invalidate() below. */ - g_object_set_qdata( G_OBJECT( load->real ), - vips__foreign_load_operation, load ); + g_object_set_qdata( G_OBJECT( load->real ), + vips__foreign_load_operation, load ); /* Load the image and check the result. * * ->header() read the header into @out, load will read the * image into @real. They must match exactly in size, bands, - * format and coding for the copy to work. + * format and coding for the copy to work. * * Some versions of ImageMagick give different results between * Ping and Load for some formats, for example. @@ -994,9 +994,9 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) * If the load fails, we need to stop */ if( class->load( load ) || - vips_image_pio_input( load->real ) || + vips_image_pio_input( load->real ) || !vips_foreign_load_iscompat( load->real, out ) ) { - vips_operation_invalidate( VIPS_OPERATION( load ) ); + vips_operation_invalidate( VIPS_OPERATION( load ) ); load->error = TRUE; return( NULL ); @@ -1005,7 +1005,7 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) /* We have to tell vips that out depends on real. We've set * the demand hint below, but not given an input there. */ - if( vips_image_pipelinev( load->out, load->out->dhint, + if( vips_image_pipelinev( load->out, load->out->dhint, load->real, NULL ) ) return( NULL ); } @@ -1016,7 +1016,7 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) /* Just pointer-copy. */ static int -vips_foreign_load_generate( VipsRegion *or, +vips_foreign_load_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { VipsRegion *ir = (VipsRegion *) seq; @@ -1055,7 +1055,7 @@ vips_foreign_load_build( VipsObject *object ) if( (flags & VIPS_FOREIGN_PARTIAL) && (flags & VIPS_FOREIGN_SEQUENTIAL) ) { - g_warning( "%s", + g_warning( "%s", _( "VIPS_FOREIGN_PARTIAL and VIPS_FOREIGN_SEQUENTIAL " "both set -- using SEQUENTIAL" ) ); flags ^= VIPS_FOREIGN_PARTIAL; @@ -1067,7 +1067,7 @@ vips_foreign_load_build( VipsObject *object ) * loader in random mode is fine, since we'll read to ram or a temp * file. */ - if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && + if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && load->access != VIPS_ACCESS_RANDOM ) load->nocache = TRUE; @@ -1075,21 +1075,21 @@ vips_foreign_load_build( VipsObject *object ) */ if( vips_object_argument_isset( object, "fail" ) && !vips_object_argument_isset( object, "fail_on" ) ) - load->fail_on = load->fail ? + load->fail_on = load->fail ? VIPS_FAIL_ON_WARNING : VIPS_FAIL_ON_NONE; if( VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )-> build( object ) ) return( -1 ); - if( load->sequential ) - g_warning( "%s", + if( load->sequential ) + g_warning( "%s", _( "ignoring deprecated \"sequential\" mode -- " - "please use \"access\" instead" ) ); + "please use \"access\" instead" ) ); - g_object_set( object, "out", vips_image_new(), NULL ); + g_object_set( object, "out", vips_image_new(), NULL ); - vips_image_set_string( load->out, + vips_image_set_string( load->out, VIPS_META_LOADER, class->nickname ); #ifdef DEBUG @@ -1099,7 +1099,7 @@ vips_foreign_load_build( VipsObject *object ) /* Read the header into @out. */ if( fclass->header && - fclass->header( load ) ) + fclass->header( load ) ) return( -1 ); /* If there's no ->load() method then the header read has done @@ -1120,14 +1120,14 @@ vips_foreign_load_build( VipsObject *object ) if( vips_image_pipelinev( load->out, load->out->dhint, NULL ) ) return( -1 ); - /* Then 'start' creates the real image and 'gen' fetches + /* Then 'start' creates the real image and 'gen' fetches * pixels for @out from @real on demand. */ - if( vips_image_generate( load->out, - vips_foreign_load_start, - vips_foreign_load_generate, - vips_stop_one, - NULL, load ) ) + if( vips_image_generate( load->out, + vips_foreign_load_start, + vips_foreign_load_generate, + vips_stop_one, + NULL, load ) ) return( -1 ); } @@ -1139,7 +1139,7 @@ vips_foreign_load_build( VipsObject *object ) return( 0 ); } -static VipsOperationFlags +static VipsOperationFlags vips_foreign_load_operation_get_flags( VipsOperation *operation ) { VipsForeignLoad *load = VIPS_FOREIGN_LOAD( operation ); @@ -1173,56 +1173,56 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class ) operation_class->get_flags = vips_foreign_load_operation_get_flags; - VIPS_ARG_IMAGE( class, "out", 2, - _( "Output" ), + VIPS_ARG_IMAGE( class, "out", 2, + _( "Output" ), _( "Output image" ), - VIPS_ARGUMENT_REQUIRED_OUTPUT, + VIPS_ARGUMENT_REQUIRED_OUTPUT, G_STRUCT_OFFSET( VipsForeignLoad, out ) ); - VIPS_ARG_FLAGS( class, "flags", 106, - _( "Flags" ), + 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_TYPE_FOREIGN_FLAGS, VIPS_FOREIGN_NONE ); - VIPS_ARG_BOOL( class, "memory", 107, - _( "Memory" ), + 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", 108, - _( "Access" ), + 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_TYPE_ACCESS, VIPS_ACCESS_RANDOM ); - VIPS_ARG_ENUM( class, "fail_on", 109, - _( "Fail on" ), + VIPS_ARG_ENUM( class, "fail_on", 109, + _( "Fail on" ), _( "Error level to fail on" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignLoad, fail_on ), - VIPS_TYPE_FAIL_ON, VIPS_FAIL_ON_NONE ); + VIPS_TYPE_FAIL_ON, VIPS_FAIL_ON_NONE ); - VIPS_ARG_BOOL( class, "sequential", 110, - _( "Sequential" ), + VIPS_ARG_BOOL( class, "sequential", 110, + _( "Sequential" ), _( "Sequential read only" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, sequential ), FALSE ); VIPS_ARG_BOOL( class, "fail", 111, - _( "Fail" ), + _( "Fail" ), _( "Fail on first warning" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, fail ), FALSE ); - VIPS_ARG_BOOL( class, "disc", 112, - _( "Disc" ), + VIPS_ARG_BOOL( class, "disc", 112, + _( "Disc" ), _( "Open to disc" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, disc ), @@ -1248,25 +1248,25 @@ vips_foreign_load_init( VipsForeignLoad *load ) * * Loaders can call this on the image they are making if they see a read error * from the load library. It signals "invalidate" on the load operation and - * will cause it to be dropped from cache. + * will cause it to be dropped from cache. * * If we know a file will cause a read error, we don't want to cache the - * failing operation, we want to make sure the image will really be opened - * again if our caller tries again. For example, a broken file might be - * replaced by a working one. + * failing operation, we want to make sure the image will really be opened + * again if our caller tries again. For example, a broken file might be + * replaced by a working one. */ void vips_foreign_load_invalidate( VipsImage *image ) { - VipsOperation *operation; + VipsOperation *operation; #ifdef DEBUG - printf( "vips_foreign_load_invalidate: %p\n", image ); + printf( "vips_foreign_load_invalidate: %p\n", image ); #endif /*DEBUG*/ - if( (operation = g_object_get_qdata( G_OBJECT( image ), + if( (operation = g_object_get_qdata( G_OBJECT( image ), vips__foreign_load_operation )) ) { - vips_operation_invalidate( operation ); + vips_operation_invalidate( operation ); } } @@ -1293,7 +1293,7 @@ vips_foreign_save_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) VIPS_OBJECT_CLASS( vips_foreign_save_parent_class )-> summary_class( object_class, buf ); - vips_buf_appendf( buf, ", %s", + vips_buf_appendf( buf, ", %s", vips_enum_nick( VIPS_TYPE_SAVEABLE, class->saveable ) ); } @@ -1307,7 +1307,7 @@ vips_foreign_save_new_from_string( const char *string ) if( !(file_op = vips_foreign_find_save( string )) ) return( NULL ); type = g_type_from_name( file_op ); - g_assert( type ); + g_assert( type ); save = VIPS_FOREIGN_SAVE( g_object_new( type, NULL ) ); g_object_set( save, @@ -1317,7 +1317,7 @@ vips_foreign_save_new_from_string( const char *string ) return( VIPS_OBJECT( save ) ); } -/* Convert an image for saving. +/* Convert an image for saving. */ int vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, @@ -1328,7 +1328,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, */ g_object_ref( in ); - /* For coded images, can this class save the coding we are in now? + /* For coded images, can this class save the coding we are in now? * Nothing to do. */ if( in->Coding != VIPS_CODING_NONE && @@ -1337,7 +1337,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, return( 0 ); } - /* For uncoded images, if this saver supports ANY bands and this + /* For uncoded images, if this saver supports ANY bands and this * format we have nothing to do. */ if( in->Coding == VIPS_CODING_NONE && @@ -1366,7 +1366,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this is an VIPS_CODING_RAD, we unpack to float. This could be - * scRGB or XYZ. + * scRGB or XYZ. */ if( in->Coding == VIPS_CODING_RAD ) { VipsImage *out; @@ -1380,14 +1380,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* If the saver supports RAD, we need to go to scRGB or XYZ. + /* If the saver supports RAD, we need to go to scRGB or XYZ. */ if( coding[VIPS_CODING_RAD] ) { if( in->Type != VIPS_INTERPRETATION_scRGB && in->Type != VIPS_INTERPRETATION_XYZ ) { VipsImage *out; - if( vips_colourspace( in, &out, + if( vips_colourspace( in, &out, VIPS_INTERPRETATION_scRGB, NULL ) ) { g_object_unref( in ); return( -1 ); @@ -1399,16 +1399,16 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this image is CMYK and the saver is RGB-only, use lcms to try to - * import to XYZ. + * import to XYZ. */ if( in->Type == VIPS_INTERPRETATION_CMYK && in->Bands >= 4 && (saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGBA || - saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { VipsImage *out; - if( vips_icc_import( in, &out, + if( vips_icc_import( in, &out, "pcs", VIPS_PCS_XYZ, "embedded", TRUE, "input_profile", "cmyk", @@ -1422,7 +1422,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this is something other than CMYK or RAD, and it's not already - * an RGB image, eg. maybe a LAB image, we need to transform + * an RGB image, eg. maybe a LAB image, we need to transform * to RGB. */ if( !coding[VIPS_CODING_RAD] && @@ -1435,12 +1435,12 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, (saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGBA || saveable == VIPS_SAVEABLE_RGBA_ONLY || - saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { VipsImage *out; VipsInterpretation interpretation; /* Do we make RGB or RGB16? We don't want to squash a 16-bit - * RGB down to 8 bits if the saver supports 16. + * RGB down to 8 bits if the saver supports 16. */ if( vips_band_format_is8bit( format[in->BandFmt] ) ) interpretation = VIPS_INTERPRETATION_sRGB; @@ -1456,17 +1456,17 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* VIPS_SAVEABLE_RGBA_ONLY does not support mono types ... convert - * to sRGB. + /* VIPS_SAVEABLE_RGBA_ONLY does not support mono types ... convert + * to sRGB. */ if( !coding[VIPS_CODING_RAD] && in->Bands < 3 && - saveable == VIPS_SAVEABLE_RGBA_ONLY ) { + saveable == VIPS_SAVEABLE_RGBA_ONLY ) { VipsImage *out; VipsInterpretation interpretation; /* Do we make RGB or RGB16? We don't want to squash a 16-bit - * RGB down to 8 bits if the saver supports 16. + * RGB down to 8 bits if the saver supports 16. */ if( vips_band_format_is8bit( format[in->BandFmt] ) ) interpretation = VIPS_INTERPRETATION_sRGB; @@ -1483,7 +1483,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* Get the bands right. We must do this after all colourspace - * transforms, since they can change the number of bands. + * transforms, since they can change the number of bands. */ if( in->Coding == VIPS_CODING_NONE ) { /* Do we need to flatten out an alpha channel? There needs to @@ -1491,14 +1491,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * alpha. */ if( (in->Bands == 2 || - (in->Bands == 4 && + (in->Bands == 4 && in->Type != VIPS_INTERPRETATION_CMYK)) && (saveable == VIPS_SAVEABLE_MONO || saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGB_CMYK) ) { VipsImage *out; - if( vips_flatten( in, &out, + if( vips_flatten( in, &out, "background", background, NULL ) ) { g_object_unref( in ); @@ -1513,10 +1513,10 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * bands. */ - else if( in->Bands > 3 && + else if( in->Bands > 3 && (saveable == VIPS_SAVEABLE_RGB || (saveable == VIPS_SAVEABLE_RGB_CMYK && - in->Type != VIPS_INTERPRETATION_CMYK)) ) { + in->Type != VIPS_INTERPRETATION_CMYK)) ) { VipsImage *out; /* Don't let 4 bands though unless the image really is @@ -1526,7 +1526,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * write CMYK jpg, but we mustn't do that for RGBA * images. */ - if( vips_extract_band( in, &out, 0, + if( vips_extract_band( in, &out, 0, "n", 3, NULL ) ) { g_object_unref( in ); @@ -1536,14 +1536,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - else if( in->Bands > 4 && + else if( in->Bands > 4 && ((saveable == VIPS_SAVEABLE_RGB_CMYK && in->Type == VIPS_INTERPRETATION_CMYK) || saveable == VIPS_SAVEABLE_RGBA || saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { VipsImage *out; - if( vips_extract_band( in, &out, 0, + if( vips_extract_band( in, &out, 0, "n", 4, NULL ) ) { g_object_unref( in ); @@ -1553,7 +1553,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - else if( in->Bands > 1 && + else if( in->Bands > 1 && saveable == VIPS_SAVEABLE_MONO ) { VipsImage *out; @@ -1601,7 +1601,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, else { VipsImage *out; - if( vips_rshift_const1( in, &out, 8, NULL ) ) { + if( vips_rshift_const1( in, &out, 8, NULL ) ) { g_object_unref( in ); return( -1 ); } @@ -1609,7 +1609,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; - /* That could have produced an int image ... make sure + /* That could have produced an int image ... make sure * we are now uchar. */ if( vips_cast( in, &out, VIPS_FORMAT_UCHAR, NULL ) ) { @@ -1666,16 +1666,16 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* Some format libraries, like libpng, will throw a hard error if the + /* Some format libraries, like libpng, will throw a hard error if the * profile is inappropriate for this image type. With profiles inherited - * from a source image, this can happen all the time, so we + * from a source image, this can happen all the time, so we * want to silently drop the profile in this case. */ if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { const void *data; size_t length; - if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, + if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, &data, &length ) && !vips_icc_is_compatible_profile( in, data, length ) ) { VipsImage *out; @@ -1703,7 +1703,7 @@ vips_foreign_save_build( VipsObject *object ) VipsForeignSave *save = VIPS_FOREIGN_SAVE( object ); if( save->in ) { - VipsForeignSaveClass *class = + VipsForeignSaveClass *class = VIPS_FOREIGN_SAVE_GET_CLASS( save ); VipsImage *ready; @@ -1722,7 +1722,7 @@ vips_foreign_save_build( VipsObject *object ) VIPS_UNREF( ready ); ready = x; - vips_image_set_int( ready, + vips_image_set_int( ready, VIPS_META_PAGE_HEIGHT, save->page_height ); } @@ -1749,7 +1749,7 @@ vips_foreign_save_build( VipsObject *object ) #define DX VIPS_FORMAT_DPCOMPLEX static int vips_foreign_save_format_table[10] = { -// UC C US S UI I F X D DX +// UC C US S UI I F X D DX UC, C, US, S, UI, I, F, X, D, DX }; @@ -1772,9 +1772,9 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) object_class->nickname = "save"; object_class->description = _( "savers" ); - /* All savers are sequential by definition. Things like tiled tiff - * write and interlaced png write, which are not, add extra caches - * on their input. + /* All savers are sequential by definition. Things like tiled tiff + * write and interlaced png write, which are not, add extra caches + * on their input. */ operation_class->flags |= VIPS_OPERATION_SEQUENTIAL; @@ -1790,10 +1790,10 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) /* Default to no cast on save. */ - class->format_table = vips_foreign_save_format_table; + class->format_table = vips_foreign_save_format_table; - VIPS_ARG_IMAGE( class, "in", 0, - _( "Input" ), + VIPS_ARG_IMAGE( class, "in", 0, + _( "Input" ), _( "Image to save" ), VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignSave, in ) ); @@ -1805,19 +1805,19 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) G_STRUCT_OFFSET( VipsForeignSave, strip ), FALSE ); - VIPS_ARG_BOXED( class, "background", 101, - _( "Background" ), + VIPS_ARG_BOXED( class, "background", 101, + _( "Background" ), _( "Background value" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignSave, background ), VIPS_TYPE_ARRAY_DOUBLE ); - VIPS_ARG_INT( class, "page_height", 102, - _( "Page height" ), + VIPS_ARG_INT( class, "page_height", 102, + _( "Page height" ), _( "Set page height for multipage save" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignSave, page_height ), - 0, VIPS_MAX_COORD, 0 ); + 0, VIPS_MAX_COORD, 0 ); } @@ -1827,10 +1827,10 @@ vips_foreign_save_init( VipsForeignSave *save ) save->background = vips_array_double_newv( 1, 0.0 ); } -/* Can we write this filename with this class? +/* Can we write this filename with this class? */ static void * -vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, const char *filename, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); @@ -1838,7 +1838,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, const char **p; - /* All savers needs suffs defined since we use the suff to pick the + /* All savers needs suffs defined since we use the suff to pick the * saver. */ if( !class->suffs ) @@ -1854,7 +1854,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, * end of the filename, so we can test directly against the suffix. */ for( p = class->suffs; *p; p++ ) - if( vips_iscasepostfix( filename, *p ) ) + if( vips_iscasepostfix( filename, *p ) ) return( save_class ); return( NULL ); @@ -1865,7 +1865,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, * @filename: name to find a saver for * * Searches for an operation you could use to write to @filename. - * Any trailing options on @filename are stripped and ignored. + * Any trailing options on @filename are stripped and ignored. * * See also: vips_foreign_find_save_buffer(), vips_image_write_to_file(). * @@ -1880,9 +1880,9 @@ vips_foreign_find_save( const char *name ) vips__filename_split8( name, filename, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_sub, + (VipsSListMap2Fn) vips_foreign_find_save_sub, (void *) filename, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known file format" ), name ); @@ -1894,7 +1894,7 @@ vips_foreign_find_save( const char *name ) } static void * -vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, +vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, void *a, void *b ) { VipsForeignClass *foreign_class = VIPS_FOREIGN_CLASS( save_class ); @@ -1906,11 +1906,11 @@ vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, for( i = 0; foreign_class->suffs[i]; i++ ) *n_fields += 1; - return( NULL ); + return( NULL ); } static void * -vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, +vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, void *a, void *b ) { VipsForeignClass *foreign_class = VIPS_FOREIGN_CLASS( save_class ); @@ -1920,29 +1920,29 @@ vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, if( foreign_class->suffs ) for( i = 0; foreign_class->suffs[i]; i++ ) { - **p = g_strdup( foreign_class->suffs[i] ); + **p = g_strdup( foreign_class->suffs[i] ); *p += 1; } - return( NULL ); + return( NULL ); } /** * vips_foreign_get_suffixes: * - * Get a %NULL-terminated array listing all the supported suffixes. + * Get a %NULL-terminated array listing all the supported suffixes. * - * This is not the same as all the supported file types, since libvips - * detects image format for load by testing the first few bytes. + * This is not the same as all the supported file types, since libvips + * detects image format for load by testing the first few bytes. * * Use vips_foreign_find_load() to detect type for a specific file. * * Free the return result with g_strfreev(). * - * Returns: (transfer full) (array): all supported file extensions, as a - * %NULL-terminated array. + * Returns: (transfer full) (array): all supported file extensions, as a + * %NULL-terminated array. */ -gchar ** +gchar ** vips_foreign_get_suffixes( void ) { int n_suffs; @@ -1950,19 +1950,19 @@ vips_foreign_get_suffixes( void ) gchar **p; n_suffs = 0; - (void) vips_foreign_map( + (void) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_get_suffixes_count_cb, + (VipsSListMap2Fn) vips_foreign_get_suffixes_count_cb, &n_suffs, NULL ); - suffs = g_new0( gchar *, n_suffs + 1 ); + suffs = g_new0( gchar *, n_suffs + 1 ); p = suffs; - (void) vips_foreign_map( + (void) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_get_suffixes_add_cb, + (VipsSListMap2Fn) vips_foreign_get_suffixes_add_cb, &p, NULL ); - return( suffs ); + return( suffs ); } /* Kept for early vips8 API compat. @@ -1983,7 +1983,7 @@ vips_foreign_save( VipsImage *in, const char *name, ... ) return( -1 ); va_start( ap, name ); - result = vips_call_split_option_string( operation_name, option_string, + result = vips_call_split_option_string( operation_name, option_string, ap, in, filename ); va_end( ap ); @@ -1993,13 +1993,13 @@ vips_foreign_save( VipsImage *in, const char *name, ... ) /* Can this class write this filetype to a target? */ static void * -vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, const char *suffix, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class ); - /* All concrete savers needs suffs, since we use the suff to pick the + /* All concrete savers needs suffs, since we use the suff to pick the * saver. */ if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) && @@ -2020,7 +2020,7 @@ vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, * @suffix: format to find a saver for * * Searches for an operation you could use to write to a target in @suffix - * format. + * format. * * See also: vips_image_write_to_buffer(). * @@ -2035,9 +2035,9 @@ vips_foreign_find_save_target( const char *name ) vips__filename_split8( name, suffix, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_target_sub, + (VipsSListMap2Fn) vips_foreign_find_save_target_sub, (void *) suffix, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known target format" ), name ); @@ -2051,13 +2051,13 @@ vips_foreign_find_save_target( const char *name ) /* Can we write this buffer with this file type? */ static void * -vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, const char *suffix, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class ); - /* All concrete savers needs suffs, since we use the suff to pick the + /* All concrete savers needs suffs, since we use the suff to pick the * saver. */ if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) && @@ -2078,7 +2078,7 @@ vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, * @suffix: name to find a saver for * * Searches for an operation you could use to write to a buffer in @suffix - * format. + * format. * * See also: vips_image_write_to_buffer(). * @@ -2093,9 +2093,9 @@ vips_foreign_find_save_buffer( const char *name ) vips__filename_split8( name, suffix, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_buffer_sub, + (VipsSListMap2Fn) vips_foreign_find_save_buffer_sub, (void *) suffix, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known buffer format" ), name ); @@ -2122,16 +2122,16 @@ vips_foreign_find_save_buffer( const char *name ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Read a HEIF image file into a VIPS image. + * Read a HEIF image file into a VIPS image. * * Use @page to select a page to render, numbering from zero. If neither @n * nor @page are set, @page defaults to the primary page, otherwise to 0. * * Use @n to select the number of pages to render. The default is 1. Pages are - * rendered in a vertical column. Set to -1 to mean "until the end of the + * rendered in a vertical column. Set to -1 to mean "until the end of the * document". Use vips_grid() to reorganise pages. * - * HEIF images have a primary image. The metadata item `heif-primary` gives + * HEIF images have a primary image. The metadata item `heif-primary` gives * the page number of the primary. * * If @thumbnail is %TRUE, then fetch a stored thumbnail rather than the @@ -2174,11 +2174,11 @@ vips_heifload( const char *filename, VipsImage **out, ... ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Read a HEIF image file into a VIPS image. - * Exactly as vips_heifload(), but read from a memory buffer. + * Read a HEIF image file into a VIPS image. + * Exactly as vips_heifload(), but read from a memory buffer. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_heifload(). * @@ -2217,7 +2217,7 @@ vips_heifload_buffer( void *buf, size_t len, VipsImage **out, ... ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Exactly as vips_heifload(), but read from a source. + * Exactly as vips_heifload(), but read from a source. * * See also: vips_heifload(). * @@ -2238,8 +2238,8 @@ vips_heifload_source( VipsSource *source, VipsImage **out, ... ) /** * vips_heifsave: (method) - * @in: image to save - * @filename: file to write to + * @in: image to save + * @filename: file to write to * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -2251,7 +2251,7 @@ vips_heifload_source( VipsSource *source, VipsImage **out, ... ) * * @effort: %gint, encoding effort * * @subsample_mode: #VipsForeignSubsample, chroma subsampling mode * - * Write a VIPS image to a file in HEIF format. + * Write a VIPS image to a file in HEIF format. * * Use @Q to set the compression factor. Default 50, which seems to be roughly * what the iphone uses. Q 30 gives about the same quality as JPEG Q 75. @@ -2290,7 +2290,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) /** * vips_heifsave_buffer: (method) - * @in: image to save + * @in: image to save * @buf: (array length=len) (element-type guint8): return output buffer here * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments @@ -2304,7 +2304,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) * * @effort: %gint, encoding effort * * @subsample_mode: #VipsForeignSubsample, chroma subsampling mode * - * As vips_heifsave(), but save to a memory buffer. + * As vips_heifsave(), but save to a memory buffer. * * The address of the buffer is returned in @obuf, the length of the buffer in * @olen. You are responsible for freeing the buffer with g_free() when you @@ -2321,19 +2321,19 @@ vips_heifsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) VipsArea *area; int result; - area = NULL; + area = NULL; va_start( ap, len ); result = vips_call_split( "heifsave_buffer", ap, in, &area ); va_end( ap ); if( !result && - area ) { + area ) { if( buf ) { *buf = area->data; area->free_fn = NULL; } - if( len ) + if( len ) *len = area->length; vips_area_unref( area ); @@ -2344,7 +2344,7 @@ vips_heifsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) /** * vips_heifsave_target: (method) - * @in: image to save + * @in: image to save * @target: save image to this target * @...: %NULL-terminated list of optional named arguments * @@ -2382,7 +2382,7 @@ vips_heifsave_target( VipsImage *in, VipsTarget *target, ... ) * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * - * Read a JPEG-XL image. + * Read a JPEG-XL image. * * The JPEG-XL loader and saver are experimental features and may change * in future libvips versions. @@ -2411,7 +2411,7 @@ vips_jxlload( const char *filename, VipsImage **out, ... ) * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_jxlload(), but read from a buffer. + * Exactly as vips_jxlload(), but read from a buffer. * * Returns: 0 on success, -1 on error. */ @@ -2441,7 +2441,7 @@ vips_jxlload_buffer( void *buf, size_t len, VipsImage **out, ... ) * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_jxlload(), but read from a source. + * Exactly as vips_jxlload(), but read from a source. * * Returns: 0 on success, -1 on error. */ @@ -2460,8 +2460,8 @@ vips_jxlload_source( VipsSource *source, VipsImage **out, ... ) /** * vips_jxlsave: (method) - * @in: image to save - * @filename: file to write to + * @in: image to save + * @filename: file to write to * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -2472,17 +2472,17 @@ vips_jxlload_source( VipsSource *source, VipsImage **out, ... ) * * @lossless: %gboolean, enables lossless compression * * @Q: %gint, quality setting * - * Write a VIPS image to a file in JPEG-XL format. + * Write a VIPS image to a file in JPEG-XL format. * * The JPEG-XL loader and saver are experimental features and may change * in future libvips versions. * - * @tier sets the overall decode speed the encoder will target. Minimum is 0 + * @tier sets the overall decode speed the encoder will target. Minimum is 0 * (highest quality), and maximum is 4 (lowest quality). Default is 0. * - * @distance sets the target maximum encoding error. Minimum is 0 + * @distance sets the target maximum encoding error. Minimum is 0 * (highest quality), and maximum is 15 (lowest quality). Default is 1.0 - * (visually lossless). + * (visually lossless). * * As a convenience, you can also use @Q to set @distance. @Q uses * approximately the same scale as regular JPEG. @@ -2506,7 +2506,7 @@ vips_jxlsave( VipsImage *in, const char *filename, ... ) /** * vips_jxlsave_buffer: (method) - * @in: image to save + * @in: image to save * @buf: (array length=len) (element-type guint8): return output buffer here * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments @@ -2532,19 +2532,19 @@ vips_jxlsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) VipsArea *area; int result; - area = NULL; + area = NULL; va_start( ap, len ); result = vips_call_split( "jxlsave_buffer", ap, in, &area ); va_end( ap ); if( !result && - area ) { + area ) { if( buf ) { *buf = area->data; area->free_fn = NULL; } - if( len ) + if( len ) *len = area->length; vips_area_unref( area ); @@ -2555,7 +2555,7 @@ vips_jxlsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) /** * vips_jxlsave_target: (method) - * @in: image to save + * @in: image to save * @target: save image to this target * @...: %NULL-terminated list of optional named arguments * @@ -2601,7 +2601,7 @@ vips_jxlsave_target( VipsImage *in, VipsTarget *target, ... ) * * @background: #VipsArrayDouble background colour * * @password: %gchararray background colour * - * Render a PDF file into a VIPS image. + * Render a PDF file into a VIPS image. * * The output image is always RGBA --- CMYK PDFs will be * converted. If you need CMYK bitmaps, you should use vips_magickload() @@ -2611,19 +2611,19 @@ vips_jxlsave_target( VipsImage *in, VipsTarget *target, ... ) * * 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() + * left. Set to -1 to mean "until the end of the document". Use vips_grid() * to change page layout. * * Use @dpi to set the rendering resolution. The default is 72. Additionally, * you can scale by setting @scale. If you set both, they combine. * - * Use @background to set the background RGBA colour. The default is 255 + * Use @background to set the background RGBA colour. The default is 255 * (solid white), use eg. 0 for a transparent background. * * Use @password to supply a decryption password. * * The operation fills a number of header fields with metadata, for example - * "pdf-author". They may be useful. + * "pdf-author". They may be useful. * * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. @@ -2661,10 +2661,10 @@ vips_pdfload( const char *filename, VipsImage **out, ... ) * * @background: #VipsArrayDouble background colour * * Read a PDF-formatted memory buffer into a VIPS image. Exactly as - * vips_pdfload(), but read from memory. + * vips_pdfload(), but read from memory. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_pdfload(). * @@ -2704,7 +2704,7 @@ vips_pdfload_buffer( void *buf, size_t len, VipsImage **out, ... ) * * @scale: %gdouble, scale render by this factor * * @background: #VipsArrayDouble background colour * - * Exactly as vips_pdfload(), but read from a source. + * Exactly as vips_pdfload(), but read from a source. * * See also: vips_pdfload() * @@ -2789,7 +2789,7 @@ vips_openslideload( const char *filename, VipsImage **out, ... ) * * @attach_associated: %gboolean, attach all associated images as metadata * * @autocrop: %gboolean, crop to image bounds * - * Exactly as vips_openslideload(), but read from a source. + * Exactly as vips_openslideload(), but read from a source. * * Returns: 0 on success, -1 on error. */ @@ -2812,84 +2812,84 @@ vips_openslideload_source( VipsSource *source, VipsImage **out, ... ) void vips_foreign_operation_init( void ) { - extern GType vips_foreign_load_rad_file_get_type( void ); - extern GType vips_foreign_load_rad_buffer_get_type( void ); - extern GType vips_foreign_load_rad_source_get_type( void ); - extern GType vips_foreign_save_rad_file_get_type( void ); - extern GType vips_foreign_save_rad_buffer_get_type( void ); - extern GType vips_foreign_save_rad_target_get_type( void ); + extern GType vips_foreign_load_rad_file_get_type( void ); + extern GType vips_foreign_load_rad_buffer_get_type( void ); + extern GType vips_foreign_load_rad_source_get_type( void ); + extern GType vips_foreign_save_rad_file_get_type( void ); + extern GType vips_foreign_save_rad_buffer_get_type( void ); + extern GType vips_foreign_save_rad_target_get_type( void ); - extern GType vips_foreign_load_mat_get_type( void ); + extern GType vips_foreign_load_mat_get_type( void ); - extern GType vips_foreign_load_ppm_file_get_type( void ); - extern GType vips_foreign_load_ppm_source_get_type( void ); - extern GType vips_foreign_save_ppm_file_get_type( void ); - extern GType vips_foreign_save_pbm_target_get_type( void ); + extern GType vips_foreign_load_ppm_file_get_type( void ); + extern GType vips_foreign_load_ppm_source_get_type( void ); + extern GType vips_foreign_save_ppm_file_get_type( void ); + extern GType vips_foreign_save_pbm_target_get_type( void ); extern GType vips_foreign_save_pgm_target_get_type( void ); - extern GType vips_foreign_save_ppm_target_get_type( void ); - extern GType vips_foreign_save_pfm_target_get_type( void ); - - extern GType vips_foreign_load_png_file_get_type( void ); - extern GType vips_foreign_load_png_buffer_get_type( void ); - extern GType vips_foreign_load_png_source_get_type( void ); - extern GType vips_foreign_save_png_file_get_type( void ); - extern GType vips_foreign_save_png_buffer_get_type( void ); - extern GType vips_foreign_save_png_target_get_type( void ); - - extern GType vips_foreign_save_spng_file_get_type( void ); - extern GType vips_foreign_save_spng_buffer_get_type( void ); - extern GType vips_foreign_save_spng_target_get_type( void ); - - extern GType vips_foreign_load_csv_file_get_type( void ); - extern GType vips_foreign_load_csv_source_get_type( void ); - extern GType vips_foreign_save_csv_file_get_type( void ); - extern GType vips_foreign_save_csv_target_get_type( void ); - - extern GType vips_foreign_load_matrix_file_get_type( void ); - extern GType vips_foreign_load_matrix_source_get_type( void ); - extern GType vips_foreign_save_matrix_file_get_type( void ); - extern GType vips_foreign_save_matrix_target_get_type( void ); - extern GType vips_foreign_print_matrix_get_type( void ); - - extern GType vips_foreign_load_fits_file_get_type( void ); - extern GType vips_foreign_load_fits_source_get_type( void ); - extern GType vips_foreign_save_fits_get_type( void ); - - extern GType vips_foreign_load_analyze_get_type( void ); - - extern GType vips_foreign_load_openexr_get_type( void ); - - extern GType vips_foreign_load_openslide_file_get_type( void ); - extern GType vips_foreign_load_openslide_source_get_type( void ); - - extern GType vips_foreign_load_vips_file_get_type( void ); - extern GType vips_foreign_load_vips_source_get_type( void ); - extern GType vips_foreign_save_vips_file_get_type( void ); - extern GType vips_foreign_save_vips_target_get_type( void ); - - extern GType vips_foreign_load_jpeg_file_get_type( void ); - extern GType vips_foreign_load_jpeg_buffer_get_type( void ); - extern GType vips_foreign_load_jpeg_source_get_type( void ); - extern GType vips_foreign_save_jpeg_file_get_type( void ); - extern GType vips_foreign_save_jpeg_buffer_get_type( void ); - extern GType vips_foreign_save_jpeg_target_get_type( void ); - extern GType vips_foreign_save_jpeg_mime_get_type( void ); - - extern GType vips_foreign_load_tiff_file_get_type( void ); - extern GType vips_foreign_load_tiff_buffer_get_type( void ); - extern GType vips_foreign_load_tiff_source_get_type( void ); - extern GType vips_foreign_save_tiff_file_get_type( void ); - extern GType vips_foreign_save_tiff_buffer_get_type( void ); - extern GType vips_foreign_save_tiff_target_get_type( void ); - - extern GType vips_foreign_load_raw_get_type( void ); - extern GType vips_foreign_save_raw_get_type( void ); - extern GType vips_foreign_save_raw_fd_get_type( void ); - - extern GType vips_foreign_load_magick_file_get_type( void ); - extern GType vips_foreign_load_magick_buffer_get_type( void ); - extern GType vips_foreign_load_magick7_file_get_type( void ); - extern GType vips_foreign_load_magick7_buffer_get_type( void ); + extern GType vips_foreign_save_ppm_target_get_type( void ); + extern GType vips_foreign_save_pfm_target_get_type( void ); + + extern GType vips_foreign_load_png_file_get_type( void ); + extern GType vips_foreign_load_png_buffer_get_type( void ); + extern GType vips_foreign_load_png_source_get_type( void ); + extern GType vips_foreign_save_png_file_get_type( void ); + extern GType vips_foreign_save_png_buffer_get_type( void ); + extern GType vips_foreign_save_png_target_get_type( void ); + + extern GType vips_foreign_save_spng_file_get_type( void ); + extern GType vips_foreign_save_spng_buffer_get_type( void ); + extern GType vips_foreign_save_spng_target_get_type( void ); + + extern GType vips_foreign_load_csv_file_get_type( void ); + extern GType vips_foreign_load_csv_source_get_type( void ); + extern GType vips_foreign_save_csv_file_get_type( void ); + extern GType vips_foreign_save_csv_target_get_type( void ); + + extern GType vips_foreign_load_matrix_file_get_type( void ); + extern GType vips_foreign_load_matrix_source_get_type( void ); + extern GType vips_foreign_save_matrix_file_get_type( void ); + extern GType vips_foreign_save_matrix_target_get_type( void ); + extern GType vips_foreign_print_matrix_get_type( void ); + + extern GType vips_foreign_load_fits_file_get_type( void ); + extern GType vips_foreign_load_fits_source_get_type( void ); + extern GType vips_foreign_save_fits_get_type( void ); + + extern GType vips_foreign_load_analyze_get_type( void ); + + extern GType vips_foreign_load_openexr_get_type( void ); + + extern GType vips_foreign_load_openslide_file_get_type( void ); + extern GType vips_foreign_load_openslide_source_get_type( void ); + + extern GType vips_foreign_load_vips_file_get_type( void ); + extern GType vips_foreign_load_vips_source_get_type( void ); + extern GType vips_foreign_save_vips_file_get_type( void ); + extern GType vips_foreign_save_vips_target_get_type( void ); + + extern GType vips_foreign_load_jpeg_file_get_type( void ); + extern GType vips_foreign_load_jpeg_buffer_get_type( void ); + extern GType vips_foreign_load_jpeg_source_get_type( void ); + extern GType vips_foreign_save_jpeg_file_get_type( void ); + extern GType vips_foreign_save_jpeg_buffer_get_type( void ); + extern GType vips_foreign_save_jpeg_target_get_type( void ); + extern GType vips_foreign_save_jpeg_mime_get_type( void ); + + extern GType vips_foreign_load_tiff_file_get_type( void ); + extern GType vips_foreign_load_tiff_buffer_get_type( void ); + extern GType vips_foreign_load_tiff_source_get_type( void ); + extern GType vips_foreign_save_tiff_file_get_type( void ); + extern GType vips_foreign_save_tiff_buffer_get_type( void ); + extern GType vips_foreign_save_tiff_target_get_type( void ); + + extern GType vips_foreign_load_raw_get_type( void ); + extern GType vips_foreign_save_raw_get_type( void ); + extern GType vips_foreign_save_raw_fd_get_type( void ); + + extern GType vips_foreign_load_magick_file_get_type( void ); + extern GType vips_foreign_load_magick_buffer_get_type( void ); + extern GType vips_foreign_load_magick7_file_get_type( void ); + extern GType vips_foreign_load_magick7_buffer_get_type( void ); extern GType vips_foreign_save_magick_file_get_type( void ); extern GType vips_foreign_save_magick_buffer_get_type( void ); @@ -2898,142 +2898,144 @@ vips_foreign_operation_init( void ) extern GType vips_foreign_save_magick_gif_file_get_type( void ); extern GType vips_foreign_save_magick_gif_buffer_get_type( void ); - extern GType vips_foreign_save_dz_file_get_type( void ); - extern GType vips_foreign_save_dz_buffer_get_type( void ); - extern GType vips_foreign_save_dz_target_get_type( void ); - - extern GType vips_foreign_load_webp_file_get_type( void ); - extern GType vips_foreign_load_webp_buffer_get_type( void ); - extern GType vips_foreign_load_webp_source_get_type( void ); - extern GType vips_foreign_save_webp_file_get_type( void ); - extern GType vips_foreign_save_webp_buffer_get_type( void ); - extern GType vips_foreign_save_webp_target_get_type( void ); - - extern GType vips_foreign_load_pdf_file_get_type( void ); - extern GType vips_foreign_load_pdf_buffer_get_type( void ); - extern GType vips_foreign_load_pdf_source_get_type( void ); - - extern GType vips_foreign_load_svg_file_get_type( void ); - extern GType vips_foreign_load_svg_buffer_get_type( void ); - extern GType vips_foreign_load_svg_source_get_type( void ); - - extern GType vips_foreign_load_jp2k_file_get_type( void ); - extern GType vips_foreign_load_jp2k_buffer_get_type( void ); - extern GType vips_foreign_load_jp2k_source_get_type( void ); - extern GType vips_foreign_save_jp2k_file_get_type( void ); - extern GType vips_foreign_save_jp2k_buffer_get_type( void ); - extern GType vips_foreign_save_jp2k_target_get_type( void ); - - extern GType vips_foreign_load_jxl_file_get_type( void ); - extern GType vips_foreign_load_jxl_buffer_get_type( void ); - extern GType vips_foreign_load_jxl_source_get_type( void ); - extern GType vips_foreign_save_jxl_file_get_type( void ); - extern GType vips_foreign_save_jxl_buffer_get_type( void ); - extern GType vips_foreign_save_jxl_target_get_type( void ); - - extern GType vips_foreign_load_heif_file_get_type( void ); - extern GType vips_foreign_load_heif_buffer_get_type( void ); - extern GType vips_foreign_load_heif_source_get_type( void ); - extern GType vips_foreign_save_heif_file_get_type( void ); - extern GType vips_foreign_save_heif_buffer_get_type( void ); - extern GType vips_foreign_save_heif_target_get_type( void ); - extern GType vips_foreign_save_avif_target_get_type( void ); - - extern GType vips_foreign_load_nifti_file_get_type( void ); - extern GType vips_foreign_load_nifti_source_get_type( void ); - extern GType vips_foreign_save_nifti_get_type( void ); - - extern GType vips_foreign_load_nsgif_file_get_type( void ); - extern GType vips_foreign_load_nsgif_buffer_get_type( void ); - extern GType vips_foreign_load_nsgif_source_get_type( void ); + extern GType vips_foreign_save_dz_file_get_type( void ); + extern GType vips_foreign_save_dz_buffer_get_type( void ); + extern GType vips_foreign_save_dz_target_get_type( void ); + + extern GType vips_foreign_load_webp_file_get_type( void ); + extern GType vips_foreign_load_webp_buffer_get_type( void ); + extern GType vips_foreign_load_webp_source_get_type( void ); + extern GType vips_foreign_save_webp_file_get_type( void ); + extern GType vips_foreign_save_webp_buffer_get_type( void ); + extern GType vips_foreign_save_webp_target_get_type( void ); + + extern GType vips_foreign_load_pdf_file_get_type( void ); + extern GType vips_foreign_load_pdf_buffer_get_type( void ); + extern GType vips_foreign_load_pdf_source_get_type( void ); + + extern GType vips_foreign_load_svg_file_get_type( void ); + extern GType vips_foreign_load_svg_buffer_get_type( void ); + extern GType vips_foreign_load_svg_source_get_type( void ); + + extern GType vips_foreign_load_jp2k_file_get_type( void ); + extern GType vips_foreign_load_jp2k_buffer_get_type( void ); + extern GType vips_foreign_load_jp2k_source_get_type( void ); + extern GType vips_foreign_save_jp2k_file_get_type( void ); + extern GType vips_foreign_save_jp2k_buffer_get_type( void ); + extern GType vips_foreign_save_jp2k_target_get_type( void ); + + extern GType vips_foreign_load_jxl_file_get_type( void ); + extern GType vips_foreign_load_jxl_buffer_get_type( void ); + extern GType vips_foreign_load_jxl_source_get_type( void ); + extern GType vips_foreign_save_jxl_file_get_type( void ); + extern GType vips_foreign_save_jxl_buffer_get_type( void ); + extern GType vips_foreign_save_jxl_target_get_type( void ); + + extern GType vips_foreign_load_heif_file_get_type( void ); + extern GType vips_foreign_load_heif_buffer_get_type( void ); + extern GType vips_foreign_load_heif_source_get_type( void ); + extern GType vips_foreign_save_heif_file_get_type( void ); + extern GType vips_foreign_save_heif_buffer_get_type( void ); + extern GType vips_foreign_save_heif_target_get_type( void ); + extern GType vips_foreign_save_avif_target_get_type( void ); + + extern GType vips_foreign_load_nifti_file_get_type( void ); + extern GType vips_foreign_load_nifti_source_get_type( void ); + extern GType vips_foreign_save_nifti_get_type( void ); + + extern GType vips_foreign_load_nsgif_file_get_type( void ); + extern GType vips_foreign_load_nsgif_buffer_get_type( void ); + extern GType vips_foreign_load_nsgif_source_get_type( void ); extern GType vips_foreign_save_cgif_file_get_type( void ); extern GType vips_foreign_save_cgif_buffer_get_type( void ); extern GType vips_foreign_save_cgif_target_get_type( void ); - vips_foreign_load_csv_file_get_type(); - vips_foreign_load_csv_source_get_type(); - vips_foreign_save_csv_file_get_type(); - vips_foreign_save_csv_target_get_type(); + vips_foreign_load_csv_file_get_type(); + vips_foreign_load_csv_source_get_type(); + vips_foreign_save_csv_file_get_type(); + vips_foreign_save_csv_target_get_type(); - vips_foreign_load_matrix_file_get_type(); - vips_foreign_load_matrix_source_get_type(); - vips_foreign_save_matrix_file_get_type(); - vips_foreign_save_matrix_target_get_type(); - vips_foreign_print_matrix_get_type(); + vips_foreign_load_matrix_file_get_type(); + vips_foreign_load_matrix_source_get_type(); + vips_foreign_save_matrix_file_get_type(); + vips_foreign_save_matrix_target_get_type(); + vips_foreign_print_matrix_get_type(); - vips_foreign_load_raw_get_type(); - vips_foreign_save_raw_get_type(); - vips_foreign_save_raw_fd_get_type(); + vips_foreign_load_raw_get_type(); + vips_foreign_save_raw_get_type(); + vips_foreign_save_raw_fd_get_type(); - vips_foreign_load_vips_file_get_type(); - vips_foreign_load_vips_source_get_type(); - vips_foreign_save_vips_file_get_type(); - vips_foreign_save_vips_target_get_type(); + vips_foreign_load_vips_file_get_type(); + vips_foreign_load_vips_source_get_type(); + vips_foreign_save_vips_file_get_type(); + vips_foreign_save_vips_target_get_type(); #ifdef HAVE_ANALYZE - vips_foreign_load_analyze_get_type(); + vips_foreign_load_analyze_get_type(); #endif /*HAVE_ANALYZE*/ #ifdef HAVE_PPM - vips_foreign_load_ppm_file_get_type(); - vips_foreign_load_ppm_source_get_type(); - vips_foreign_save_ppm_file_get_type(); - vips_foreign_save_pbm_target_get_type(); - vips_foreign_save_pgm_target_get_type(); - vips_foreign_save_ppm_target_get_type(); - vips_foreign_save_pfm_target_get_type(); + vips_foreign_load_ppm_file_get_type(); + vips_foreign_load_ppm_source_get_type(); + vips_foreign_save_ppm_file_get_type(); + vips_foreign_save_pbm_target_get_type(); + vips_foreign_save_pgm_target_get_type(); + vips_foreign_save_ppm_target_get_type(); + vips_foreign_save_pfm_target_get_type(); #endif /*HAVE_PPM*/ #ifdef HAVE_RADIANCE - vips_foreign_load_rad_file_get_type(); - vips_foreign_load_rad_buffer_get_type(); - vips_foreign_load_rad_source_get_type(); - vips_foreign_save_rad_file_get_type(); - vips_foreign_save_rad_buffer_get_type(); - vips_foreign_save_rad_target_get_type(); + vips_foreign_load_rad_file_get_type(); + vips_foreign_load_rad_buffer_get_type(); + vips_foreign_load_rad_source_get_type(); + vips_foreign_save_rad_file_get_type(); + vips_foreign_save_rad_buffer_get_type(); + vips_foreign_save_rad_target_get_type(); #endif /*HAVE_RADIANCE*/ #if defined(HAVE_POPPLER) && !defined(POPPLER_MODULE) - vips_foreign_load_pdf_file_get_type(); - vips_foreign_load_pdf_buffer_get_type(); - vips_foreign_load_pdf_source_get_type(); + vips_foreign_load_pdf_file_get_type(); + vips_foreign_load_pdf_buffer_get_type(); + vips_foreign_load_pdf_source_get_type(); #endif /*defined(HAVE_POPPLER) && !defined(POPPLER_MODULE)*/ #ifdef HAVE_PDFIUM - vips_foreign_load_pdf_file_get_type(); - vips_foreign_load_pdf_buffer_get_type(); - vips_foreign_load_pdf_source_get_type(); + vips_foreign_load_pdf_file_get_type(); + vips_foreign_load_pdf_buffer_get_type(); + vips_foreign_load_pdf_source_get_type(); #endif /*HAVE_PDFIUM*/ -#ifdef HAVE_RSVG - vips_foreign_load_svg_file_get_type(); - vips_foreign_load_svg_buffer_get_type(); - vips_foreign_load_svg_source_get_type(); +#if defined(HAVE_RSVG) || defined(HAVE_RESVG) + vips_foreign_load_svg_file_get_type(); + vips_foreign_load_svg_buffer_get_type(); +#if defined(HAVE_RSVG) + vips_foreign_load_svg_source_get_type(); +#endif #endif /*HAVE_RSVG*/ #if defined(HAVE_LIBJXL) && !defined(LIBJXL_MODULE) - vips_foreign_load_jxl_file_get_type(); - vips_foreign_load_jxl_buffer_get_type(); - vips_foreign_load_jxl_source_get_type(); - vips_foreign_save_jxl_file_get_type(); - vips_foreign_save_jxl_buffer_get_type(); - vips_foreign_save_jxl_target_get_type(); + vips_foreign_load_jxl_file_get_type(); + vips_foreign_load_jxl_buffer_get_type(); + vips_foreign_load_jxl_source_get_type(); + vips_foreign_save_jxl_file_get_type(); + vips_foreign_save_jxl_buffer_get_type(); + vips_foreign_save_jxl_target_get_type(); #endif /*defined(HAVE_LIBJXL) && !defined(LIBJXL_MODULE)*/ #ifdef HAVE_LIBOPENJP2 - vips_foreign_load_jp2k_file_get_type(); - vips_foreign_load_jp2k_buffer_get_type(); - vips_foreign_load_jp2k_source_get_type(); - vips_foreign_save_jp2k_file_get_type(); - vips_foreign_save_jp2k_buffer_get_type(); - vips_foreign_save_jp2k_target_get_type(); + vips_foreign_load_jp2k_file_get_type(); + vips_foreign_load_jp2k_buffer_get_type(); + vips_foreign_load_jp2k_source_get_type(); + vips_foreign_save_jp2k_file_get_type(); + vips_foreign_save_jp2k_buffer_get_type(); + vips_foreign_save_jp2k_target_get_type(); #endif /*HAVE_LIBOPENJP2*/ #ifdef HAVE_NSGIF vips_foreign_load_nsgif_file_get_type(); - vips_foreign_load_nsgif_buffer_get_type(); - vips_foreign_load_nsgif_source_get_type(); + vips_foreign_load_nsgif_buffer_get_type(); + vips_foreign_load_nsgif_source_get_type(); #endif /*HAVE_NSGIF*/ #ifdef HAVE_CGIF @@ -3043,64 +3045,64 @@ vips_foreign_operation_init( void ) #endif /*HAVE_CGIF*/ #ifdef HAVE_GSF - vips_foreign_save_dz_file_get_type(); - vips_foreign_save_dz_buffer_get_type(); - vips_foreign_save_dz_target_get_type(); + vips_foreign_save_dz_file_get_type(); + vips_foreign_save_dz_buffer_get_type(); + vips_foreign_save_dz_target_get_type(); #endif /*HAVE_GSF*/ #ifdef HAVE_PNG - vips_foreign_load_png_file_get_type(); - vips_foreign_load_png_buffer_get_type(); - vips_foreign_load_png_source_get_type(); - vips_foreign_save_png_file_get_type(); - vips_foreign_save_png_buffer_get_type(); - vips_foreign_save_png_target_get_type(); + vips_foreign_load_png_file_get_type(); + vips_foreign_load_png_buffer_get_type(); + vips_foreign_load_png_source_get_type(); + vips_foreign_save_png_file_get_type(); + vips_foreign_save_png_buffer_get_type(); + vips_foreign_save_png_target_get_type(); #endif /*HAVE_PNG*/ #ifdef HAVE_SPNG - vips_foreign_load_png_file_get_type(); - vips_foreign_load_png_buffer_get_type(); - vips_foreign_load_png_source_get_type(); - vips_foreign_save_spng_file_get_type(); - vips_foreign_save_spng_buffer_get_type(); - vips_foreign_save_spng_target_get_type(); + vips_foreign_load_png_file_get_type(); + vips_foreign_load_png_buffer_get_type(); + vips_foreign_load_png_source_get_type(); + vips_foreign_save_spng_file_get_type(); + vips_foreign_save_spng_buffer_get_type(); + vips_foreign_save_spng_target_get_type(); #endif /*HAVE_SPNG*/ #ifdef HAVE_MATIO - vips_foreign_load_mat_get_type(); + vips_foreign_load_mat_get_type(); #endif /*HAVE_MATIO*/ #ifdef HAVE_JPEG - vips_foreign_load_jpeg_file_get_type(); - vips_foreign_load_jpeg_buffer_get_type(); - vips_foreign_load_jpeg_source_get_type(); - vips_foreign_save_jpeg_file_get_type(); - vips_foreign_save_jpeg_buffer_get_type(); - vips_foreign_save_jpeg_target_get_type(); - vips_foreign_save_jpeg_mime_get_type(); + vips_foreign_load_jpeg_file_get_type(); + vips_foreign_load_jpeg_buffer_get_type(); + vips_foreign_load_jpeg_source_get_type(); + vips_foreign_save_jpeg_file_get_type(); + vips_foreign_save_jpeg_buffer_get_type(); + vips_foreign_save_jpeg_target_get_type(); + vips_foreign_save_jpeg_mime_get_type(); #endif /*HAVE_JPEG*/ #ifdef HAVE_LIBWEBP - vips_foreign_load_webp_file_get_type(); - vips_foreign_load_webp_buffer_get_type(); - vips_foreign_load_webp_source_get_type(); - vips_foreign_save_webp_file_get_type(); - vips_foreign_save_webp_buffer_get_type(); - vips_foreign_save_webp_target_get_type(); + vips_foreign_load_webp_file_get_type(); + vips_foreign_load_webp_buffer_get_type(); + vips_foreign_load_webp_source_get_type(); + vips_foreign_save_webp_file_get_type(); + vips_foreign_save_webp_buffer_get_type(); + vips_foreign_save_webp_target_get_type(); #endif /*HAVE_LIBWEBP*/ #ifdef HAVE_TIFF - vips_foreign_load_tiff_file_get_type(); - vips_foreign_load_tiff_buffer_get_type(); - vips_foreign_load_tiff_source_get_type(); - vips_foreign_save_tiff_file_get_type(); - vips_foreign_save_tiff_buffer_get_type(); - vips_foreign_save_tiff_target_get_type(); + vips_foreign_load_tiff_file_get_type(); + vips_foreign_load_tiff_buffer_get_type(); + vips_foreign_load_tiff_source_get_type(); + vips_foreign_save_tiff_file_get_type(); + vips_foreign_save_tiff_buffer_get_type(); + vips_foreign_save_tiff_target_get_type(); #endif /*HAVE_TIFF*/ #if defined(HAVE_OPENSLIDE) && !defined(OPENSLIDE_MODULE) - vips_foreign_load_openslide_file_get_type(); - vips_foreign_load_openslide_source_get_type(); + vips_foreign_load_openslide_file_get_type(); + vips_foreign_load_openslide_source_get_type(); #endif /*defined(HAVE_OPENSLIDE) && !defined(OPENSLIDE_MODULE)*/ #if defined(ENABLE_MAGICKLOAD) && !defined(MAGICK_MODULE) @@ -3125,34 +3127,34 @@ vips_foreign_operation_init( void ) #endif /*defined(ENABLE_MAGICKSAVE) && !defined(MAGICK_MODULE)*/ #ifdef HAVE_CFITSIO - vips_foreign_load_fits_file_get_type(); - vips_foreign_load_fits_source_get_type(); - vips_foreign_save_fits_get_type(); + vips_foreign_load_fits_file_get_type(); + vips_foreign_load_fits_source_get_type(); + vips_foreign_save_fits_get_type(); #endif /*HAVE_CFITSIO*/ #ifdef HAVE_OPENEXR - vips_foreign_load_openexr_get_type(); + vips_foreign_load_openexr_get_type(); #endif /*HAVE_OPENEXR*/ #ifdef HAVE_NIFTI - vips_foreign_load_nifti_file_get_type(); - vips_foreign_load_nifti_source_get_type(); - vips_foreign_save_nifti_get_type(); + vips_foreign_load_nifti_file_get_type(); + vips_foreign_load_nifti_source_get_type(); + vips_foreign_save_nifti_get_type(); #endif /*HAVE_NIFTI*/ #if defined(HAVE_HEIF_DECODER) && !defined(HEIF_MODULE) - vips_foreign_load_heif_file_get_type(); - vips_foreign_load_heif_buffer_get_type(); - vips_foreign_load_heif_source_get_type(); + vips_foreign_load_heif_file_get_type(); + vips_foreign_load_heif_buffer_get_type(); + vips_foreign_load_heif_source_get_type(); #endif /*defined(HAVE_HEIF_DECODER) && !defined(HEIF_MODULE)*/ #if defined(HAVE_HEIF_ENCODER) && !defined(HEIF_MODULE) - vips_foreign_save_heif_file_get_type(); - vips_foreign_save_heif_buffer_get_type(); - vips_foreign_save_heif_target_get_type(); + vips_foreign_save_heif_file_get_type(); + vips_foreign_save_heif_buffer_get_type(); + vips_foreign_save_heif_target_get_type(); vips_foreign_save_avif_target_get_type(); #endif /*defined(HAVE_HEIF_ENCODER) && !defined(HEIF_MODULE)*/ - vips__foreign_load_operation = - g_quark_from_static_string( "vips-foreign-load-operation" ); + vips__foreign_load_operation = + g_quark_from_static_string( "vips-foreign-load-operation" ); } diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 2eb1541ff1..f607e59f13 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -21,7 +21,7 @@ * - rework as a sequential loader to reduce overcomputation * 11/6/21 * - switch to rsvg_handle_render_document() - * - librsvg can no longer render very large images :( + * - librsvg can no longer render very large images :( * 14/10/21 * - allow utf-8 headers for svg detection * 28/4/22 @@ -33,7 +33,7 @@ /* This file is part of VIPS. - + VIPS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -81,25 +81,38 @@ #include #include -/* Render SVGs with tiles this size. They need to be pretty big to limit - * overcomputation. +/* A handy #define for we-will-handle-svgz. */ -#define TILE_SIZE (2000) +#if LIBRSVG_CHECK_FEATURE(SVGZ) +#define HANDLE_SVGZ +#endif -/* The #define HANDLE_SVGZ + +#endif + +#if defined(HAVE_RSVG) || defined(HAVE_RESVG) + +#ifndef HAVE_ZLIB +#undef HANDLE_SVGZ #endif #ifdef HANDLE_SVGZ #include #endif +/* Render SVGs with tiles this size. They need to be pretty big to limit + * overcomputation. + */ +#define TILE_SIZE (2000) + +/* The = 18 && - str[0] == '\037' && + if( len >= 18 && + str[0] == '\037' && str[1] == '\213' ) { z_stream zs; size_t opos; @@ -259,7 +277,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) /* There isn't really an error return from is_a_buffer() */ - if( inflateInit2( &zs, 15 | 32 ) != Z_OK ) + if( inflateInit2( &zs, 15 | 32 ) != Z_OK ) return( FALSE ); opos = 0; @@ -271,7 +289,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) return( FALSE ); } opos = sizeof( obuf ) - zs.avail_out; - } while( opos < sizeof( obuf ) && + } while( opos < sizeof( obuf ) && zs.avail_in > 0 ); inflateEnd( &zs ); @@ -295,7 +313,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) * valid utf-8. * * We could rsvg_handle_new_from_data() on the buffer, but that can be - * horribly slow for large documents. + * horribly slow for large documents. */ if( vips_utf8_strcasestr( str, "page ); +#else + resvg_options_destroy( svg->options ); + if ( svg->tree ) { + resvg_tree_destroy( svg->tree ); + } +#endif G_OBJECT_CLASS( vips_foreign_load_svg_parent_class )-> dispose( gobject ); @@ -328,6 +353,7 @@ vips_foreign_load_svg_get_flags( VipsForeignLoad *load ) return( VIPS_FOREIGN_PARTIAL ); } +#ifdef HAVE_RSVG #if LIBRSVG_CHECK_VERSION( 2, 52, 0 ) /* Derived from `CssLength::to_user` in librsvg. * https://gitlab.gnome.org/GNOME/librsvg/-/blob/e6607c9ae8d8409d4efff6b12993717400b3356e/src/length.rs#L368 @@ -377,7 +403,7 @@ svg_css_length_to_pixels( RsvgLength length, double dpi ) value = dpi * value / 6; break; default: - /* Probably RSVG_UNIT_PERCENT. We can't know what the + /* Probably RSVG_UNIT_PERCENT. We can't know what the * pixel value is without more information. */ value = 0; @@ -386,9 +412,10 @@ svg_css_length_to_pixels( RsvgLength length, double dpi ) return value; } #endif +#endif static int -vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, +vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, double *out_width, double *out_height ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( svg ); @@ -396,9 +423,10 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, double width; double height; +#ifdef HAVE_RSVG #if LIBRSVG_CHECK_VERSION( 2, 52, 0 ) - if( !rsvg_handle_get_intrinsic_size_in_pixels( svg->page, + if( !rsvg_handle_get_intrinsic_size_in_pixels( svg->page, &width, &height ) ) { RsvgRectangle viewbox; @@ -414,8 +442,8 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, &has_viewbox, &viewbox ); #if LIBRSVG_CHECK_VERSION( 2, 54, 0 ) - /* After librsvg 2.54.0, the `has_width` and `has_height` - * arguments always returns `TRUE`, since with SVG2 all + /* After librsvg 2.54.0, the `has_width` and `has_height` + * arguments always returns `TRUE`, since with SVG2 all * documents *have* a default width and height of `100%`. */ width = svg_css_length_to_pixels( iwidth, svg->dpi ); @@ -425,7 +453,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, has_height = height > 0.0; if( has_width && has_height ) { - /* Success! Taking the viewbox into account is not + /* Success! Taking the viewbox into account is not * needed. */ } @@ -462,7 +490,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, if( width <= 0.0 || height <= 0.0 ) { - /* We haven't found a usable set of sizes, so try + /* We haven't found a usable set of sizes, so try * working out the visible area. */ rsvg_handle_get_geometry_for_element( svg->page, NULL, @@ -483,10 +511,15 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, } #endif /*LIBRSVG_CHECK_VERSION( 2, 52, 0 )*/ +#else /* HAVE_RSVG */ + resvg_size size = resvg_get_image_size(svg->tree); + width = size.width; + height = size.height; +#endif /* width or height below 0.5 can't be rounded to 1. */ - if( width < 0.5 || + if( width < 0.5 || height < 0.5 ) { vips_error( class->nickname, "%s", _( "bad dimensions" ) ); return( -1 ); @@ -499,7 +532,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, } static int -vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, +vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, int *out_width, int *out_height ) { double width; @@ -507,7 +540,11 @@ vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, /* Get dimensions with the default dpi. */ +#ifdef HAVE_RSVG rsvg_handle_set_dpi( svg->page, 72.0 ); +#else + resvg_options_set_dpi(svg->options, 72.0); +#endif if( vips_foreign_load_svg_get_natural_size( svg, &width, &height ) ) return( -1 ); @@ -538,12 +575,12 @@ vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, VipsImage *out ) */ res = svg->dpi / 25.4; - vips_image_init_fields( out, + vips_image_init_fields( out, width, height, 4, VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, VIPS_INTERPRETATION_sRGB, res, res ); - /* We render to a cache with a couple of rows of tiles, so fat strips + /* We render to a cache with a couple of rows of tiles, so fat strips * work well. */ if( vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL ) ) @@ -561,31 +598,33 @@ vips_foreign_load_svg_header( VipsForeignLoad *load ) } static int -vips_foreign_load_svg_generate( VipsRegion *or, +vips_foreign_load_svg_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { const VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) a; - const VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( svg ); const VipsRect *r = &or->valid; - cairo_surface_t *surface; - cairo_t *cr; - int y; - #ifdef DEBUG printf( "vips_foreign_load_svg_generate:\n " - "left = %d, top = %d, width = %d, height = %d\n", - r->left, r->top, r->width, r->height ); + "left = %d, top = %d, width = %d, height = %d\n", + r->left, r->top, r->width, r->height ); #endif /*DEBUG*/ - /* rsvg won't always paint the background. + /* SVG won't always paint the background. */ - vips_region_black( or ); + vips_region_black( or ); + +#ifdef HAVE_RSVG + const VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( svg ); - surface = cairo_image_surface_create_for_data( - VIPS_REGION_ADDR( or, r->left, r->top ), - CAIRO_FORMAT_ARGB32, - r->width, r->height, + cairo_surface_t *surface; + cairo_t *cr; + int y; + + surface = cairo_image_surface_create_for_data( + VIPS_REGION_ADDR( or, r->left, r->top ), + CAIRO_FORMAT_ARGB32, + r->width, r->height, VIPS_REGION_LSKIP( or ) ); cr = cairo_create( surface ); cairo_surface_destroy( surface ); @@ -611,7 +650,7 @@ vips_foreign_load_svg_generate( VipsRegion *or, if( !rsvg_handle_render_document( svg->page, cr, &viewport, &error ) ) { cairo_destroy( cr ); vips_operation_invalidate( VIPS_OPERATION( svg ) ); - vips_error( class->nickname, + vips_error( class->nickname, "%s", _( "SVG rendering failed" ) ); vips_g_error( &error ); return( -1 ); @@ -640,24 +679,56 @@ vips_foreign_load_svg_generate( VipsRegion *or, /* Cairo makes pre-multipled BRGA -- we must byteswap and unpremultiply. */ - for( y = 0; y < r->height; y++ ) - vips__premultiplied_bgra2rgba( + for( y = 0; y < r->height; y++ ) + vips__premultiplied_bgra2rgba( (guint32 *) VIPS_REGION_ADDR( or, r->left, r->top + y ), - r->width ); + r->width ); +#else + + guint8 *pixmap = VIPS_REGION_ADDR( or, r->left, r->top ); + + resvg_render( + svg->tree, + (resvg_fit_to) { .type = RESVG_FIT_TO_TYPE_ORIGINAL }, + (resvg_transform) { + .a = svg->cairo_scale, + .d = svg->cairo_scale, + .e = -r->left, + .f = -r->top, + }, + r->width, + r->height, + (char *) pixmap + ); + + // Just unpremultiply. + for (int i = 0; i < r->width * r->height; i++) { + guint8 *ptr = &pixmap[i * 4]; + guint8 a = ptr[3]; + // Skip transparent and fully opaque pixels. + if ( a != 0 && a != 255 ) { + // Any compiler will unroll it. + for (int i = 0; i < 3; i++) { + ptr[i] = 255 * ptr[i] / a; + } + } + } + +#endif - return( 0 ); + return( 0 ); } static int vips_foreign_load_svg_load( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsImage **t = (VipsImage **) + VipsImage **t = (VipsImage **) vips_object_local_array( (VipsObject *) load, 3 ); /* Enough tiles for two complete rows. */ - t[0] = vips_image_new(); + t[0] = vips_image_new(); if( vips_foreign_load_svg_parse( svg, t[0] ) || vips_image_generate( t[0], NULL, vips_foreign_load_svg_generate, NULL, svg, NULL ) || @@ -666,7 +737,7 @@ vips_foreign_load_svg_load( VipsForeignLoad *load ) "tile_height", TILE_SIZE, "max_tiles", 2 * (1 + t[0]->Xsize / TILE_SIZE), NULL ) || - vips_image_write( t[1], load->real ) ) + vips_image_write( t[1], load->real ) ) return( -1 ); return( 0 ); @@ -697,7 +768,7 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class ) */ foreign_class->priority = -5; - load_class->get_flags_filename = + load_class->get_flags_filename = vips_foreign_load_svg_get_flags_filename; load_class->get_flags = vips_foreign_load_svg_get_flags; load_class->load = vips_foreign_load_svg_load; @@ -731,8 +802,12 @@ vips_foreign_load_svg_init( VipsForeignLoadSvg *svg ) svg->dpi = 72.0; svg->scale = 1.0; svg->cairo_scale = 1.0; +#ifdef HAVE_RESVG + svg->options = resvg_options_create(); +#endif } +#ifdef HAVE_RSVG typedef struct _VipsForeignLoadSvgSource { VipsForeignLoadSvg parent_object; @@ -744,7 +819,7 @@ typedef struct _VipsForeignLoadSvgSource { typedef VipsForeignLoadClass VipsForeignLoadSvgSourceClass; -G_DEFINE_TYPE( VipsForeignLoadSvgSource, vips_foreign_load_svg_source, +G_DEFINE_TYPE( VipsForeignLoadSvgSource, vips_foreign_load_svg_source, vips_foreign_load_svg_get_type() ); gboolean @@ -753,7 +828,7 @@ vips_foreign_load_svg_source_is_a_source( VipsSource *source ) unsigned char *data; gint64 bytes_read; - if( (bytes_read = vips_source_sniff_at_most( source, + if( (bytes_read = vips_source_sniff_at_most( source, &data, SVG_HEADER_SIZE )) <= 0 ) return( FALSE ); @@ -764,7 +839,7 @@ static int vips_foreign_load_svg_source_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsForeignLoadSvgSource *source = + VipsForeignLoadSvgSource *source = (VipsForeignLoadSvgSource *) load; RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; @@ -776,14 +851,13 @@ vips_foreign_load_svg_source_header( VipsForeignLoad *load ) return( -1 ); gstream = vips_g_input_stream_new_from_source( source->source ); - if( !(svg->page = rsvg_handle_new_from_stream_sync( + if( !(svg->page = rsvg_handle_new_from_stream_sync( gstream, NULL, flags, NULL, &error )) ) { g_object_unref( gstream ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gstream ); - return( vips_foreign_load_svg_header( load ) ); } @@ -823,7 +897,7 @@ vips_foreign_load_svg_source_class_init( VipsForeignLoadSvgSourceClass *class ) VIPS_ARG_OBJECT( class, "source", 1, _( "Source" ), _( "Source to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgSource, source ), VIPS_TYPE_SOURCE ); @@ -833,19 +907,20 @@ static void vips_foreign_load_svg_source_init( VipsForeignLoadSvgSource *source ) { } +#endif typedef struct _VipsForeignLoadSvgFile { VipsForeignLoadSvg parent_object; /* Filename for load. */ - char *filename; + char *filename; } VipsForeignLoadSvgFile; typedef VipsForeignLoadSvgClass VipsForeignLoadSvgFileClass; -G_DEFINE_TYPE( VipsForeignLoadSvgFile, vips_foreign_load_svg_file, +G_DEFINE_TYPE( VipsForeignLoadSvgFile, vips_foreign_load_svg_file, vips_foreign_load_svg_get_type() ); static gboolean @@ -854,16 +929,36 @@ vips_foreign_load_svg_file_is_a( const char *filename ) unsigned char buf[SVG_HEADER_SIZE]; guint64 bytes; - return( (bytes = vips__get_bytes( filename, + return( (bytes = vips__get_bytes( filename, buf, SVG_HEADER_SIZE )) > 0 && vips_foreign_load_svg_is_a( buf, bytes ) ); } +static const char *resvg_error_msg(resvg_error e) { + switch (e) { + case RESVG_ERROR_NOT_AN_UTF8_STR: + return "only UTF-8 content is supported"; + case RESVG_ERROR_FILE_OPEN_FAILED: + return "failed to open the provided file"; + case RESVG_ERROR_MALFORMED_GZIP: + return "compressed SVG must use the GZip algorithm"; + case RESVG_ERROR_ELEMENTS_LIMIT_REACHED: + return "we do not allow SVG with more than 1_000_000 elements for security reasons"; + case RESVG_ERROR_INVALID_SIZE: + return "SVG doesn't have a valid size"; + case RESVG_ERROR_PARSING_FAILED: + return "failed to parse SVG data"; + default: + return "unknown error"; + } +} + static int vips_foreign_load_svg_file_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; VipsForeignLoadSvgFile *file = (VipsForeignLoadSvgFile *) load; +#ifdef HAVE_RSVG RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; GError *error = NULL; @@ -871,14 +966,20 @@ vips_foreign_load_svg_file_header( VipsForeignLoad *load ) GFile *gfile; gfile = g_file_new_for_path( file->filename ); - if( !(svg->page = rsvg_handle_new_from_gfile_sync( - gfile, flags, NULL, &error )) ) { + if( !(svg->page = rsvg_handle_new_from_gfile_sync( + gfile, flags, NULL, &error )) ) { g_object_unref( gfile ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gfile ); - +#else + resvg_error error = resvg_parse_tree_from_file(file->filename, svg->options, &svg->tree); + if (error != RESVG_OK) { + vips_error(VIPS_OBJECT_GET_CLASS( svg )->nickname, "%s", resvg_error_msg(error)); + return (-1); + } +#endif VIPS_SETSTR( load->out->filename, file->filename ); return( vips_foreign_load_svg_header( load ) ); @@ -888,7 +989,7 @@ static const char *vips_foreign_svg_suffs[] = { ".svg", /* librsvg supports svgz directly, no need to check for zlib here. */ -#if LIBRSVG_CHECK_FEATURE(SVGZ) +#ifdef HANDLE_SVGZ ".svgz", ".svg.gz", #endif @@ -896,7 +997,7 @@ static const char *vips_foreign_svg_suffs[] = { }; static void -vips_foreign_load_svg_file_class_init( +vips_foreign_load_svg_file_class_init( VipsForeignLoadSvgFileClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); @@ -914,10 +1015,10 @@ vips_foreign_load_svg_file_class_init( load_class->is_a = vips_foreign_load_svg_file_is_a; load_class->header = vips_foreign_load_svg_file_header; - VIPS_ARG_STRING( class, "filename", 1, + VIPS_ARG_STRING( class, "filename", 1, _( "Filename" ), _( "Filename to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgFile, filename ), NULL ); @@ -939,36 +1040,43 @@ typedef struct _VipsForeignLoadSvgBuffer { typedef VipsForeignLoadSvgClass VipsForeignLoadSvgBufferClass; -G_DEFINE_TYPE( VipsForeignLoadSvgBuffer, vips_foreign_load_svg_buffer, +G_DEFINE_TYPE( VipsForeignLoadSvgBuffer, vips_foreign_load_svg_buffer, vips_foreign_load_svg_get_type() ); static int vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsForeignLoadSvgBuffer *buffer = + VipsForeignLoadSvgBuffer *buffer = (VipsForeignLoadSvgBuffer *) load; +#ifdef HAVE_RSVG RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; GError *error = NULL; GInputStream *gstream; - gstream = g_memory_input_stream_new_from_data( + gstream = g_memory_input_stream_new_from_data( buffer->buf->data, buffer->buf->length, NULL ); - if( !(svg->page = rsvg_handle_new_from_stream_sync( - gstream, NULL, flags, NULL, &error )) ) { + if( !(svg->page = rsvg_handle_new_from_stream_sync( + gstream, NULL, flags, NULL, &error )) ) { g_object_unref( gstream ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gstream ); - +#else + resvg_error error = resvg_parse_tree_from_data(buffer->buf->data, buffer->buf->length, svg->options, &svg->tree); + if (error != RESVG_OK) { + vips_error(VIPS_OBJECT_GET_CLASS( svg )->nickname, "%s", resvg_error_msg(error)); + return (-1); + } +#endif return( vips_foreign_load_svg_header( load ) ); } static void -vips_foreign_load_svg_buffer_class_init( +vips_foreign_load_svg_buffer_class_init( VipsForeignLoadSvgBufferClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); @@ -983,10 +1091,10 @@ vips_foreign_load_svg_buffer_class_init( load_class->is_a_buffer = vips_foreign_load_svg_is_a; load_class->header = vips_foreign_load_svg_buffer_header; - VIPS_ARG_BOXED( class, "buffer", 1, + VIPS_ARG_BOXED( class, "buffer", 1, _( "Buffer" ), _( "Buffer to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgBuffer, buf ), VIPS_TYPE_BLOB ); @@ -1015,7 +1123,7 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) * and should be fast. * * Use @dpi to set the rendering resolution. The default is 72. You can also - * scale the rendering by @scale. + * scale the rendering by @scale. * * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. @@ -1054,10 +1162,10 @@ vips_svgload( const char *filename, VipsImage **out, ... ) * * @unlimited: %gboolean, allow SVGs of any size * * Read a SVG-formatted memory block into a VIPS image. Exactly as - * vips_svgload(), but read from a memory buffer. + * vips_svgload(), but read from a memory buffer. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_svgload(). * @@ -1128,7 +1236,7 @@ vips_svgload_string( const char *str, VipsImage **out, ... ) * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_svgload(), but read from a source. + * Exactly as vips_svgload(), but read from a source. * * See also: vips_svgload(). * @@ -1146,4 +1254,3 @@ vips_svgload_source( VipsSource *source, VipsImage **out, ... ) return( result ); } - diff --git a/meson.build b/meson.build index e67e45ecd1..b2ed5d876c 100644 --- a/meson.build +++ b/meson.build @@ -371,6 +371,16 @@ if librsvg_found cfg_var.set('HAVE_RSVG', '1') endif +# libresvg doesn't ship pkg-config files, so we can't use dependency(). +libresvg_dep = cc.find_library('resvg', has_headers: ['resvg.h'], required: get_option('resvg')) +libresvg_found = libresvg_dep.found() +if libresvg_found + # It's annoying that I have to spell out the `include_directories` here, but without it Meson can build + # but `compile_commands.json` doesn't have the -I$PREFIX/include, making code analysis tools & VSCode fail. + libvips_deps += declare_dependency(dependencies: [libresvg_dep], include_directories: [include_directories(get_option('prefix') / get_option('includedir'))], link_args: ['-ldl']) + cfg_var.set('HAVE_RESVG', '1') +endif + openslide_dep = dependency('openslide', version: '>=3.3.0', required: get_option('openslide')) openslide_module = false if openslide_dep.found() @@ -634,6 +644,7 @@ build_summary = { 'PDF load with PDFium': [pdfium_dep.found()], 'PDF load with poppler-glib': [libpoppler_found, ' (dynamic module: ', libpoppler_module, ')'], 'SVG load with librsvg': [librsvg_found], + 'SVG load with libresvg': [libresvg_found], 'EXR load with OpenEXR': [openexr_dep.found()], 'OpenSlide load': [openslide_dep.found(), ' (dynamic module: ', openslide_module, ')'], 'Matlab load with libmatio': [matio_dep.found()], diff --git a/meson_options.txt b/meson_options.txt index 375d1e5f05..0fbe593df7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -188,6 +188,11 @@ option('rsvg', value: 'auto', description: 'Build with rsvg') +option('resvg', + type: 'feature', + value: 'auto', + description: 'Build with resvg') + option('spng', type: 'feature', value: 'auto', From 0b75df254a478b29580ce5d92ba2ed272446883e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 17 Jan 2023 18:15:01 +0100 Subject: [PATCH 02/11] Revert whitespace-only changes --- libvips/foreign/foreign.c | 1042 ++++++++++++++++++------------------- libvips/foreign/svgload.c | 160 +++--- 2 files changed, 601 insertions(+), 601 deletions(-) diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 1517c142b6..521a6917de 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -81,41 +81,41 @@ * @include: vips/vips.h * @title: VipsForeign * - * This set of operations load and save images in a variety of formats. + * This set of operations load and save images in a variety of formats. * * The operations share a base class that offers a simple way to search for a * subclass of #VipsForeign which can load a certain file (see - * vips_foreign_find_load()) or buffer (see vips_foreign_find_load_buffer()), + * vips_foreign_find_load()) or buffer (see vips_foreign_find_load_buffer()), * or which could be used to save an image to a * certain file type (see vips_foreign_find_save() and * vips_foreign_find_save_buffer()). You can then run these * operations using vips_call() and friends to perform the load or save. * * vips_image_write_to_file() and vips_image_new_from_file() and friends use - * these functions to automate file load and save. + * these functions to automate file load and save. * * You can also invoke the operations directly, for example: * * |[ - * vips_tiffsave (my_image, "frank.anything", + * vips_tiffsave (my_image, "frank.anything", * "compression", VIPS_FOREIGN_TIFF_COMPRESSION_JPEG, * NULL); * ]| * * To add support for a new file format to vips, simply define a new subclass - * of #VipsForeignLoad or #VipsForeignSave. + * of #VipsForeignLoad or #VipsForeignSave. * - * If you define a new operation which is a subclass of #VipsForeign, support + * If you define a new operation which is a subclass of #VipsForeign, support * for it automatically appears in all VIPS user-interfaces. It will also be * transparently supported by vips_image_new_from_file() and friends. * * VIPS comes with VipsForeign for TIFF, JPEG, PNG, Analyze, PPM, OpenEXR, CSV, - * Matlab, Radiance, RAW, FITS, WebP, SVG, PDF, GIF and VIPS. It also includes - * import filters which can load with libMagick and with OpenSlide. + * Matlab, Radiance, RAW, FITS, WebP, SVG, PDF, GIF and VIPS. It also includes + * import filters which can load with libMagick and with OpenSlide. * * ## Writing a new loader * - * Add a new loader to VIPS by subclassing #VipsForeignLoad. Subclasses need to + * Add a new loader to VIPS by subclassing #VipsForeignLoad. Subclasses need to * implement at least @header(). * * @header() must set at least the header fields of @out. @load(), if defined, @@ -124,7 +124,7 @@ * The suffix list is used to select a format to save a file in, and to pick a * loader if you don't define is_a(). * - * You should also define @nickname and @description in #VipsObject. + * You should also define @nickname and @description in #VipsObject. * * As a complete example, here's code for a PNG loader, minus the actual * calls to libpng. @@ -132,59 +132,59 @@ * |[ * typedef struct _VipsForeignLoadPng { * VipsForeignLoad parent_object; - * - * char *filename; + * + * char *filename; * } VipsForeignLoadPng; - * + * * typedef VipsForeignLoadClass VipsForeignLoadPngClass; - * - * G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png, + * + * G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png, * VIPS_TYPE_FOREIGN_LOAD ); - * + * * static VipsForeignFlags * vips_foreign_load_png_get_flags_filename( const char *filename ) * { * VipsForeignFlags flags; - * + * * flags = 0; * if( vips__png_isinterlaced( filename ) ) * flags = VIPS_FOREIGN_PARTIAL; * else * flags = VIPS_FOREIGN_SEQUENTIAL; - * + * * return( flags ); * } - * + * * static VipsForeignFlags * vips_foreign_load_png_get_flags( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * return( vips_foreign_load_png_get_flags_filename( png->filename ) ); * } - * + * * static int * vips_foreign_load_png_header( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * if( vips__png_header( png->filename, load->out ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static int * vips_foreign_load_png_load( VipsForeignLoad *load ) * { * VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - * + * * if( vips__png_read( png->filename, load->real ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static void * vips_foreign_load_png_class_init( VipsForeignLoadPngClass *class ) * { @@ -192,40 +192,40 @@ * VipsObjectClass *object_class = (VipsObjectClass *) class; * VipsForeignClass *foreign_class = (VipsForeignClass *) class; * VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class; - * + * * gobject_class->set_property = vips_object_set_property; * gobject_class->get_property = vips_object_get_property; - * + * * object_class->nickname = "pngload"; * object_class->description = _( "load png from file" ); - * + * * foreign_class->suffs = vips__png_suffs; - * + * * load_class->is_a = vips__png_ispng; - * load_class->get_flags_filename = + * load_class->get_flags_filename = * vips_foreign_load_png_get_flags_filename; * load_class->get_flags = vips_foreign_load_png_get_flags; * load_class->header = vips_foreign_load_png_header; * load_class->load = vips_foreign_load_png_load; - * - * VIPS_ARG_STRING( class, "filename", 1, + * + * VIPS_ARG_STRING( class, "filename", 1, * _( "Filename" ), * _( "Filename to load from" ), - * VIPS_ARGUMENT_REQUIRED_INPUT, + * VIPS_ARGUMENT_REQUIRED_INPUT, * G_STRUCT_OFFSET( VipsForeignLoadPng, filename ), * NULL ); * } - * + * * static void * vips_foreign_load_png_init( VipsForeignLoadPng *png ) * { * } * ]| - * + * * ## Writing a new saver * * Call your saver in the class' @build() method after chaining up. The - * prepared image should be ready for you to save in @ready. + * prepared image should be ready for you to save in @ready. * * As a complete example, here's the code for the CSV saver, minus the calls * to the actual save routines. @@ -233,32 +233,32 @@ * |[ * typedef struct _VipsForeignSaveCsv { * VipsForeignSave parent_object; - * - * char *filename; + * + * char *filename; * const char *separator; * } VipsForeignSaveCsv; - * + * * typedef VipsForeignSaveClass VipsForeignSaveCsvClass; - * - * G_DEFINE_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv, + * + * G_DEFINE_TYPE( VipsForeignSaveCsv, vips_foreign_save_csv, * VIPS_TYPE_FOREIGN_SAVE ); - * + * * static int * vips_foreign_save_csv_build( VipsObject *object ) * { * VipsForeignSave *save = (VipsForeignSave *) object; * VipsForeignSaveCsv *csv = (VipsForeignSaveCsv *) object; - * + * * if( VIPS_OBJECT_CLASS( vips_foreign_save_csv_parent_class )-> * build( object ) ) * return( -1 ); - * + * * if( vips__csv_write( save->ready, csv->filename, csv->separator ) ) * return( -1 ); - * + * * return( 0 ); * } - * + * * static void * vips_foreign_save_csv_class_init( VipsForeignSaveCsvClass *class ) * { @@ -266,35 +266,35 @@ * VipsObjectClass *object_class = (VipsObjectClass *) class; * VipsForeignClass *foreign_class = (VipsForeignClass *) class; * VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class; - * + * * gobject_class->set_property = vips_object_set_property; * gobject_class->get_property = vips_object_get_property; - * + * * object_class->nickname = "csvsave"; * object_class->description = _( "save image to csv file" ); * object_class->build = vips_foreign_save_csv_build; - * + * * foreign_class->suffs = vips__foreign_csv_suffs; - * + * * save_class->saveable = VIPS_SAVEABLE_MONO; - * // no need to define ->format_table, we don't want the input + * // no need to define ->format_table, we don't want the input * // cast for us - * - * VIPS_ARG_STRING( class, "filename", 1, + * + * VIPS_ARG_STRING( class, "filename", 1, * _( "Filename" ), * _( "Filename to save to" ), - * VIPS_ARGUMENT_REQUIRED_INPUT, + * VIPS_ARGUMENT_REQUIRED_INPUT, * G_STRUCT_OFFSET( VipsForeignSaveCsv, filename ), * NULL ); - * - * VIPS_ARG_STRING( class, "separator", 13, - * _( "Separator" ), + * + * VIPS_ARG_STRING( class, "separator", 13, + * _( "Separator" ), * _( "Separator characters" ), * VIPS_ARGUMENT_OPTIONAL_INPUT, * G_STRUCT_OFFSET( VipsForeignSaveCsv, separator ), - * "\t" ); + * "\t" ); * } - * + * * static void * vips_foreign_save_csv_init( VipsForeignSaveCsv *csv ) * { @@ -303,12 +303,12 @@ * ]| */ -/* Use this to link images to the load operation that made them. +/* Use this to link images to the load operation that made them. */ -static GQuark vips__foreign_load_operation = 0; +static GQuark vips__foreign_load_operation = 0; /** - * VipsForeignFlags: + * VipsForeignFlags: * @VIPS_FOREIGN_NONE: no flags set * @VIPS_FOREIGN_PARTIAL: the image may be read lazilly * @VIPS_FOREIGN_BIGENDIAN: image pixels are most-significant byte first @@ -317,11 +317,11 @@ static GQuark vips__foreign_load_operation = 0; * Some hints about the image loader. * * #VIPS_FOREIGN_PARTIAL means that the image can be read directly from the - * file without needing to be unpacked to a temporary image first. + * file without needing to be unpacked to a temporary image first. * * #VIPS_FOREIGN_SEQUENTIAL means that the loader supports lazy reading, but * only top-to-bottom (sequential) access. Formats like PNG can read sets of - * scanlines, for example, but only in order. + * scanlines, for example, but only in order. * * If neither PARTIAL or SEQUENTIAL is set, the loader only supports whole * image read. Setting both PARTIAL and SEQUENTIAL is an error. @@ -337,7 +337,7 @@ static void vips_foreign_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) { VipsForeignClass *class = VIPS_FOREIGN_CLASS( object_class ); - VipsOperationClass *operation_class = + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( object_class ); VIPS_OBJECT_CLASS( vips_foreign_parent_class )-> @@ -382,7 +382,7 @@ vips_foreign_init( VipsForeign *object ) { } -/* To iterate over supported files we build a temp list of subclasses of +/* To iterate over supported files we build a temp list of subclasses of * VipsForeign, sort by priority, iterate, and free. */ @@ -391,9 +391,9 @@ file_add_class( VipsForeignClass *class, GSList **files ) { /* We exclude "rawload" as it has a different API. */ - if( !vips_isprefix( "rawload", VIPS_OBJECT_CLASS( class )->nickname ) ) - /* Append so we don't reverse the list of files. Sort will - * not reorder items of equal priority. + if( !vips_isprefix( "rawload", VIPS_OBJECT_CLASS( class )->nickname ) ) + /* Append so we don't reverse the list of files. Sort will + * not reorder items of equal priority. */ *files = g_slist_append( *files, class ); @@ -414,7 +414,7 @@ file_compare( VipsForeignClass *a, VipsForeignClass *b, void *user_data ) * @b: user data * * Apply a function to every #VipsForeignClass that VIPS knows about. Foreigns - * are presented to the function in priority order. + * are presented to the function in priority order. * * Like all VIPS map functions, if @fn returns %NULL, iteration continues. If * it returns non-%NULL, iteration terminates and that value is returned. The @@ -431,7 +431,7 @@ vips_foreign_map( const char *base, VipsSListMap2Fn fn, void *a, void *b ) void *result; files = NULL; - (void) vips_class_map_all( g_type_from_name( base ), + (void) vips_class_map_all( g_type_from_name( base ), (VipsClassMapFn) file_add_class, (void *) &files ); files = g_slist_sort( files, (GCompareFunc) file_compare ); @@ -502,7 +502,7 @@ vips_foreign_load_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) /* Can this VipsForeign open this file? */ static void * -vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, +vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, const char *filename, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class ); @@ -511,11 +511,11 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, /* Ignore the buffer and source loaders. */ if( vips_ispostfix( object_class->nickname, "_buffer" ) || - vips_ispostfix( object_class->nickname, "_source" ) ) + vips_ispostfix( object_class->nickname, "_source" ) ) return( NULL ); #ifdef DEBUG - printf( "vips_foreign_find_load_sub: %s\n", + printf( "vips_foreign_find_load_sub: %s\n", VIPS_OBJECT_CLASS( class )->nickname ); #endif /*DEBUG*/ @@ -523,19 +523,19 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, * otherwise fall back to checking the filename suffix. */ if( load_class->is_a ) { - if( load_class->is_a( filename ) ) + if( load_class->is_a( filename ) ) return( load_class ); #ifdef DEBUG - printf( "vips_foreign_find_load_sub: is_a failed\n" ); + printf( "vips_foreign_find_load_sub: is_a failed\n" ); #endif /*DEBUG*/ } else if( class->suffs ) { if( vips_filename_suffix_match( filename, class->suffs ) ) return( load_class ); } - else - g_warning( "loader %s has no is_a method and no suffix list", + else + g_warning( "loader %s has no is_a method and no suffix list", object_class->nickname ); return( NULL ); @@ -546,7 +546,7 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class, * @filename: file to find a loader for * * Searches for an operation you could use to load @filename. Any trailing - * options on @filename are stripped and ignored. + * options on @filename are stripped and ignored. * * See also: vips_foreign_find_load_buffer(), vips_image_new_from_file(). * @@ -564,27 +564,27 @@ vips_foreign_find_load( const char *name ) /* Very common, so make a better error message for this case. */ if( !vips_existsf( "%s", filename ) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "file \"%s\" does not exist" ), name ); return( NULL ); } if( vips_isdirf( "%s", filename ) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "\"%s\" is a directory" ), name ); return( NULL ); } - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - (VipsSListMap2Fn) vips_foreign_find_load_sub, + (VipsSListMap2Fn) vips_foreign_find_load_sub, (void *) filename, NULL )) ) { - vips_error( "VipsForeignLoad", + vips_error( "VipsForeignLoad", _( "\"%s\" is not a known file format" ), name ); return( NULL ); } #ifdef DEBUG - printf( "vips_foreign_find_load: selected %s\n", + printf( "vips_foreign_find_load: selected %s\n", VIPS_OBJECT_CLASS( load_class )->nickname ); #endif /*DEBUG*/ @@ -592,7 +592,7 @@ vips_foreign_find_load( const char *name ) } /* Kept for compat with earlier version of the vip8 API. Use - * vips_image_new_from_file() now. + * vips_image_new_from_file() now. */ int @@ -609,7 +609,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... ) return( -1 ); va_start( ap, out ); - result = vips_call_split_option_string( operation_name, option_string, + result = vips_call_split_option_string( operation_name, option_string, ap, filename, out ); va_end( ap ); @@ -619,7 +619,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... ) /* Can this VipsForeign open this buffer? */ static void * -vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, +vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, const void **buf, size_t *len ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class ); @@ -630,11 +630,11 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, return( NULL ); if( load_class->is_a_buffer ) { - if( load_class->is_a_buffer( *buf, *len ) ) + if( load_class->is_a_buffer( *buf, *len ) ) return( load_class ); } else - g_warning( "loader %s has no is_a_buffer method", + g_warning( "loader %s has no is_a_buffer method", object_class->nickname ); return( NULL ); @@ -642,18 +642,18 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, /** * vips_foreign_find_load_buffer: - * @data: (array length=size) (element-type guint8) (transfer none): start of + * @data: (array length=size) (element-type guint8) (transfer none): start of * memory buffer * @size: (type gsize): number of bytes in @data * * Searches for an operation you could use to load a memory buffer. To see the * range of buffer loaders supported by your vips, try something like: - * + * * vips -l | grep load_buffer * * See also: vips_image_new_from_buffer(). * - * Returns: (transfer none): the name of an operation on success, %NULL on + * Returns: (transfer none): the name of an operation on success, %NULL on * error. */ const char * @@ -661,12 +661,12 @@ vips_foreign_find_load_buffer( const void *data, size_t size ) { VipsForeignLoadClass *load_class; - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - (VipsSListMap2Fn) vips_foreign_find_load_buffer_sub, + (VipsSListMap2Fn) vips_foreign_find_load_buffer_sub, &data, &size )) ) { - vips_error( "VipsForeignLoad", - "%s", _( "buffer is not in a known format" ) ); + vips_error( "VipsForeignLoad", + "%s", _( "buffer is not in a known format" ) ); return( NULL ); } @@ -693,11 +693,11 @@ vips_foreign_find_load_source_sub( void *item, void *a, void *b ) */ (void) vips_source_rewind( source ); - if( load_class->is_a_source( source ) ) + if( load_class->is_a_source( source ) ) return( load_class ); } - else - g_warning( "loader %s has no is_a_source method", + else + g_warning( "loader %s has no is_a_source method", object_class->nickname ); return( NULL ); @@ -709,12 +709,12 @@ vips_foreign_find_load_source_sub( void *item, void *a, void *b ) * * Searches for an operation you could use to load a source. To see the * range of source loaders supported by your vips, try something like: - * + * * vips -l | grep load_source * * See also: vips_image_new_from_source(). * - * Returns: (transfer none): the name of an operation on success, %NULL on + * Returns: (transfer none): the name of an operation on success, %NULL on * error. */ const char * @@ -722,18 +722,18 @@ vips_foreign_find_load_source( VipsSource *source ) { VipsForeignLoadClass *load_class; - if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( + if( !(load_class = (VipsForeignLoadClass *) vips_foreign_map( "VipsForeignLoad", - vips_foreign_find_load_source_sub, + vips_foreign_find_load_source_sub, source, NULL )) ) { - vips_error( "VipsForeignLoad", - "%s", _( "source is not in a known format" ) ); + vips_error( "VipsForeignLoad", + "%s", _( "source is not in a known format" ) ); return( NULL ); } /* All source loaders should be NOCACHE. */ - g_assert( VIPS_OPERATION_CLASS( load_class )->flags & + g_assert( VIPS_OPERATION_CLASS( load_class )->flags & VIPS_OPERATION_NOCACHE ); return( G_OBJECT_CLASS_NAME( load_class ) ); @@ -749,17 +749,17 @@ vips_foreign_find_load_source( VipsSource *source ) * * Returns: %TRUE if @filename can be loaded by @loader. */ -gboolean +gboolean vips_foreign_is_a( const char *loader, const char *filename ) { const VipsObjectClass *class; VipsForeignLoadClass *load_class; - if( !(class = vips_class_find( "VipsForeignLoad", loader )) ) + if( !(class = vips_class_find( "VipsForeignLoad", loader )) ) return( FALSE ); load_class = VIPS_FOREIGN_LOAD_CLASS( class ); if( load_class->is_a && - load_class->is_a( filename ) ) + load_class->is_a( filename ) ) return( TRUE ); return( FALSE ); @@ -823,21 +823,21 @@ vips_foreign_is_a_source( const char *loader, VipsSource *source ) * @loader: name of loader to use for test * @filename: file to test * - * Return the flags for @filename using @loader. + * Return the flags for @filename using @loader. * @loader is something like "tiffload" or "VipsForeignLoadTiff". * * Returns: the flags for @filename. */ -VipsForeignFlags +VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename ) { const VipsObjectClass *class; if( (class = vips_class_find( "VipsForeignLoad", loader )) ) { - VipsForeignLoadClass *load_class = + VipsForeignLoadClass *load_class = VIPS_FOREIGN_LOAD_CLASS( class ); - if( load_class->get_flags_filename ) + if( load_class->get_flags_filename ) return( load_class->get_flags_filename( filename ) ); } @@ -854,7 +854,7 @@ vips_foreign_load_new_from_string( const char *string ) if( !(file_op = vips_foreign_find_load( string )) ) return( NULL ); type = g_type_from_name( file_op ); - g_assert( type ); + g_assert( type ); load = VIPS_FOREIGN_LOAD( g_object_new( type, NULL ) ); g_object_set( load, @@ -897,7 +897,7 @@ vips_foreign_load_temp( VipsForeignLoad *load ) /* If it can do sequential access and it's been requested, we can open * directly. */ - if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && + if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && load->access != VIPS_ACCESS_RANDOM ) { #ifdef DEBUG printf( "vips_foreign_load_temp: partial sequential temp\n" ); @@ -906,7 +906,7 @@ vips_foreign_load_temp( VipsForeignLoad *load ) return( vips_image_new() ); } - /* We open via disc if the uncompressed image will be larger than + /* We open via disc if the uncompressed image will be larger than * vips_get_disc_threshold() */ if( image_size > disc_threshold ) { @@ -938,7 +938,7 @@ vips_foreign_load_iscompat( VipsImage *a, VipsImage *b ) a->Coding != b->Coding || a->BandFmt != b->BandFmt ) { vips_error( "VipsForeignLoad", - "%s", _( "images do not match" ) ); + "%s", _( "images do not match" ) ); return( FALSE ); } @@ -968,25 +968,25 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) #endif /*DEBUG*/ /* Read the image in. This may involve a long computation and - * will finish with load->real holding the decompressed image. + * will finish with load->real holding the decompressed image. * * We want our caller to be able to see this computation on * @out, so eval signals on ->real need to appear on ->out. */ load->real->progress_signal = load->out; - /* Note the load object on the image. Loaders can use + /* Note the load object on the image. Loaders can use * this to signal invalidate if they hit a load error. See * vips_foreign_load_invalidate() below. */ - g_object_set_qdata( G_OBJECT( load->real ), - vips__foreign_load_operation, load ); + g_object_set_qdata( G_OBJECT( load->real ), + vips__foreign_load_operation, load ); /* Load the image and check the result. * * ->header() read the header into @out, load will read the * image into @real. They must match exactly in size, bands, - * format and coding for the copy to work. + * format and coding for the copy to work. * * Some versions of ImageMagick give different results between * Ping and Load for some formats, for example. @@ -994,9 +994,9 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) * If the load fails, we need to stop */ if( class->load( load ) || - vips_image_pio_input( load->real ) || + vips_image_pio_input( load->real ) || !vips_foreign_load_iscompat( load->real, out ) ) { - vips_operation_invalidate( VIPS_OPERATION( load ) ); + vips_operation_invalidate( VIPS_OPERATION( load ) ); load->error = TRUE; return( NULL ); @@ -1005,7 +1005,7 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) /* We have to tell vips that out depends on real. We've set * the demand hint below, but not given an input there. */ - if( vips_image_pipelinev( load->out, load->out->dhint, + if( vips_image_pipelinev( load->out, load->out->dhint, load->real, NULL ) ) return( NULL ); } @@ -1016,7 +1016,7 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) /* Just pointer-copy. */ static int -vips_foreign_load_generate( VipsRegion *or, +vips_foreign_load_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { VipsRegion *ir = (VipsRegion *) seq; @@ -1055,7 +1055,7 @@ vips_foreign_load_build( VipsObject *object ) if( (flags & VIPS_FOREIGN_PARTIAL) && (flags & VIPS_FOREIGN_SEQUENTIAL) ) { - g_warning( "%s", + g_warning( "%s", _( "VIPS_FOREIGN_PARTIAL and VIPS_FOREIGN_SEQUENTIAL " "both set -- using SEQUENTIAL" ) ); flags ^= VIPS_FOREIGN_PARTIAL; @@ -1067,7 +1067,7 @@ vips_foreign_load_build( VipsObject *object ) * loader in random mode is fine, since we'll read to ram or a temp * file. */ - if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && + if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) && load->access != VIPS_ACCESS_RANDOM ) load->nocache = TRUE; @@ -1075,21 +1075,21 @@ vips_foreign_load_build( VipsObject *object ) */ if( vips_object_argument_isset( object, "fail" ) && !vips_object_argument_isset( object, "fail_on" ) ) - load->fail_on = load->fail ? + load->fail_on = load->fail ? VIPS_FAIL_ON_WARNING : VIPS_FAIL_ON_NONE; if( VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )-> build( object ) ) return( -1 ); - if( load->sequential ) - g_warning( "%s", + if( load->sequential ) + g_warning( "%s", _( "ignoring deprecated \"sequential\" mode -- " - "please use \"access\" instead" ) ); + "please use \"access\" instead" ) ); - g_object_set( object, "out", vips_image_new(), NULL ); + g_object_set( object, "out", vips_image_new(), NULL ); - vips_image_set_string( load->out, + vips_image_set_string( load->out, VIPS_META_LOADER, class->nickname ); #ifdef DEBUG @@ -1099,7 +1099,7 @@ vips_foreign_load_build( VipsObject *object ) /* Read the header into @out. */ if( fclass->header && - fclass->header( load ) ) + fclass->header( load ) ) return( -1 ); /* If there's no ->load() method then the header read has done @@ -1120,14 +1120,14 @@ vips_foreign_load_build( VipsObject *object ) if( vips_image_pipelinev( load->out, load->out->dhint, NULL ) ) return( -1 ); - /* Then 'start' creates the real image and 'gen' fetches + /* Then 'start' creates the real image and 'gen' fetches * pixels for @out from @real on demand. */ - if( vips_image_generate( load->out, - vips_foreign_load_start, - vips_foreign_load_generate, - vips_stop_one, - NULL, load ) ) + if( vips_image_generate( load->out, + vips_foreign_load_start, + vips_foreign_load_generate, + vips_stop_one, + NULL, load ) ) return( -1 ); } @@ -1139,7 +1139,7 @@ vips_foreign_load_build( VipsObject *object ) return( 0 ); } -static VipsOperationFlags +static VipsOperationFlags vips_foreign_load_operation_get_flags( VipsOperation *operation ) { VipsForeignLoad *load = VIPS_FOREIGN_LOAD( operation ); @@ -1173,56 +1173,56 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class ) operation_class->get_flags = vips_foreign_load_operation_get_flags; - VIPS_ARG_IMAGE( class, "out", 2, - _( "Output" ), + VIPS_ARG_IMAGE( class, "out", 2, + _( "Output" ), _( "Output image" ), - VIPS_ARGUMENT_REQUIRED_OUTPUT, + VIPS_ARGUMENT_REQUIRED_OUTPUT, G_STRUCT_OFFSET( VipsForeignLoad, out ) ); - VIPS_ARG_FLAGS( class, "flags", 106, - _( "Flags" ), + 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_TYPE_FOREIGN_FLAGS, VIPS_FOREIGN_NONE ); - VIPS_ARG_BOOL( class, "memory", 107, - _( "Memory" ), + 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", 108, - _( "Access" ), + 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_TYPE_ACCESS, VIPS_ACCESS_RANDOM ); - VIPS_ARG_ENUM( class, "fail_on", 109, - _( "Fail on" ), + VIPS_ARG_ENUM( class, "fail_on", 109, + _( "Fail on" ), _( "Error level to fail on" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignLoad, fail_on ), - VIPS_TYPE_FAIL_ON, VIPS_FAIL_ON_NONE ); + VIPS_TYPE_FAIL_ON, VIPS_FAIL_ON_NONE ); - VIPS_ARG_BOOL( class, "sequential", 110, - _( "Sequential" ), + VIPS_ARG_BOOL( class, "sequential", 110, + _( "Sequential" ), _( "Sequential read only" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, sequential ), FALSE ); VIPS_ARG_BOOL( class, "fail", 111, - _( "Fail" ), + _( "Fail" ), _( "Fail on first warning" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, fail ), FALSE ); - VIPS_ARG_BOOL( class, "disc", 112, - _( "Disc" ), + VIPS_ARG_BOOL( class, "disc", 112, + _( "Disc" ), _( "Open to disc" ), VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED, G_STRUCT_OFFSET( VipsForeignLoad, disc ), @@ -1248,25 +1248,25 @@ vips_foreign_load_init( VipsForeignLoad *load ) * * Loaders can call this on the image they are making if they see a read error * from the load library. It signals "invalidate" on the load operation and - * will cause it to be dropped from cache. + * will cause it to be dropped from cache. * * If we know a file will cause a read error, we don't want to cache the - * failing operation, we want to make sure the image will really be opened - * again if our caller tries again. For example, a broken file might be - * replaced by a working one. + * failing operation, we want to make sure the image will really be opened + * again if our caller tries again. For example, a broken file might be + * replaced by a working one. */ void vips_foreign_load_invalidate( VipsImage *image ) { - VipsOperation *operation; + VipsOperation *operation; #ifdef DEBUG - printf( "vips_foreign_load_invalidate: %p\n", image ); + printf( "vips_foreign_load_invalidate: %p\n", image ); #endif /*DEBUG*/ - if( (operation = g_object_get_qdata( G_OBJECT( image ), + if( (operation = g_object_get_qdata( G_OBJECT( image ), vips__foreign_load_operation )) ) { - vips_operation_invalidate( operation ); + vips_operation_invalidate( operation ); } } @@ -1293,7 +1293,7 @@ vips_foreign_save_summary_class( VipsObjectClass *object_class, VipsBuf *buf ) VIPS_OBJECT_CLASS( vips_foreign_save_parent_class )-> summary_class( object_class, buf ); - vips_buf_appendf( buf, ", %s", + vips_buf_appendf( buf, ", %s", vips_enum_nick( VIPS_TYPE_SAVEABLE, class->saveable ) ); } @@ -1307,7 +1307,7 @@ vips_foreign_save_new_from_string( const char *string ) if( !(file_op = vips_foreign_find_save( string )) ) return( NULL ); type = g_type_from_name( file_op ); - g_assert( type ); + g_assert( type ); save = VIPS_FOREIGN_SAVE( g_object_new( type, NULL ) ); g_object_set( save, @@ -1317,7 +1317,7 @@ vips_foreign_save_new_from_string( const char *string ) return( VIPS_OBJECT( save ) ); } -/* Convert an image for saving. +/* Convert an image for saving. */ int vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, @@ -1328,7 +1328,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, */ g_object_ref( in ); - /* For coded images, can this class save the coding we are in now? + /* For coded images, can this class save the coding we are in now? * Nothing to do. */ if( in->Coding != VIPS_CODING_NONE && @@ -1337,7 +1337,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, return( 0 ); } - /* For uncoded images, if this saver supports ANY bands and this + /* For uncoded images, if this saver supports ANY bands and this * format we have nothing to do. */ if( in->Coding == VIPS_CODING_NONE && @@ -1366,7 +1366,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this is an VIPS_CODING_RAD, we unpack to float. This could be - * scRGB or XYZ. + * scRGB or XYZ. */ if( in->Coding == VIPS_CODING_RAD ) { VipsImage *out; @@ -1380,14 +1380,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* If the saver supports RAD, we need to go to scRGB or XYZ. + /* If the saver supports RAD, we need to go to scRGB or XYZ. */ if( coding[VIPS_CODING_RAD] ) { if( in->Type != VIPS_INTERPRETATION_scRGB && in->Type != VIPS_INTERPRETATION_XYZ ) { VipsImage *out; - if( vips_colourspace( in, &out, + if( vips_colourspace( in, &out, VIPS_INTERPRETATION_scRGB, NULL ) ) { g_object_unref( in ); return( -1 ); @@ -1399,16 +1399,16 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this image is CMYK and the saver is RGB-only, use lcms to try to - * import to XYZ. + * import to XYZ. */ if( in->Type == VIPS_INTERPRETATION_CMYK && in->Bands >= 4 && (saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGBA || - saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { VipsImage *out; - if( vips_icc_import( in, &out, + if( vips_icc_import( in, &out, "pcs", VIPS_PCS_XYZ, "embedded", TRUE, "input_profile", "cmyk", @@ -1422,7 +1422,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* If this is something other than CMYK or RAD, and it's not already - * an RGB image, eg. maybe a LAB image, we need to transform + * an RGB image, eg. maybe a LAB image, we need to transform * to RGB. */ if( !coding[VIPS_CODING_RAD] && @@ -1435,12 +1435,12 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, (saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGBA || saveable == VIPS_SAVEABLE_RGBA_ONLY || - saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { VipsImage *out; VipsInterpretation interpretation; /* Do we make RGB or RGB16? We don't want to squash a 16-bit - * RGB down to 8 bits if the saver supports 16. + * RGB down to 8 bits if the saver supports 16. */ if( vips_band_format_is8bit( format[in->BandFmt] ) ) interpretation = VIPS_INTERPRETATION_sRGB; @@ -1456,17 +1456,17 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* VIPS_SAVEABLE_RGBA_ONLY does not support mono types ... convert - * to sRGB. + /* VIPS_SAVEABLE_RGBA_ONLY does not support mono types ... convert + * to sRGB. */ if( !coding[VIPS_CODING_RAD] && in->Bands < 3 && - saveable == VIPS_SAVEABLE_RGBA_ONLY ) { + saveable == VIPS_SAVEABLE_RGBA_ONLY ) { VipsImage *out; VipsInterpretation interpretation; /* Do we make RGB or RGB16? We don't want to squash a 16-bit - * RGB down to 8 bits if the saver supports 16. + * RGB down to 8 bits if the saver supports 16. */ if( vips_band_format_is8bit( format[in->BandFmt] ) ) interpretation = VIPS_INTERPRETATION_sRGB; @@ -1483,7 +1483,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, } /* Get the bands right. We must do this after all colourspace - * transforms, since they can change the number of bands. + * transforms, since they can change the number of bands. */ if( in->Coding == VIPS_CODING_NONE ) { /* Do we need to flatten out an alpha channel? There needs to @@ -1491,14 +1491,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * alpha. */ if( (in->Bands == 2 || - (in->Bands == 4 && + (in->Bands == 4 && in->Type != VIPS_INTERPRETATION_CMYK)) && (saveable == VIPS_SAVEABLE_MONO || saveable == VIPS_SAVEABLE_RGB || saveable == VIPS_SAVEABLE_RGB_CMYK) ) { VipsImage *out; - if( vips_flatten( in, &out, + if( vips_flatten( in, &out, "background", background, NULL ) ) { g_object_unref( in ); @@ -1513,10 +1513,10 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * bands. */ - else if( in->Bands > 3 && + else if( in->Bands > 3 && (saveable == VIPS_SAVEABLE_RGB || (saveable == VIPS_SAVEABLE_RGB_CMYK && - in->Type != VIPS_INTERPRETATION_CMYK)) ) { + in->Type != VIPS_INTERPRETATION_CMYK)) ) { VipsImage *out; /* Don't let 4 bands though unless the image really is @@ -1526,7 +1526,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, * write CMYK jpg, but we mustn't do that for RGBA * images. */ - if( vips_extract_band( in, &out, 0, + if( vips_extract_band( in, &out, 0, "n", 3, NULL ) ) { g_object_unref( in ); @@ -1536,14 +1536,14 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - else if( in->Bands > 4 && + else if( in->Bands > 4 && ((saveable == VIPS_SAVEABLE_RGB_CMYK && in->Type == VIPS_INTERPRETATION_CMYK) || saveable == VIPS_SAVEABLE_RGBA || saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { VipsImage *out; - if( vips_extract_band( in, &out, 0, + if( vips_extract_band( in, &out, 0, "n", 4, NULL ) ) { g_object_unref( in ); @@ -1553,7 +1553,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - else if( in->Bands > 1 && + else if( in->Bands > 1 && saveable == VIPS_SAVEABLE_MONO ) { VipsImage *out; @@ -1601,7 +1601,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, else { VipsImage *out; - if( vips_rshift_const1( in, &out, 8, NULL ) ) { + if( vips_rshift_const1( in, &out, 8, NULL ) ) { g_object_unref( in ); return( -1 ); } @@ -1609,7 +1609,7 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; - /* That could have produced an int image ... make sure + /* That could have produced an int image ... make sure * we are now uchar. */ if( vips_cast( in, &out, VIPS_FORMAT_UCHAR, NULL ) ) { @@ -1666,16 +1666,16 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, in = out; } - /* Some format libraries, like libpng, will throw a hard error if the + /* Some format libraries, like libpng, will throw a hard error if the * profile is inappropriate for this image type. With profiles inherited - * from a source image, this can happen all the time, so we + * from a source image, this can happen all the time, so we * want to silently drop the profile in this case. */ if( vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) { const void *data; size_t length; - if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, + if( !vips_image_get_blob( in, VIPS_META_ICC_NAME, &data, &length ) && !vips_icc_is_compatible_profile( in, data, length ) ) { VipsImage *out; @@ -1703,7 +1703,7 @@ vips_foreign_save_build( VipsObject *object ) VipsForeignSave *save = VIPS_FOREIGN_SAVE( object ); if( save->in ) { - VipsForeignSaveClass *class = + VipsForeignSaveClass *class = VIPS_FOREIGN_SAVE_GET_CLASS( save ); VipsImage *ready; @@ -1722,7 +1722,7 @@ vips_foreign_save_build( VipsObject *object ) VIPS_UNREF( ready ); ready = x; - vips_image_set_int( ready, + vips_image_set_int( ready, VIPS_META_PAGE_HEIGHT, save->page_height ); } @@ -1749,7 +1749,7 @@ vips_foreign_save_build( VipsObject *object ) #define DX VIPS_FORMAT_DPCOMPLEX static int vips_foreign_save_format_table[10] = { -// UC C US S UI I F X D DX +// UC C US S UI I F X D DX UC, C, US, S, UI, I, F, X, D, DX }; @@ -1772,9 +1772,9 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) object_class->nickname = "save"; object_class->description = _( "savers" ); - /* All savers are sequential by definition. Things like tiled tiff - * write and interlaced png write, which are not, add extra caches - * on their input. + /* All savers are sequential by definition. Things like tiled tiff + * write and interlaced png write, which are not, add extra caches + * on their input. */ operation_class->flags |= VIPS_OPERATION_SEQUENTIAL; @@ -1790,10 +1790,10 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) /* Default to no cast on save. */ - class->format_table = vips_foreign_save_format_table; + class->format_table = vips_foreign_save_format_table; - VIPS_ARG_IMAGE( class, "in", 0, - _( "Input" ), + VIPS_ARG_IMAGE( class, "in", 0, + _( "Input" ), _( "Image to save" ), VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignSave, in ) ); @@ -1805,19 +1805,19 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) G_STRUCT_OFFSET( VipsForeignSave, strip ), FALSE ); - VIPS_ARG_BOXED( class, "background", 101, - _( "Background" ), + VIPS_ARG_BOXED( class, "background", 101, + _( "Background" ), _( "Background value" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignSave, background ), VIPS_TYPE_ARRAY_DOUBLE ); - VIPS_ARG_INT( class, "page_height", 102, - _( "Page height" ), + VIPS_ARG_INT( class, "page_height", 102, + _( "Page height" ), _( "Set page height for multipage save" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignSave, page_height ), - 0, VIPS_MAX_COORD, 0 ); + 0, VIPS_MAX_COORD, 0 ); } @@ -1827,10 +1827,10 @@ vips_foreign_save_init( VipsForeignSave *save ) save->background = vips_array_double_newv( 1, 0.0 ); } -/* Can we write this filename with this class? +/* Can we write this filename with this class? */ static void * -vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, const char *filename, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); @@ -1838,7 +1838,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, const char **p; - /* All savers needs suffs defined since we use the suff to pick the + /* All savers needs suffs defined since we use the suff to pick the * saver. */ if( !class->suffs ) @@ -1854,7 +1854,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, * end of the filename, so we can test directly against the suffix. */ for( p = class->suffs; *p; p++ ) - if( vips_iscasepostfix( filename, *p ) ) + if( vips_iscasepostfix( filename, *p ) ) return( save_class ); return( NULL ); @@ -1865,7 +1865,7 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class, * @filename: name to find a saver for * * Searches for an operation you could use to write to @filename. - * Any trailing options on @filename are stripped and ignored. + * Any trailing options on @filename are stripped and ignored. * * See also: vips_foreign_find_save_buffer(), vips_image_write_to_file(). * @@ -1880,9 +1880,9 @@ vips_foreign_find_save( const char *name ) vips__filename_split8( name, filename, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_sub, + (VipsSListMap2Fn) vips_foreign_find_save_sub, (void *) filename, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known file format" ), name ); @@ -1894,7 +1894,7 @@ vips_foreign_find_save( const char *name ) } static void * -vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, +vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, void *a, void *b ) { VipsForeignClass *foreign_class = VIPS_FOREIGN_CLASS( save_class ); @@ -1906,11 +1906,11 @@ vips_foreign_get_suffixes_count_cb( VipsForeignSaveClass *save_class, for( i = 0; foreign_class->suffs[i]; i++ ) *n_fields += 1; - return( NULL ); + return( NULL ); } static void * -vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, +vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, void *a, void *b ) { VipsForeignClass *foreign_class = VIPS_FOREIGN_CLASS( save_class ); @@ -1920,29 +1920,29 @@ vips_foreign_get_suffixes_add_cb( VipsForeignSaveClass *save_class, if( foreign_class->suffs ) for( i = 0; foreign_class->suffs[i]; i++ ) { - **p = g_strdup( foreign_class->suffs[i] ); + **p = g_strdup( foreign_class->suffs[i] ); *p += 1; } - return( NULL ); + return( NULL ); } /** * vips_foreign_get_suffixes: * - * Get a %NULL-terminated array listing all the supported suffixes. + * Get a %NULL-terminated array listing all the supported suffixes. * - * This is not the same as all the supported file types, since libvips - * detects image format for load by testing the first few bytes. + * This is not the same as all the supported file types, since libvips + * detects image format for load by testing the first few bytes. * * Use vips_foreign_find_load() to detect type for a specific file. * * Free the return result with g_strfreev(). * - * Returns: (transfer full) (array): all supported file extensions, as a - * %NULL-terminated array. + * Returns: (transfer full) (array): all supported file extensions, as a + * %NULL-terminated array. */ -gchar ** +gchar ** vips_foreign_get_suffixes( void ) { int n_suffs; @@ -1950,19 +1950,19 @@ vips_foreign_get_suffixes( void ) gchar **p; n_suffs = 0; - (void) vips_foreign_map( + (void) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_get_suffixes_count_cb, + (VipsSListMap2Fn) vips_foreign_get_suffixes_count_cb, &n_suffs, NULL ); - suffs = g_new0( gchar *, n_suffs + 1 ); + suffs = g_new0( gchar *, n_suffs + 1 ); p = suffs; - (void) vips_foreign_map( + (void) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_get_suffixes_add_cb, + (VipsSListMap2Fn) vips_foreign_get_suffixes_add_cb, &p, NULL ); - return( suffs ); + return( suffs ); } /* Kept for early vips8 API compat. @@ -1983,7 +1983,7 @@ vips_foreign_save( VipsImage *in, const char *name, ... ) return( -1 ); va_start( ap, name ); - result = vips_call_split_option_string( operation_name, option_string, + result = vips_call_split_option_string( operation_name, option_string, ap, in, filename ); va_end( ap ); @@ -1993,13 +1993,13 @@ vips_foreign_save( VipsImage *in, const char *name, ... ) /* Can this class write this filetype to a target? */ static void * -vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, const char *suffix, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class ); - /* All concrete savers needs suffs, since we use the suff to pick the + /* All concrete savers needs suffs, since we use the suff to pick the * saver. */ if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) && @@ -2020,7 +2020,7 @@ vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class, * @suffix: format to find a saver for * * Searches for an operation you could use to write to a target in @suffix - * format. + * format. * * See also: vips_image_write_to_buffer(). * @@ -2035,9 +2035,9 @@ vips_foreign_find_save_target( const char *name ) vips__filename_split8( name, suffix, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_target_sub, + (VipsSListMap2Fn) vips_foreign_find_save_target_sub, (void *) suffix, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known target format" ), name ); @@ -2051,13 +2051,13 @@ vips_foreign_find_save_target( const char *name ) /* Can we write this buffer with this file type? */ static void * -vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, +vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, const char *suffix, void *b ) { VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class ); VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class ); - /* All concrete savers needs suffs, since we use the suff to pick the + /* All concrete savers needs suffs, since we use the suff to pick the * saver. */ if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) && @@ -2078,7 +2078,7 @@ vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class, * @suffix: name to find a saver for * * Searches for an operation you could use to write to a buffer in @suffix - * format. + * format. * * See also: vips_image_write_to_buffer(). * @@ -2093,9 +2093,9 @@ vips_foreign_find_save_buffer( const char *name ) vips__filename_split8( name, suffix, option_string ); - if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( + if( !(save_class = (VipsForeignSaveClass *) vips_foreign_map( "VipsForeignSave", - (VipsSListMap2Fn) vips_foreign_find_save_buffer_sub, + (VipsSListMap2Fn) vips_foreign_find_save_buffer_sub, (void *) suffix, NULL )) ) { vips_error( "VipsForeignSave", _( "\"%s\" is not a known buffer format" ), name ); @@ -2122,16 +2122,16 @@ vips_foreign_find_save_buffer( const char *name ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Read a HEIF image file into a VIPS image. + * Read a HEIF image file into a VIPS image. * * Use @page to select a page to render, numbering from zero. If neither @n * nor @page are set, @page defaults to the primary page, otherwise to 0. * * Use @n to select the number of pages to render. The default is 1. Pages are - * rendered in a vertical column. Set to -1 to mean "until the end of the + * rendered in a vertical column. Set to -1 to mean "until the end of the * document". Use vips_grid() to reorganise pages. * - * HEIF images have a primary image. The metadata item `heif-primary` gives + * HEIF images have a primary image. The metadata item `heif-primary` gives * the page number of the primary. * * If @thumbnail is %TRUE, then fetch a stored thumbnail rather than the @@ -2174,11 +2174,11 @@ vips_heifload( const char *filename, VipsImage **out, ... ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Read a HEIF image file into a VIPS image. - * Exactly as vips_heifload(), but read from a memory buffer. + * Read a HEIF image file into a VIPS image. + * Exactly as vips_heifload(), but read from a memory buffer. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_heifload(). * @@ -2217,7 +2217,7 @@ vips_heifload_buffer( void *buf, size_t len, VipsImage **out, ... ) * * @thumbnail: %gboolean, fetch thumbnail instead of image * * @unlimited: %gboolean, remove all denial of service limits * - * Exactly as vips_heifload(), but read from a source. + * Exactly as vips_heifload(), but read from a source. * * See also: vips_heifload(). * @@ -2238,8 +2238,8 @@ vips_heifload_source( VipsSource *source, VipsImage **out, ... ) /** * vips_heifsave: (method) - * @in: image to save - * @filename: file to write to + * @in: image to save + * @filename: file to write to * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -2251,7 +2251,7 @@ vips_heifload_source( VipsSource *source, VipsImage **out, ... ) * * @effort: %gint, encoding effort * * @subsample_mode: #VipsForeignSubsample, chroma subsampling mode * - * Write a VIPS image to a file in HEIF format. + * Write a VIPS image to a file in HEIF format. * * Use @Q to set the compression factor. Default 50, which seems to be roughly * what the iphone uses. Q 30 gives about the same quality as JPEG Q 75. @@ -2290,7 +2290,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) /** * vips_heifsave_buffer: (method) - * @in: image to save + * @in: image to save * @buf: (array length=len) (element-type guint8): return output buffer here * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments @@ -2304,7 +2304,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) * * @effort: %gint, encoding effort * * @subsample_mode: #VipsForeignSubsample, chroma subsampling mode * - * As vips_heifsave(), but save to a memory buffer. + * As vips_heifsave(), but save to a memory buffer. * * The address of the buffer is returned in @obuf, the length of the buffer in * @olen. You are responsible for freeing the buffer with g_free() when you @@ -2321,19 +2321,19 @@ vips_heifsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) VipsArea *area; int result; - area = NULL; + area = NULL; va_start( ap, len ); result = vips_call_split( "heifsave_buffer", ap, in, &area ); va_end( ap ); if( !result && - area ) { + area ) { if( buf ) { *buf = area->data; area->free_fn = NULL; } - if( len ) + if( len ) *len = area->length; vips_area_unref( area ); @@ -2344,7 +2344,7 @@ vips_heifsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) /** * vips_heifsave_target: (method) - * @in: image to save + * @in: image to save * @target: save image to this target * @...: %NULL-terminated list of optional named arguments * @@ -2382,7 +2382,7 @@ vips_heifsave_target( VipsImage *in, VipsTarget *target, ... ) * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * - * Read a JPEG-XL image. + * Read a JPEG-XL image. * * The JPEG-XL loader and saver are experimental features and may change * in future libvips versions. @@ -2411,7 +2411,7 @@ vips_jxlload( const char *filename, VipsImage **out, ... ) * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_jxlload(), but read from a buffer. + * Exactly as vips_jxlload(), but read from a buffer. * * Returns: 0 on success, -1 on error. */ @@ -2441,7 +2441,7 @@ vips_jxlload_buffer( void *buf, size_t len, VipsImage **out, ... ) * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_jxlload(), but read from a source. + * Exactly as vips_jxlload(), but read from a source. * * Returns: 0 on success, -1 on error. */ @@ -2460,8 +2460,8 @@ vips_jxlload_source( VipsSource *source, VipsImage **out, ... ) /** * vips_jxlsave: (method) - * @in: image to save - * @filename: file to write to + * @in: image to save + * @filename: file to write to * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -2472,17 +2472,17 @@ vips_jxlload_source( VipsSource *source, VipsImage **out, ... ) * * @lossless: %gboolean, enables lossless compression * * @Q: %gint, quality setting * - * Write a VIPS image to a file in JPEG-XL format. + * Write a VIPS image to a file in JPEG-XL format. * * The JPEG-XL loader and saver are experimental features and may change * in future libvips versions. * - * @tier sets the overall decode speed the encoder will target. Minimum is 0 + * @tier sets the overall decode speed the encoder will target. Minimum is 0 * (highest quality), and maximum is 4 (lowest quality). Default is 0. * - * @distance sets the target maximum encoding error. Minimum is 0 + * @distance sets the target maximum encoding error. Minimum is 0 * (highest quality), and maximum is 15 (lowest quality). Default is 1.0 - * (visually lossless). + * (visually lossless). * * As a convenience, you can also use @Q to set @distance. @Q uses * approximately the same scale as regular JPEG. @@ -2506,7 +2506,7 @@ vips_jxlsave( VipsImage *in, const char *filename, ... ) /** * vips_jxlsave_buffer: (method) - * @in: image to save + * @in: image to save * @buf: (array length=len) (element-type guint8): return output buffer here * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments @@ -2532,19 +2532,19 @@ vips_jxlsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) VipsArea *area; int result; - area = NULL; + area = NULL; va_start( ap, len ); result = vips_call_split( "jxlsave_buffer", ap, in, &area ); va_end( ap ); if( !result && - area ) { + area ) { if( buf ) { *buf = area->data; area->free_fn = NULL; } - if( len ) + if( len ) *len = area->length; vips_area_unref( area ); @@ -2555,7 +2555,7 @@ vips_jxlsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) /** * vips_jxlsave_target: (method) - * @in: image to save + * @in: image to save * @target: save image to this target * @...: %NULL-terminated list of optional named arguments * @@ -2601,7 +2601,7 @@ vips_jxlsave_target( VipsImage *in, VipsTarget *target, ... ) * * @background: #VipsArrayDouble background colour * * @password: %gchararray background colour * - * Render a PDF file into a VIPS image. + * Render a PDF file into a VIPS image. * * The output image is always RGBA --- CMYK PDFs will be * converted. If you need CMYK bitmaps, you should use vips_magickload() @@ -2611,19 +2611,19 @@ vips_jxlsave_target( VipsImage *in, VipsTarget *target, ... ) * * 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() + * left. Set to -1 to mean "until the end of the document". Use vips_grid() * to change page layout. * * Use @dpi to set the rendering resolution. The default is 72. Additionally, * you can scale by setting @scale. If you set both, they combine. * - * Use @background to set the background RGBA colour. The default is 255 + * Use @background to set the background RGBA colour. The default is 255 * (solid white), use eg. 0 for a transparent background. * * Use @password to supply a decryption password. * * The operation fills a number of header fields with metadata, for example - * "pdf-author". They may be useful. + * "pdf-author". They may be useful. * * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. @@ -2661,10 +2661,10 @@ vips_pdfload( const char *filename, VipsImage **out, ... ) * * @background: #VipsArrayDouble background colour * * Read a PDF-formatted memory buffer into a VIPS image. Exactly as - * vips_pdfload(), but read from memory. + * vips_pdfload(), but read from memory. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_pdfload(). * @@ -2704,7 +2704,7 @@ vips_pdfload_buffer( void *buf, size_t len, VipsImage **out, ... ) * * @scale: %gdouble, scale render by this factor * * @background: #VipsArrayDouble background colour * - * Exactly as vips_pdfload(), but read from a source. + * Exactly as vips_pdfload(), but read from a source. * * See also: vips_pdfload() * @@ -2789,7 +2789,7 @@ vips_openslideload( const char *filename, VipsImage **out, ... ) * * @attach_associated: %gboolean, attach all associated images as metadata * * @autocrop: %gboolean, crop to image bounds * - * Exactly as vips_openslideload(), but read from a source. + * Exactly as vips_openslideload(), but read from a source. * * Returns: 0 on success, -1 on error. */ @@ -2812,84 +2812,84 @@ vips_openslideload_source( VipsSource *source, VipsImage **out, ... ) void vips_foreign_operation_init( void ) { - extern GType vips_foreign_load_rad_file_get_type( void ); - extern GType vips_foreign_load_rad_buffer_get_type( void ); - extern GType vips_foreign_load_rad_source_get_type( void ); - extern GType vips_foreign_save_rad_file_get_type( void ); - extern GType vips_foreign_save_rad_buffer_get_type( void ); - extern GType vips_foreign_save_rad_target_get_type( void ); + extern GType vips_foreign_load_rad_file_get_type( void ); + extern GType vips_foreign_load_rad_buffer_get_type( void ); + extern GType vips_foreign_load_rad_source_get_type( void ); + extern GType vips_foreign_save_rad_file_get_type( void ); + extern GType vips_foreign_save_rad_buffer_get_type( void ); + extern GType vips_foreign_save_rad_target_get_type( void ); - extern GType vips_foreign_load_mat_get_type( void ); + extern GType vips_foreign_load_mat_get_type( void ); - extern GType vips_foreign_load_ppm_file_get_type( void ); - extern GType vips_foreign_load_ppm_source_get_type( void ); - extern GType vips_foreign_save_ppm_file_get_type( void ); - extern GType vips_foreign_save_pbm_target_get_type( void ); + extern GType vips_foreign_load_ppm_file_get_type( void ); + extern GType vips_foreign_load_ppm_source_get_type( void ); + extern GType vips_foreign_save_ppm_file_get_type( void ); + extern GType vips_foreign_save_pbm_target_get_type( void ); extern GType vips_foreign_save_pgm_target_get_type( void ); - extern GType vips_foreign_save_ppm_target_get_type( void ); - extern GType vips_foreign_save_pfm_target_get_type( void ); - - extern GType vips_foreign_load_png_file_get_type( void ); - extern GType vips_foreign_load_png_buffer_get_type( void ); - extern GType vips_foreign_load_png_source_get_type( void ); - extern GType vips_foreign_save_png_file_get_type( void ); - extern GType vips_foreign_save_png_buffer_get_type( void ); - extern GType vips_foreign_save_png_target_get_type( void ); - - extern GType vips_foreign_save_spng_file_get_type( void ); - extern GType vips_foreign_save_spng_buffer_get_type( void ); - extern GType vips_foreign_save_spng_target_get_type( void ); - - extern GType vips_foreign_load_csv_file_get_type( void ); - extern GType vips_foreign_load_csv_source_get_type( void ); - extern GType vips_foreign_save_csv_file_get_type( void ); - extern GType vips_foreign_save_csv_target_get_type( void ); - - extern GType vips_foreign_load_matrix_file_get_type( void ); - extern GType vips_foreign_load_matrix_source_get_type( void ); - extern GType vips_foreign_save_matrix_file_get_type( void ); - extern GType vips_foreign_save_matrix_target_get_type( void ); - extern GType vips_foreign_print_matrix_get_type( void ); - - extern GType vips_foreign_load_fits_file_get_type( void ); - extern GType vips_foreign_load_fits_source_get_type( void ); - extern GType vips_foreign_save_fits_get_type( void ); - - extern GType vips_foreign_load_analyze_get_type( void ); - - extern GType vips_foreign_load_openexr_get_type( void ); - - extern GType vips_foreign_load_openslide_file_get_type( void ); - extern GType vips_foreign_load_openslide_source_get_type( void ); - - extern GType vips_foreign_load_vips_file_get_type( void ); - extern GType vips_foreign_load_vips_source_get_type( void ); - extern GType vips_foreign_save_vips_file_get_type( void ); - extern GType vips_foreign_save_vips_target_get_type( void ); - - extern GType vips_foreign_load_jpeg_file_get_type( void ); - extern GType vips_foreign_load_jpeg_buffer_get_type( void ); - extern GType vips_foreign_load_jpeg_source_get_type( void ); - extern GType vips_foreign_save_jpeg_file_get_type( void ); - extern GType vips_foreign_save_jpeg_buffer_get_type( void ); - extern GType vips_foreign_save_jpeg_target_get_type( void ); - extern GType vips_foreign_save_jpeg_mime_get_type( void ); - - extern GType vips_foreign_load_tiff_file_get_type( void ); - extern GType vips_foreign_load_tiff_buffer_get_type( void ); - extern GType vips_foreign_load_tiff_source_get_type( void ); - extern GType vips_foreign_save_tiff_file_get_type( void ); - extern GType vips_foreign_save_tiff_buffer_get_type( void ); - extern GType vips_foreign_save_tiff_target_get_type( void ); - - extern GType vips_foreign_load_raw_get_type( void ); - extern GType vips_foreign_save_raw_get_type( void ); - extern GType vips_foreign_save_raw_fd_get_type( void ); - - extern GType vips_foreign_load_magick_file_get_type( void ); - extern GType vips_foreign_load_magick_buffer_get_type( void ); - extern GType vips_foreign_load_magick7_file_get_type( void ); - extern GType vips_foreign_load_magick7_buffer_get_type( void ); + extern GType vips_foreign_save_ppm_target_get_type( void ); + extern GType vips_foreign_save_pfm_target_get_type( void ); + + extern GType vips_foreign_load_png_file_get_type( void ); + extern GType vips_foreign_load_png_buffer_get_type( void ); + extern GType vips_foreign_load_png_source_get_type( void ); + extern GType vips_foreign_save_png_file_get_type( void ); + extern GType vips_foreign_save_png_buffer_get_type( void ); + extern GType vips_foreign_save_png_target_get_type( void ); + + extern GType vips_foreign_save_spng_file_get_type( void ); + extern GType vips_foreign_save_spng_buffer_get_type( void ); + extern GType vips_foreign_save_spng_target_get_type( void ); + + extern GType vips_foreign_load_csv_file_get_type( void ); + extern GType vips_foreign_load_csv_source_get_type( void ); + extern GType vips_foreign_save_csv_file_get_type( void ); + extern GType vips_foreign_save_csv_target_get_type( void ); + + extern GType vips_foreign_load_matrix_file_get_type( void ); + extern GType vips_foreign_load_matrix_source_get_type( void ); + extern GType vips_foreign_save_matrix_file_get_type( void ); + extern GType vips_foreign_save_matrix_target_get_type( void ); + extern GType vips_foreign_print_matrix_get_type( void ); + + extern GType vips_foreign_load_fits_file_get_type( void ); + extern GType vips_foreign_load_fits_source_get_type( void ); + extern GType vips_foreign_save_fits_get_type( void ); + + extern GType vips_foreign_load_analyze_get_type( void ); + + extern GType vips_foreign_load_openexr_get_type( void ); + + extern GType vips_foreign_load_openslide_file_get_type( void ); + extern GType vips_foreign_load_openslide_source_get_type( void ); + + extern GType vips_foreign_load_vips_file_get_type( void ); + extern GType vips_foreign_load_vips_source_get_type( void ); + extern GType vips_foreign_save_vips_file_get_type( void ); + extern GType vips_foreign_save_vips_target_get_type( void ); + + extern GType vips_foreign_load_jpeg_file_get_type( void ); + extern GType vips_foreign_load_jpeg_buffer_get_type( void ); + extern GType vips_foreign_load_jpeg_source_get_type( void ); + extern GType vips_foreign_save_jpeg_file_get_type( void ); + extern GType vips_foreign_save_jpeg_buffer_get_type( void ); + extern GType vips_foreign_save_jpeg_target_get_type( void ); + extern GType vips_foreign_save_jpeg_mime_get_type( void ); + + extern GType vips_foreign_load_tiff_file_get_type( void ); + extern GType vips_foreign_load_tiff_buffer_get_type( void ); + extern GType vips_foreign_load_tiff_source_get_type( void ); + extern GType vips_foreign_save_tiff_file_get_type( void ); + extern GType vips_foreign_save_tiff_buffer_get_type( void ); + extern GType vips_foreign_save_tiff_target_get_type( void ); + + extern GType vips_foreign_load_raw_get_type( void ); + extern GType vips_foreign_save_raw_get_type( void ); + extern GType vips_foreign_save_raw_fd_get_type( void ); + + extern GType vips_foreign_load_magick_file_get_type( void ); + extern GType vips_foreign_load_magick_buffer_get_type( void ); + extern GType vips_foreign_load_magick7_file_get_type( void ); + extern GType vips_foreign_load_magick7_buffer_get_type( void ); extern GType vips_foreign_save_magick_file_get_type( void ); extern GType vips_foreign_save_magick_buffer_get_type( void ); @@ -2898,144 +2898,144 @@ vips_foreign_operation_init( void ) extern GType vips_foreign_save_magick_gif_file_get_type( void ); extern GType vips_foreign_save_magick_gif_buffer_get_type( void ); - extern GType vips_foreign_save_dz_file_get_type( void ); - extern GType vips_foreign_save_dz_buffer_get_type( void ); - extern GType vips_foreign_save_dz_target_get_type( void ); - - extern GType vips_foreign_load_webp_file_get_type( void ); - extern GType vips_foreign_load_webp_buffer_get_type( void ); - extern GType vips_foreign_load_webp_source_get_type( void ); - extern GType vips_foreign_save_webp_file_get_type( void ); - extern GType vips_foreign_save_webp_buffer_get_type( void ); - extern GType vips_foreign_save_webp_target_get_type( void ); - - extern GType vips_foreign_load_pdf_file_get_type( void ); - extern GType vips_foreign_load_pdf_buffer_get_type( void ); - extern GType vips_foreign_load_pdf_source_get_type( void ); - - extern GType vips_foreign_load_svg_file_get_type( void ); - extern GType vips_foreign_load_svg_buffer_get_type( void ); - extern GType vips_foreign_load_svg_source_get_type( void ); - - extern GType vips_foreign_load_jp2k_file_get_type( void ); - extern GType vips_foreign_load_jp2k_buffer_get_type( void ); - extern GType vips_foreign_load_jp2k_source_get_type( void ); - extern GType vips_foreign_save_jp2k_file_get_type( void ); - extern GType vips_foreign_save_jp2k_buffer_get_type( void ); - extern GType vips_foreign_save_jp2k_target_get_type( void ); - - extern GType vips_foreign_load_jxl_file_get_type( void ); - extern GType vips_foreign_load_jxl_buffer_get_type( void ); - extern GType vips_foreign_load_jxl_source_get_type( void ); - extern GType vips_foreign_save_jxl_file_get_type( void ); - extern GType vips_foreign_save_jxl_buffer_get_type( void ); - extern GType vips_foreign_save_jxl_target_get_type( void ); - - extern GType vips_foreign_load_heif_file_get_type( void ); - extern GType vips_foreign_load_heif_buffer_get_type( void ); - extern GType vips_foreign_load_heif_source_get_type( void ); - extern GType vips_foreign_save_heif_file_get_type( void ); - extern GType vips_foreign_save_heif_buffer_get_type( void ); - extern GType vips_foreign_save_heif_target_get_type( void ); - extern GType vips_foreign_save_avif_target_get_type( void ); - - extern GType vips_foreign_load_nifti_file_get_type( void ); - extern GType vips_foreign_load_nifti_source_get_type( void ); - extern GType vips_foreign_save_nifti_get_type( void ); - - extern GType vips_foreign_load_nsgif_file_get_type( void ); - extern GType vips_foreign_load_nsgif_buffer_get_type( void ); - extern GType vips_foreign_load_nsgif_source_get_type( void ); + extern GType vips_foreign_save_dz_file_get_type( void ); + extern GType vips_foreign_save_dz_buffer_get_type( void ); + extern GType vips_foreign_save_dz_target_get_type( void ); + + extern GType vips_foreign_load_webp_file_get_type( void ); + extern GType vips_foreign_load_webp_buffer_get_type( void ); + extern GType vips_foreign_load_webp_source_get_type( void ); + extern GType vips_foreign_save_webp_file_get_type( void ); + extern GType vips_foreign_save_webp_buffer_get_type( void ); + extern GType vips_foreign_save_webp_target_get_type( void ); + + extern GType vips_foreign_load_pdf_file_get_type( void ); + extern GType vips_foreign_load_pdf_buffer_get_type( void ); + extern GType vips_foreign_load_pdf_source_get_type( void ); + + extern GType vips_foreign_load_svg_file_get_type( void ); + extern GType vips_foreign_load_svg_buffer_get_type( void ); + extern GType vips_foreign_load_svg_source_get_type( void ); + + extern GType vips_foreign_load_jp2k_file_get_type( void ); + extern GType vips_foreign_load_jp2k_buffer_get_type( void ); + extern GType vips_foreign_load_jp2k_source_get_type( void ); + extern GType vips_foreign_save_jp2k_file_get_type( void ); + extern GType vips_foreign_save_jp2k_buffer_get_type( void ); + extern GType vips_foreign_save_jp2k_target_get_type( void ); + + extern GType vips_foreign_load_jxl_file_get_type( void ); + extern GType vips_foreign_load_jxl_buffer_get_type( void ); + extern GType vips_foreign_load_jxl_source_get_type( void ); + extern GType vips_foreign_save_jxl_file_get_type( void ); + extern GType vips_foreign_save_jxl_buffer_get_type( void ); + extern GType vips_foreign_save_jxl_target_get_type( void ); + + extern GType vips_foreign_load_heif_file_get_type( void ); + extern GType vips_foreign_load_heif_buffer_get_type( void ); + extern GType vips_foreign_load_heif_source_get_type( void ); + extern GType vips_foreign_save_heif_file_get_type( void ); + extern GType vips_foreign_save_heif_buffer_get_type( void ); + extern GType vips_foreign_save_heif_target_get_type( void ); + extern GType vips_foreign_save_avif_target_get_type( void ); + + extern GType vips_foreign_load_nifti_file_get_type( void ); + extern GType vips_foreign_load_nifti_source_get_type( void ); + extern GType vips_foreign_save_nifti_get_type( void ); + + extern GType vips_foreign_load_nsgif_file_get_type( void ); + extern GType vips_foreign_load_nsgif_buffer_get_type( void ); + extern GType vips_foreign_load_nsgif_source_get_type( void ); extern GType vips_foreign_save_cgif_file_get_type( void ); extern GType vips_foreign_save_cgif_buffer_get_type( void ); extern GType vips_foreign_save_cgif_target_get_type( void ); - vips_foreign_load_csv_file_get_type(); - vips_foreign_load_csv_source_get_type(); - vips_foreign_save_csv_file_get_type(); - vips_foreign_save_csv_target_get_type(); + vips_foreign_load_csv_file_get_type(); + vips_foreign_load_csv_source_get_type(); + vips_foreign_save_csv_file_get_type(); + vips_foreign_save_csv_target_get_type(); - vips_foreign_load_matrix_file_get_type(); - vips_foreign_load_matrix_source_get_type(); - vips_foreign_save_matrix_file_get_type(); - vips_foreign_save_matrix_target_get_type(); - vips_foreign_print_matrix_get_type(); + vips_foreign_load_matrix_file_get_type(); + vips_foreign_load_matrix_source_get_type(); + vips_foreign_save_matrix_file_get_type(); + vips_foreign_save_matrix_target_get_type(); + vips_foreign_print_matrix_get_type(); - vips_foreign_load_raw_get_type(); - vips_foreign_save_raw_get_type(); - vips_foreign_save_raw_fd_get_type(); + vips_foreign_load_raw_get_type(); + vips_foreign_save_raw_get_type(); + vips_foreign_save_raw_fd_get_type(); - vips_foreign_load_vips_file_get_type(); - vips_foreign_load_vips_source_get_type(); - vips_foreign_save_vips_file_get_type(); - vips_foreign_save_vips_target_get_type(); + vips_foreign_load_vips_file_get_type(); + vips_foreign_load_vips_source_get_type(); + vips_foreign_save_vips_file_get_type(); + vips_foreign_save_vips_target_get_type(); #ifdef HAVE_ANALYZE - vips_foreign_load_analyze_get_type(); + vips_foreign_load_analyze_get_type(); #endif /*HAVE_ANALYZE*/ #ifdef HAVE_PPM - vips_foreign_load_ppm_file_get_type(); - vips_foreign_load_ppm_source_get_type(); - vips_foreign_save_ppm_file_get_type(); - vips_foreign_save_pbm_target_get_type(); - vips_foreign_save_pgm_target_get_type(); - vips_foreign_save_ppm_target_get_type(); - vips_foreign_save_pfm_target_get_type(); + vips_foreign_load_ppm_file_get_type(); + vips_foreign_load_ppm_source_get_type(); + vips_foreign_save_ppm_file_get_type(); + vips_foreign_save_pbm_target_get_type(); + vips_foreign_save_pgm_target_get_type(); + vips_foreign_save_ppm_target_get_type(); + vips_foreign_save_pfm_target_get_type(); #endif /*HAVE_PPM*/ #ifdef HAVE_RADIANCE - vips_foreign_load_rad_file_get_type(); - vips_foreign_load_rad_buffer_get_type(); - vips_foreign_load_rad_source_get_type(); - vips_foreign_save_rad_file_get_type(); - vips_foreign_save_rad_buffer_get_type(); - vips_foreign_save_rad_target_get_type(); + vips_foreign_load_rad_file_get_type(); + vips_foreign_load_rad_buffer_get_type(); + vips_foreign_load_rad_source_get_type(); + vips_foreign_save_rad_file_get_type(); + vips_foreign_save_rad_buffer_get_type(); + vips_foreign_save_rad_target_get_type(); #endif /*HAVE_RADIANCE*/ #if defined(HAVE_POPPLER) && !defined(POPPLER_MODULE) - vips_foreign_load_pdf_file_get_type(); - vips_foreign_load_pdf_buffer_get_type(); - vips_foreign_load_pdf_source_get_type(); + vips_foreign_load_pdf_file_get_type(); + vips_foreign_load_pdf_buffer_get_type(); + vips_foreign_load_pdf_source_get_type(); #endif /*defined(HAVE_POPPLER) && !defined(POPPLER_MODULE)*/ #ifdef HAVE_PDFIUM - vips_foreign_load_pdf_file_get_type(); - vips_foreign_load_pdf_buffer_get_type(); - vips_foreign_load_pdf_source_get_type(); + vips_foreign_load_pdf_file_get_type(); + vips_foreign_load_pdf_buffer_get_type(); + vips_foreign_load_pdf_source_get_type(); #endif /*HAVE_PDFIUM*/ #if defined(HAVE_RSVG) || defined(HAVE_RESVG) - vips_foreign_load_svg_file_get_type(); - vips_foreign_load_svg_buffer_get_type(); + vips_foreign_load_svg_file_get_type(); + vips_foreign_load_svg_buffer_get_type(); #if defined(HAVE_RSVG) - vips_foreign_load_svg_source_get_type(); + vips_foreign_load_svg_source_get_type(); #endif #endif /*HAVE_RSVG*/ #if defined(HAVE_LIBJXL) && !defined(LIBJXL_MODULE) - vips_foreign_load_jxl_file_get_type(); - vips_foreign_load_jxl_buffer_get_type(); - vips_foreign_load_jxl_source_get_type(); - vips_foreign_save_jxl_file_get_type(); - vips_foreign_save_jxl_buffer_get_type(); - vips_foreign_save_jxl_target_get_type(); + vips_foreign_load_jxl_file_get_type(); + vips_foreign_load_jxl_buffer_get_type(); + vips_foreign_load_jxl_source_get_type(); + vips_foreign_save_jxl_file_get_type(); + vips_foreign_save_jxl_buffer_get_type(); + vips_foreign_save_jxl_target_get_type(); #endif /*defined(HAVE_LIBJXL) && !defined(LIBJXL_MODULE)*/ #ifdef HAVE_LIBOPENJP2 - vips_foreign_load_jp2k_file_get_type(); - vips_foreign_load_jp2k_buffer_get_type(); - vips_foreign_load_jp2k_source_get_type(); - vips_foreign_save_jp2k_file_get_type(); - vips_foreign_save_jp2k_buffer_get_type(); - vips_foreign_save_jp2k_target_get_type(); + vips_foreign_load_jp2k_file_get_type(); + vips_foreign_load_jp2k_buffer_get_type(); + vips_foreign_load_jp2k_source_get_type(); + vips_foreign_save_jp2k_file_get_type(); + vips_foreign_save_jp2k_buffer_get_type(); + vips_foreign_save_jp2k_target_get_type(); #endif /*HAVE_LIBOPENJP2*/ #ifdef HAVE_NSGIF vips_foreign_load_nsgif_file_get_type(); - vips_foreign_load_nsgif_buffer_get_type(); - vips_foreign_load_nsgif_source_get_type(); + vips_foreign_load_nsgif_buffer_get_type(); + vips_foreign_load_nsgif_source_get_type(); #endif /*HAVE_NSGIF*/ #ifdef HAVE_CGIF @@ -3045,64 +3045,64 @@ vips_foreign_operation_init( void ) #endif /*HAVE_CGIF*/ #ifdef HAVE_GSF - vips_foreign_save_dz_file_get_type(); - vips_foreign_save_dz_buffer_get_type(); - vips_foreign_save_dz_target_get_type(); + vips_foreign_save_dz_file_get_type(); + vips_foreign_save_dz_buffer_get_type(); + vips_foreign_save_dz_target_get_type(); #endif /*HAVE_GSF*/ #ifdef HAVE_PNG - vips_foreign_load_png_file_get_type(); - vips_foreign_load_png_buffer_get_type(); - vips_foreign_load_png_source_get_type(); - vips_foreign_save_png_file_get_type(); - vips_foreign_save_png_buffer_get_type(); - vips_foreign_save_png_target_get_type(); + vips_foreign_load_png_file_get_type(); + vips_foreign_load_png_buffer_get_type(); + vips_foreign_load_png_source_get_type(); + vips_foreign_save_png_file_get_type(); + vips_foreign_save_png_buffer_get_type(); + vips_foreign_save_png_target_get_type(); #endif /*HAVE_PNG*/ #ifdef HAVE_SPNG - vips_foreign_load_png_file_get_type(); - vips_foreign_load_png_buffer_get_type(); - vips_foreign_load_png_source_get_type(); - vips_foreign_save_spng_file_get_type(); - vips_foreign_save_spng_buffer_get_type(); - vips_foreign_save_spng_target_get_type(); + vips_foreign_load_png_file_get_type(); + vips_foreign_load_png_buffer_get_type(); + vips_foreign_load_png_source_get_type(); + vips_foreign_save_spng_file_get_type(); + vips_foreign_save_spng_buffer_get_type(); + vips_foreign_save_spng_target_get_type(); #endif /*HAVE_SPNG*/ #ifdef HAVE_MATIO - vips_foreign_load_mat_get_type(); + vips_foreign_load_mat_get_type(); #endif /*HAVE_MATIO*/ #ifdef HAVE_JPEG - vips_foreign_load_jpeg_file_get_type(); - vips_foreign_load_jpeg_buffer_get_type(); - vips_foreign_load_jpeg_source_get_type(); - vips_foreign_save_jpeg_file_get_type(); - vips_foreign_save_jpeg_buffer_get_type(); - vips_foreign_save_jpeg_target_get_type(); - vips_foreign_save_jpeg_mime_get_type(); + vips_foreign_load_jpeg_file_get_type(); + vips_foreign_load_jpeg_buffer_get_type(); + vips_foreign_load_jpeg_source_get_type(); + vips_foreign_save_jpeg_file_get_type(); + vips_foreign_save_jpeg_buffer_get_type(); + vips_foreign_save_jpeg_target_get_type(); + vips_foreign_save_jpeg_mime_get_type(); #endif /*HAVE_JPEG*/ #ifdef HAVE_LIBWEBP - vips_foreign_load_webp_file_get_type(); - vips_foreign_load_webp_buffer_get_type(); - vips_foreign_load_webp_source_get_type(); - vips_foreign_save_webp_file_get_type(); - vips_foreign_save_webp_buffer_get_type(); - vips_foreign_save_webp_target_get_type(); + vips_foreign_load_webp_file_get_type(); + vips_foreign_load_webp_buffer_get_type(); + vips_foreign_load_webp_source_get_type(); + vips_foreign_save_webp_file_get_type(); + vips_foreign_save_webp_buffer_get_type(); + vips_foreign_save_webp_target_get_type(); #endif /*HAVE_LIBWEBP*/ #ifdef HAVE_TIFF - vips_foreign_load_tiff_file_get_type(); - vips_foreign_load_tiff_buffer_get_type(); - vips_foreign_load_tiff_source_get_type(); - vips_foreign_save_tiff_file_get_type(); - vips_foreign_save_tiff_buffer_get_type(); - vips_foreign_save_tiff_target_get_type(); + vips_foreign_load_tiff_file_get_type(); + vips_foreign_load_tiff_buffer_get_type(); + vips_foreign_load_tiff_source_get_type(); + vips_foreign_save_tiff_file_get_type(); + vips_foreign_save_tiff_buffer_get_type(); + vips_foreign_save_tiff_target_get_type(); #endif /*HAVE_TIFF*/ #if defined(HAVE_OPENSLIDE) && !defined(OPENSLIDE_MODULE) - vips_foreign_load_openslide_file_get_type(); - vips_foreign_load_openslide_source_get_type(); + vips_foreign_load_openslide_file_get_type(); + vips_foreign_load_openslide_source_get_type(); #endif /*defined(HAVE_OPENSLIDE) && !defined(OPENSLIDE_MODULE)*/ #if defined(ENABLE_MAGICKLOAD) && !defined(MAGICK_MODULE) @@ -3127,34 +3127,34 @@ vips_foreign_operation_init( void ) #endif /*defined(ENABLE_MAGICKSAVE) && !defined(MAGICK_MODULE)*/ #ifdef HAVE_CFITSIO - vips_foreign_load_fits_file_get_type(); - vips_foreign_load_fits_source_get_type(); - vips_foreign_save_fits_get_type(); + vips_foreign_load_fits_file_get_type(); + vips_foreign_load_fits_source_get_type(); + vips_foreign_save_fits_get_type(); #endif /*HAVE_CFITSIO*/ #ifdef HAVE_OPENEXR - vips_foreign_load_openexr_get_type(); + vips_foreign_load_openexr_get_type(); #endif /*HAVE_OPENEXR*/ #ifdef HAVE_NIFTI - vips_foreign_load_nifti_file_get_type(); - vips_foreign_load_nifti_source_get_type(); - vips_foreign_save_nifti_get_type(); + vips_foreign_load_nifti_file_get_type(); + vips_foreign_load_nifti_source_get_type(); + vips_foreign_save_nifti_get_type(); #endif /*HAVE_NIFTI*/ #if defined(HAVE_HEIF_DECODER) && !defined(HEIF_MODULE) - vips_foreign_load_heif_file_get_type(); - vips_foreign_load_heif_buffer_get_type(); - vips_foreign_load_heif_source_get_type(); + vips_foreign_load_heif_file_get_type(); + vips_foreign_load_heif_buffer_get_type(); + vips_foreign_load_heif_source_get_type(); #endif /*defined(HAVE_HEIF_DECODER) && !defined(HEIF_MODULE)*/ #if defined(HAVE_HEIF_ENCODER) && !defined(HEIF_MODULE) - vips_foreign_save_heif_file_get_type(); - vips_foreign_save_heif_buffer_get_type(); - vips_foreign_save_heif_target_get_type(); + vips_foreign_save_heif_file_get_type(); + vips_foreign_save_heif_buffer_get_type(); + vips_foreign_save_heif_target_get_type(); vips_foreign_save_avif_target_get_type(); #endif /*defined(HAVE_HEIF_ENCODER) && !defined(HEIF_MODULE)*/ - vips__foreign_load_operation = - g_quark_from_static_string( "vips-foreign-load-operation" ); + vips__foreign_load_operation = + g_quark_from_static_string( "vips-foreign-load-operation" ); } diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index f607e59f13..8c36b994eb 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -21,7 +21,7 @@ * - rework as a sequential loader to reduce overcomputation * 11/6/21 * - switch to rsvg_handle_render_document() - * - librsvg can no longer render very large images :( + * - librsvg can no longer render very large images :( * 14/10/21 * - allow utf-8 headers for svg detection * 28/4/22 @@ -33,7 +33,7 @@ /* This file is part of VIPS. - + VIPS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -143,7 +143,7 @@ typedef struct _VipsForeignLoadSvg { typedef VipsForeignLoadClass VipsForeignLoadSvgClass; -G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadSvg, vips_foreign_load_svg, +G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadSvg, vips_foreign_load_svg, VIPS_TYPE_FOREIGN_LOAD ); #ifdef HANDLE_SVGZ @@ -160,16 +160,16 @@ vips_foreign_load_svg_zfree( void *opaque, void *ptr ) } #endif /*HANDLE_SVGZ*/ -/* Find a utf-8 substring within the first len_bytes (not characters). +/* Find a utf-8 substring within the first len_bytes (not characters). * * - case-insensitive * - needle must be zero-terminated, but hackstack need not be * - haystack can be null-terminated - * - if haystack is shorter than len bytes, that'll end the search + * - if haystack is shorter than len bytes, that'll end the search * - if we hit invalid utf-8, we return NULL */ static const char * -vips_utf8_strcasestr( const char *haystack_start, const char *needle_start, +vips_utf8_strcasestr( const char *haystack_start, const char *needle_start, int len_bytes ) { int needle_len = g_utf8_strlen( needle_start, -1 ); @@ -177,8 +177,8 @@ vips_utf8_strcasestr( const char *haystack_start, const char *needle_start, const char *haystack; - for( haystack = haystack_start; - haystack - haystack_start <= len_bytes - needle_len_bytes; + for( haystack = haystack_start; + haystack - haystack_start <= len_bytes - needle_len_bytes; haystack = g_utf8_find_next_char( haystack, NULL ) ) { const char *needle_char; const char *haystack_char; @@ -191,16 +191,16 @@ vips_utf8_strcasestr( const char *haystack_start, const char *needle_start, * might end half-way through a utf-8 character, so we * need to be careful not to run off the end. */ - gunichar a = - g_utf8_get_char_validated( haystack_char, + gunichar a = + g_utf8_get_char_validated( haystack_char, haystack_start + len_bytes - haystack ); - gunichar b = + gunichar b = g_utf8_get_char_validated( needle_char, -1 ); - /* Invalid utf8? + /* Invalid utf8? * - * gunichar is a uint32, so we can't compare < 0, we - * have to look for -1 and -2 (the two possible error + * gunichar is a uint32, so we can't compare < 0, we + * have to look for -1 and -2 (the two possible error * values). */ if( a == (gunichar) -1 || @@ -220,15 +220,15 @@ vips_utf8_strcasestr( const char *haystack_start, const char *needle_start, if( g_unichar_tolower( a ) != g_unichar_tolower( b ) ) break; - haystack_char = - g_utf8_find_next_char( haystack_char, + haystack_char = + g_utf8_find_next_char( haystack_char, haystack_start + len_bytes ); - needle_char = + needle_char = g_utf8_find_next_char( needle_char, NULL ); } if( i == needle_len ) - /* Walked the whole of needle, so we must have found a + /* Walked the whole of needle, so we must have found a * complete match. */ return( haystack ); @@ -263,8 +263,8 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) * * Minimum gzip size is 18 bytes, starting with 1F 8B. */ - if( len >= 18 && - str[0] == '\037' && + if( len >= 18 && + str[0] == '\037' && str[1] == '\213' ) { z_stream zs; size_t opos; @@ -277,7 +277,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) /* There isn't really an error return from is_a_buffer() */ - if( inflateInit2( &zs, 15 | 32 ) != Z_OK ) + if( inflateInit2( &zs, 15 | 32 ) != Z_OK ) return( FALSE ); opos = 0; @@ -289,7 +289,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) return( FALSE ); } opos = sizeof( obuf ) - zs.avail_out; - } while( opos < sizeof( obuf ) && + } while( opos < sizeof( obuf ) && zs.avail_in > 0 ); inflateEnd( &zs ); @@ -313,7 +313,7 @@ vips_foreign_load_svg_is_a( const void *buf, size_t len ) * valid utf-8. * * We could rsvg_handle_new_from_data() on the buffer, but that can be - * horribly slow for large documents. + * horribly slow for large documents. */ if( vips_utf8_strcasestr( str, "page, + if( !rsvg_handle_get_intrinsic_size_in_pixels( svg->page, &width, &height ) ) { RsvgRectangle viewbox; @@ -442,8 +442,8 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, &has_viewbox, &viewbox ); #if LIBRSVG_CHECK_VERSION( 2, 54, 0 ) - /* After librsvg 2.54.0, the `has_width` and `has_height` - * arguments always returns `TRUE`, since with SVG2 all + /* After librsvg 2.54.0, the `has_width` and `has_height` + * arguments always returns `TRUE`, since with SVG2 all * documents *have* a default width and height of `100%`. */ width = svg_css_length_to_pixels( iwidth, svg->dpi ); @@ -453,7 +453,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, has_height = height > 0.0; if( has_width && has_height ) { - /* Success! Taking the viewbox into account is not + /* Success! Taking the viewbox into account is not * needed. */ } @@ -490,7 +490,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, if( width <= 0.0 || height <= 0.0 ) { - /* We haven't found a usable set of sizes, so try + /* We haven't found a usable set of sizes, so try * working out the visible area. */ rsvg_handle_get_geometry_for_element( svg->page, NULL, @@ -519,7 +519,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, /* width or height below 0.5 can't be rounded to 1. */ - if( width < 0.5 || + if( width < 0.5 || height < 0.5 ) { vips_error( class->nickname, "%s", _( "bad dimensions" ) ); return( -1 ); @@ -532,7 +532,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, } static int -vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, +vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, int *out_width, int *out_height ) { double width; @@ -575,12 +575,12 @@ vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, VipsImage *out ) */ res = svg->dpi / 25.4; - vips_image_init_fields( out, + vips_image_init_fields( out, width, height, 4, VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, VIPS_INTERPRETATION_sRGB, res, res ); - /* We render to a cache with a couple of rows of tiles, so fat strips + /* We render to a cache with a couple of rows of tiles, so fat strips * work well. */ if( vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL ) ) @@ -598,7 +598,7 @@ vips_foreign_load_svg_header( VipsForeignLoad *load ) } static int -vips_foreign_load_svg_generate( VipsRegion *or, +vips_foreign_load_svg_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { const VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) a; @@ -606,13 +606,13 @@ vips_foreign_load_svg_generate( VipsRegion *or, #ifdef DEBUG printf( "vips_foreign_load_svg_generate:\n " - "left = %d, top = %d, width = %d, height = %d\n", - r->left, r->top, r->width, r->height ); + "left = %d, top = %d, width = %d, height = %d\n", + r->left, r->top, r->width, r->height ); #endif /*DEBUG*/ /* SVG won't always paint the background. */ - vips_region_black( or ); + vips_region_black( or ); #ifdef HAVE_RSVG const VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( svg ); @@ -621,10 +621,10 @@ vips_foreign_load_svg_generate( VipsRegion *or, cairo_t *cr; int y; - surface = cairo_image_surface_create_for_data( - VIPS_REGION_ADDR( or, r->left, r->top ), - CAIRO_FORMAT_ARGB32, - r->width, r->height, + surface = cairo_image_surface_create_for_data( + VIPS_REGION_ADDR( or, r->left, r->top ), + CAIRO_FORMAT_ARGB32, + r->width, r->height, VIPS_REGION_LSKIP( or ) ); cr = cairo_create( surface ); cairo_surface_destroy( surface ); @@ -650,7 +650,7 @@ vips_foreign_load_svg_generate( VipsRegion *or, if( !rsvg_handle_render_document( svg->page, cr, &viewport, &error ) ) { cairo_destroy( cr ); vips_operation_invalidate( VIPS_OPERATION( svg ) ); - vips_error( class->nickname, + vips_error( class->nickname, "%s", _( "SVG rendering failed" ) ); vips_g_error( &error ); return( -1 ); @@ -679,10 +679,10 @@ vips_foreign_load_svg_generate( VipsRegion *or, /* Cairo makes pre-multipled BRGA -- we must byteswap and unpremultiply. */ - for( y = 0; y < r->height; y++ ) - vips__premultiplied_bgra2rgba( + for( y = 0; y < r->height; y++ ) + vips__premultiplied_bgra2rgba( (guint32 *) VIPS_REGION_ADDR( or, r->left, r->top + y ), - r->width ); + r->width ); #else guint8 *pixmap = VIPS_REGION_ADDR( or, r->left, r->top ); @@ -716,19 +716,19 @@ vips_foreign_load_svg_generate( VipsRegion *or, #endif - return( 0 ); + return( 0 ); } static int vips_foreign_load_svg_load( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsImage **t = (VipsImage **) + VipsImage **t = (VipsImage **) vips_object_local_array( (VipsObject *) load, 3 ); /* Enough tiles for two complete rows. */ - t[0] = vips_image_new(); + t[0] = vips_image_new(); if( vips_foreign_load_svg_parse( svg, t[0] ) || vips_image_generate( t[0], NULL, vips_foreign_load_svg_generate, NULL, svg, NULL ) || @@ -737,7 +737,7 @@ vips_foreign_load_svg_load( VipsForeignLoad *load ) "tile_height", TILE_SIZE, "max_tiles", 2 * (1 + t[0]->Xsize / TILE_SIZE), NULL ) || - vips_image_write( t[1], load->real ) ) + vips_image_write( t[1], load->real ) ) return( -1 ); return( 0 ); @@ -768,7 +768,7 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class ) */ foreign_class->priority = -5; - load_class->get_flags_filename = + load_class->get_flags_filename = vips_foreign_load_svg_get_flags_filename; load_class->get_flags = vips_foreign_load_svg_get_flags; load_class->load = vips_foreign_load_svg_load; @@ -819,7 +819,7 @@ typedef struct _VipsForeignLoadSvgSource { typedef VipsForeignLoadClass VipsForeignLoadSvgSourceClass; -G_DEFINE_TYPE( VipsForeignLoadSvgSource, vips_foreign_load_svg_source, +G_DEFINE_TYPE( VipsForeignLoadSvgSource, vips_foreign_load_svg_source, vips_foreign_load_svg_get_type() ); gboolean @@ -828,7 +828,7 @@ vips_foreign_load_svg_source_is_a_source( VipsSource *source ) unsigned char *data; gint64 bytes_read; - if( (bytes_read = vips_source_sniff_at_most( source, + if( (bytes_read = vips_source_sniff_at_most( source, &data, SVG_HEADER_SIZE )) <= 0 ) return( FALSE ); @@ -839,7 +839,7 @@ static int vips_foreign_load_svg_source_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsForeignLoadSvgSource *source = + VipsForeignLoadSvgSource *source = (VipsForeignLoadSvgSource *) load; RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; @@ -851,11 +851,11 @@ vips_foreign_load_svg_source_header( VipsForeignLoad *load ) return( -1 ); gstream = vips_g_input_stream_new_from_source( source->source ); - if( !(svg->page = rsvg_handle_new_from_stream_sync( + if( !(svg->page = rsvg_handle_new_from_stream_sync( gstream, NULL, flags, NULL, &error )) ) { g_object_unref( gstream ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gstream ); return( vips_foreign_load_svg_header( load ) ); @@ -897,7 +897,7 @@ vips_foreign_load_svg_source_class_init( VipsForeignLoadSvgSourceClass *class ) VIPS_ARG_OBJECT( class, "source", 1, _( "Source" ), _( "Source to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgSource, source ), VIPS_TYPE_SOURCE ); @@ -914,13 +914,13 @@ typedef struct _VipsForeignLoadSvgFile { /* Filename for load. */ - char *filename; + char *filename; } VipsForeignLoadSvgFile; typedef VipsForeignLoadSvgClass VipsForeignLoadSvgFileClass; -G_DEFINE_TYPE( VipsForeignLoadSvgFile, vips_foreign_load_svg_file, +G_DEFINE_TYPE( VipsForeignLoadSvgFile, vips_foreign_load_svg_file, vips_foreign_load_svg_get_type() ); static gboolean @@ -929,7 +929,7 @@ vips_foreign_load_svg_file_is_a( const char *filename ) unsigned char buf[SVG_HEADER_SIZE]; guint64 bytes; - return( (bytes = vips__get_bytes( filename, + return( (bytes = vips__get_bytes( filename, buf, SVG_HEADER_SIZE )) > 0 && vips_foreign_load_svg_is_a( buf, bytes ) ); } @@ -966,11 +966,11 @@ vips_foreign_load_svg_file_header( VipsForeignLoad *load ) GFile *gfile; gfile = g_file_new_for_path( file->filename ); - if( !(svg->page = rsvg_handle_new_from_gfile_sync( - gfile, flags, NULL, &error )) ) { + if( !(svg->page = rsvg_handle_new_from_gfile_sync( + gfile, flags, NULL, &error )) ) { g_object_unref( gfile ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gfile ); #else @@ -997,7 +997,7 @@ static const char *vips_foreign_svg_suffs[] = { }; static void -vips_foreign_load_svg_file_class_init( +vips_foreign_load_svg_file_class_init( VipsForeignLoadSvgFileClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); @@ -1015,10 +1015,10 @@ vips_foreign_load_svg_file_class_init( load_class->is_a = vips_foreign_load_svg_file_is_a; load_class->header = vips_foreign_load_svg_file_header; - VIPS_ARG_STRING( class, "filename", 1, + VIPS_ARG_STRING( class, "filename", 1, _( "Filename" ), _( "Filename to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgFile, filename ), NULL ); @@ -1040,14 +1040,14 @@ typedef struct _VipsForeignLoadSvgBuffer { typedef VipsForeignLoadSvgClass VipsForeignLoadSvgBufferClass; -G_DEFINE_TYPE( VipsForeignLoadSvgBuffer, vips_foreign_load_svg_buffer, +G_DEFINE_TYPE( VipsForeignLoadSvgBuffer, vips_foreign_load_svg_buffer, vips_foreign_load_svg_get_type() ); static int vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; - VipsForeignLoadSvgBuffer *buffer = + VipsForeignLoadSvgBuffer *buffer = (VipsForeignLoadSvgBuffer *) load; #ifdef HAVE_RSVG RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; @@ -1056,13 +1056,13 @@ vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) GInputStream *gstream; - gstream = g_memory_input_stream_new_from_data( + gstream = g_memory_input_stream_new_from_data( buffer->buf->data, buffer->buf->length, NULL ); - if( !(svg->page = rsvg_handle_new_from_stream_sync( - gstream, NULL, flags, NULL, &error )) ) { + if( !(svg->page = rsvg_handle_new_from_stream_sync( + gstream, NULL, flags, NULL, &error )) ) { g_object_unref( gstream ); vips_g_error( &error ); - return( -1 ); + return( -1 ); } g_object_unref( gstream ); #else @@ -1076,7 +1076,7 @@ vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) } static void -vips_foreign_load_svg_buffer_class_init( +vips_foreign_load_svg_buffer_class_init( VipsForeignLoadSvgBufferClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); @@ -1091,10 +1091,10 @@ vips_foreign_load_svg_buffer_class_init( load_class->is_a_buffer = vips_foreign_load_svg_is_a; load_class->header = vips_foreign_load_svg_buffer_header; - VIPS_ARG_BOXED( class, "buffer", 1, + VIPS_ARG_BOXED( class, "buffer", 1, _( "Buffer" ), _( "Buffer to load from" ), - VIPS_ARGUMENT_REQUIRED_INPUT, + VIPS_ARGUMENT_REQUIRED_INPUT, G_STRUCT_OFFSET( VipsForeignLoadSvgBuffer, buf ), VIPS_TYPE_BLOB ); @@ -1123,7 +1123,7 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) * and should be fast. * * Use @dpi to set the rendering resolution. The default is 72. You can also - * scale the rendering by @scale. + * scale the rendering by @scale. * * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. @@ -1162,10 +1162,10 @@ vips_svgload( const char *filename, VipsImage **out, ... ) * * @unlimited: %gboolean, allow SVGs of any size * * Read a SVG-formatted memory block into a VIPS image. Exactly as - * vips_svgload(), but read from a memory buffer. + * vips_svgload(), but read from a memory buffer. * - * You must not free the buffer while @out is active. The - * #VipsObject::postclose signal on @out is a good place to free. + * You must not free the buffer while @out is active. The + * #VipsObject::postclose signal on @out is a good place to free. * * See also: vips_svgload(). * @@ -1236,7 +1236,7 @@ vips_svgload_string( const char *str, VipsImage **out, ... ) * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * - * Exactly as vips_svgload(), but read from a source. + * Exactly as vips_svgload(), but read from a source. * * See also: vips_svgload(). * From d15c1ed9acb242fda85292588776fdfdc1118788 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 17 Jan 2023 18:40:23 +0100 Subject: [PATCH 03/11] Adapt to libvips style PR 3125 would resolve this in a better way with clang-format. --- libvips/foreign/foreign.c | 4 +- libvips/foreign/svgload.c | 83 +++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 521a6917de..3da372e52e 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -3009,10 +3009,10 @@ vips_foreign_operation_init( void ) #if defined(HAVE_RSVG) || defined(HAVE_RESVG) vips_foreign_load_svg_file_get_type(); vips_foreign_load_svg_buffer_get_type(); -#if defined(HAVE_RSVG) +#ifdef HAVE_RSVG vips_foreign_load_svg_source_get_type(); #endif -#endif /*HAVE_RSVG*/ +#endif /*defined(HAVE_RSVG) || defined(HAVE_RESVG)*/ #if defined(HAVE_LIBJXL) && !defined(LIBJXL_MODULE) vips_foreign_load_jxl_file_get_type(); diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 8c36b994eb..26e7866922 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -330,9 +330,7 @@ vips_foreign_load_svg_dispose( GObject *gobject ) VIPS_UNREF( svg->page ); #else resvg_options_destroy( svg->options ); - if ( svg->tree ) { - resvg_tree_destroy( svg->tree ); - } + VIPS_FREEF( resvg_tree_destroy, svg->tree ); #endif G_OBJECT_CLASS( vips_foreign_load_svg_parent_class )-> @@ -512,7 +510,7 @@ vips_foreign_load_svg_get_natural_size( VipsForeignLoadSvg *svg, #endif /*LIBRSVG_CHECK_VERSION( 2, 52, 0 )*/ #else /* HAVE_RSVG */ - resvg_size size = resvg_get_image_size(svg->tree); + resvg_size size = resvg_get_image_size( svg->tree ); width = size.width; height = size.height; #endif @@ -543,7 +541,7 @@ vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, #ifdef HAVE_RSVG rsvg_handle_set_dpi( svg->page, 72.0 ); #else - resvg_options_set_dpi(svg->options, 72.0); + resvg_options_set_dpi( svg->options, 72.0 ); #endif if( vips_foreign_load_svg_get_natural_size( svg, &width, &height ) ) return( -1 ); @@ -701,17 +699,21 @@ vips_foreign_load_svg_generate( VipsRegion *or, (char *) pixmap ); - // Just unpremultiply. - for (int i = 0; i < r->width * r->height; i++) { + /* Just unpremultiply. + */ + for( int i = 0; i < r->width * r->height; i++ ) { guint8 *ptr = &pixmap[i * 4]; guint8 a = ptr[3]; - // Skip transparent and fully opaque pixels. - if ( a != 0 && a != 255 ) { - // Any compiler will unroll it. - for (int i = 0; i < 3; i++) { - ptr[i] = 255 * ptr[i] / a; - } - } + + /* Skip transparent and fully opaque pixels. + */ + if( a == 0 || a == 255 ) + continue; + + /* Any compiler will unroll it. + */ + for( int j = 0; j < 3; j++ ) + ptr[j] = 255 * ptr[j] / a; } #endif @@ -934,22 +936,23 @@ vips_foreign_load_svg_file_is_a( const char *filename ) vips_foreign_load_svg_is_a( buf, bytes ) ); } -static const char *resvg_error_msg(resvg_error e) { - switch (e) { - case RESVG_ERROR_NOT_AN_UTF8_STR: - return "only UTF-8 content is supported"; - case RESVG_ERROR_FILE_OPEN_FAILED: - return "failed to open the provided file"; - case RESVG_ERROR_MALFORMED_GZIP: - return "compressed SVG must use the GZip algorithm"; - case RESVG_ERROR_ELEMENTS_LIMIT_REACHED: - return "we do not allow SVG with more than 1_000_000 elements for security reasons"; - case RESVG_ERROR_INVALID_SIZE: - return "SVG doesn't have a valid size"; - case RESVG_ERROR_PARSING_FAILED: - return "failed to parse SVG data"; - default: - return "unknown error"; +static const char * +resvg_error_msg( resvg_error e ) { + switch( e ) { + case RESVG_ERROR_NOT_AN_UTF8_STR: + return "only UTF-8 content is supported"; + case RESVG_ERROR_FILE_OPEN_FAILED: + return "failed to open the provided file"; + case RESVG_ERROR_MALFORMED_GZIP: + return "compressed SVG must use the GZip algorithm"; + case RESVG_ERROR_ELEMENTS_LIMIT_REACHED: + return "we do not allow SVG with more than 1_000_000 elements for security reasons"; + case RESVG_ERROR_INVALID_SIZE: + return "SVG doesn't have a valid size"; + case RESVG_ERROR_PARSING_FAILED: + return "failed to parse SVG data"; + default: + return "unknown error"; } } @@ -974,10 +977,12 @@ vips_foreign_load_svg_file_header( VipsForeignLoad *load ) } g_object_unref( gfile ); #else - resvg_error error = resvg_parse_tree_from_file(file->filename, svg->options, &svg->tree); - if (error != RESVG_OK) { - vips_error(VIPS_OBJECT_GET_CLASS( svg )->nickname, "%s", resvg_error_msg(error)); - return (-1); + resvg_error error = resvg_parse_tree_from_file( + file->filename, svg->options, &svg->tree ); + if( error != RESVG_OK ) { + vips_error( VIPS_OBJECT_GET_CLASS( svg )->nickname, + "%s", resvg_error_msg( error ) ); + return( -1 ); } #endif VIPS_SETSTR( load->out->filename, file->filename ); @@ -1066,10 +1071,12 @@ vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) } g_object_unref( gstream ); #else - resvg_error error = resvg_parse_tree_from_data(buffer->buf->data, buffer->buf->length, svg->options, &svg->tree); - if (error != RESVG_OK) { - vips_error(VIPS_OBJECT_GET_CLASS( svg )->nickname, "%s", resvg_error_msg(error)); - return (-1); + resvg_error error = resvg_parse_tree_from_data( + buffer->buf->data, buffer->buf->length, svg->options, &svg->tree ); + if( error != RESVG_OK ) { + vips_error( VIPS_OBJECT_GET_CLASS( svg )->nickname, + "%s", resvg_error_msg( error ) ); + return( -1 ); } #endif return( vips_foreign_load_svg_header( load ) ); From bc9dd66824d4ebeefe754e2d0c5c61360add2f67 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 17 Jan 2023 18:42:18 +0100 Subject: [PATCH 04/11] Fix build with librsvg --- libvips/foreign/svgload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 26e7866922..0248bf29b0 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -936,6 +936,7 @@ vips_foreign_load_svg_file_is_a( const char *filename ) vips_foreign_load_svg_is_a( buf, bytes ) ); } +#ifndef HAVE_RSVG static const char * resvg_error_msg( resvg_error e ) { switch( e ) { @@ -955,6 +956,7 @@ resvg_error_msg( resvg_error e ) { return "unknown error"; } } +#endif static int vips_foreign_load_svg_file_header( VipsForeignLoad *load ) From 349a7b766333f831790374fe06ca21d64d8b26ee Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 17 Jan 2023 19:16:30 +0100 Subject: [PATCH 05/11] Build a dynamically loadable module for resvg --- libvips/foreign/foreign.c | 2 +- libvips/foreign/meson.build | 9 ++++- libvips/meson.build | 15 ++++++++ libvips/module/resvg.c | 70 +++++++++++++++++++++++++++++++++++++ meson.build | 21 ++++++----- meson_options.txt | 5 +++ 6 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 libvips/module/resvg.c diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 3da372e52e..a5066413d1 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -3006,7 +3006,7 @@ vips_foreign_operation_init( void ) vips_foreign_load_pdf_source_get_type(); #endif /*HAVE_PDFIUM*/ -#if defined(HAVE_RSVG) || defined(HAVE_RESVG) +#if (defined(HAVE_RSVG) || defined(HAVE_RESVG)) && !defined(RESVG_MODULE) vips_foreign_load_svg_file_get_type(); vips_foreign_load_svg_buffer_get_type(); #ifdef HAVE_RSVG diff --git a/libvips/foreign/meson.build b/libvips/foreign/meson.build index a72f9c7867..253faa3d11 100644 --- a/libvips/foreign/meson.build +++ b/libvips/foreign/meson.build @@ -44,7 +44,6 @@ foreign_sources = files( 'rawsave.c', 'spngload.c', 'spngsave.c', - 'svgload.c', 'tiff2vips.c', 'tiff.c', 'tiffload.c', @@ -123,6 +122,14 @@ endif libvips_sources += foreign_sources +resvg_module_sources = files( + 'svgload.c', +) + +if not resvg_module + foreign_sources += resvg_module_sources +endif + foreign_lib = static_library('foreign', foreign_sources, foreign_headers, diff --git a/libvips/meson.build b/libvips/meson.build index 4fe672b1f1..29e0a27631 100644 --- a/libvips/meson.build +++ b/libvips/meson.build @@ -165,3 +165,18 @@ if openslide_module install_dir: module_dir ) endif + +if resvg_module + shared_module('vips-resvg', + 'module/resvg.c', + resvg_module_sources, + c_args: module_c_args, + link_args: module_link_args, + name_prefix: '', + name_suffix: module_suffix, + dependencies: [gmodule_dep, libvips_dep, resvg_dep], + gnu_symbol_visibility: 'hidden', + install: true, + install_dir: module_dir + ) +endif diff --git a/libvips/module/resvg.c b/libvips/module/resvg.c new file mode 100644 index 0000000000..de53db8960 --- /dev/null +++ b/libvips/module/resvg.c @@ -0,0 +1,70 @@ +/* resvg as a dynamically loadable module + * + * 17/1/23 kleisauke + * - initial + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +/* +#define DEBUG + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include + +#include +#include +#include + +#if defined(HAVE_RESVG) && defined(RESVG_MODULE) + +/* This is called on module load. + */ +G_MODULE_EXPORT const gchar * +g_module_check_init( GModule *module ) +{ +#ifdef DEBUG + printf( "vips_resvg: module init\n" ); +#endif /*DEBUG*/ + + extern GType vips_foreign_load_svg_file_get_type( void ); + extern GType vips_foreign_load_svg_buffer_get_type( void ); + + vips_foreign_load_svg_file_get_type(); + vips_foreign_load_svg_buffer_get_type(); + + return( NULL ); +} + +#endif /*defined(HAVE_RESVG) && defined(RESVG_MODULE)*/ diff --git a/meson.build b/meson.build index b2ed5d876c..ff0d21d3e3 100644 --- a/meson.build +++ b/meson.build @@ -371,13 +371,18 @@ if librsvg_found cfg_var.set('HAVE_RSVG', '1') endif -# libresvg doesn't ship pkg-config files, so we can't use dependency(). -libresvg_dep = cc.find_library('resvg', has_headers: ['resvg.h'], required: get_option('resvg')) -libresvg_found = libresvg_dep.found() -if libresvg_found - # It's annoying that I have to spell out the `include_directories` here, but without it Meson can build - # but `compile_commands.json` doesn't have the -I$PREFIX/include, making code analysis tools & VSCode fail. - libvips_deps += declare_dependency(dependencies: [libresvg_dep], include_directories: [include_directories(get_option('prefix') / get_option('includedir'))], link_args: ['-ldl']) +# only if librsvg not found +resvg_dep = disabler() +resvg_module = false +if not librsvg_found + # resvg doesn't ship pkg-config files, so we can't use dependency() + resvg_dep = cc.find_library('resvg', has_headers: ['resvg.h'], required: get_option('resvg')) + resvg_module = modules_enabled and not get_option('resvg-module').disabled() + if resvg_module + cfg_var.set('RESVG_MODULE', '1') + else + libvips_deps += resvg_dep + endif cfg_var.set('HAVE_RESVG', '1') endif @@ -644,7 +649,7 @@ build_summary = { 'PDF load with PDFium': [pdfium_dep.found()], 'PDF load with poppler-glib': [libpoppler_found, ' (dynamic module: ', libpoppler_module, ')'], 'SVG load with librsvg': [librsvg_found], - 'SVG load with libresvg': [libresvg_found], + 'SVG load with libresvg': [resvg_dep.found(), ' (dynamic module: ', resvg_module, ')'], 'EXR load with OpenEXR': [openexr_dep.found()], 'OpenSlide load': [openslide_dep.found(), ' (dynamic module: ', openslide_module, ')'], 'Matlab load with libmatio': [matio_dep.found()], diff --git a/meson_options.txt b/meson_options.txt index 0fbe593df7..022bcb2952 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -193,6 +193,11 @@ option('resvg', value: 'auto', description: 'Build with resvg') +option('resvg-module', + type: 'feature', + value: 'auto', + description: 'Build resvg as module') + option('spng', type: 'feature', value: 'auto', From f00e7b1bae754fa2e4e412fb2c4ea71f22af47d5 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 18 Jan 2023 13:36:23 +0100 Subject: [PATCH 06/11] Simplify conditional directive --- libvips/foreign/svgload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 0248bf29b0..ae0fa3e6d1 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -936,7 +936,7 @@ vips_foreign_load_svg_file_is_a( const char *filename ) vips_foreign_load_svg_is_a( buf, bytes ) ); } -#ifndef HAVE_RSVG +#ifdef HAVE_RESVG static const char * resvg_error_msg( resvg_error e ) { switch( e ) { From f4115acb2daf413276623f92ea48d63369c624bd Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Thu, 19 Jan 2023 16:45:56 +0100 Subject: [PATCH 07/11] Set DPI before parsing the tree resvg uses a DPI of 96 by default, libvips defaults to 72. Call `resvg_options_set_dpi()` before parsing the tree with either `resvg_parse_tree_from_file()` or `resvg_parse_tree_from_data()` to ensure that `resvg_get_image_size()` returns the correct dimensions. --- libvips/foreign/svgload.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index ae0fa3e6d1..5e7278b001 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -536,12 +536,10 @@ vips_foreign_load_svg_get_scaled_size( VipsForeignLoadSvg *svg, double width; double height; +#ifdef HAVE_RSVG /* Get dimensions with the default dpi. */ -#ifdef HAVE_RSVG rsvg_handle_set_dpi( svg->page, 72.0 ); -#else - resvg_options_set_dpi( svg->options, 72.0 ); #endif if( vips_foreign_load_svg_get_natural_size( svg, &width, &height ) ) return( -1 ); @@ -806,6 +804,10 @@ vips_foreign_load_svg_init( VipsForeignLoadSvg *svg ) svg->cairo_scale = 1.0; #ifdef HAVE_RESVG svg->options = resvg_options_create(); + + /* Get dimensions with the default dpi. + */ + resvg_options_set_dpi( svg->options, 72.0 ); #endif } From d70f0389e8e8ce5ecd5bbebd98772ae1413e561c Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 23 Jan 2023 15:14:53 +0100 Subject: [PATCH 08/11] s/libresvg/resvg/g --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ff0d21d3e3..96bd5537cc 100644 --- a/meson.build +++ b/meson.build @@ -649,7 +649,7 @@ build_summary = { 'PDF load with PDFium': [pdfium_dep.found()], 'PDF load with poppler-glib': [libpoppler_found, ' (dynamic module: ', libpoppler_module, ')'], 'SVG load with librsvg': [librsvg_found], - 'SVG load with libresvg': [resvg_dep.found(), ' (dynamic module: ', resvg_module, ')'], + 'SVG load with resvg': [resvg_dep.found(), ' (dynamic module: ', resvg_module, ')'], 'EXR load with OpenEXR': [openexr_dep.found()], 'OpenSlide load': [openslide_dep.found(), ' (dynamic module: ', openslide_module, ')'], 'Matlab load with libmatio': [matio_dep.found()], From 385117c7352e8f371cb66bc85f020cd77ca00fb0 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 23 Jan 2023 16:17:53 +0100 Subject: [PATCH 09/11] Adapt to libvips style --- libvips/foreign/svgload.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 5e7278b001..76b15d4cd4 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -681,7 +681,7 @@ vips_foreign_load_svg_generate( VipsRegion *or, r->width ); #else - guint8 *pixmap = VIPS_REGION_ADDR( or, r->left, r->top ); + VipsPel *q = VIPS_REGION_ADDR( or, r->left, r->top ); resvg_render( svg->tree, @@ -694,24 +694,24 @@ vips_foreign_load_svg_generate( VipsRegion *or, }, r->width, r->height, - (char *) pixmap + (char *) q ); /* Just unpremultiply. */ for( int i = 0; i < r->width * r->height; i++ ) { - guint8 *ptr = &pixmap[i * 4]; - guint8 a = ptr[3]; + VipsPel * restrict p = &q[i * 4]; + VipsPel x = p[3]; /* Skip transparent and fully opaque pixels. */ - if( a == 0 || a == 255 ) + if( x == 0 || x == 255 ) continue; /* Any compiler will unroll it. */ for( int j = 0; j < 3; j++ ) - ptr[j] = 255 * ptr[j] / a; + p[j] = 255 * p[j] / x; } #endif From e15de4c0a658c5b649804bab66dfab29441e00ef Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 24 Jan 2023 09:45:38 +0100 Subject: [PATCH 10/11] Add missing `resvg_dep.found()` --- meson.build | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 96bd5537cc..8a5c783ec0 100644 --- a/meson.build +++ b/meson.build @@ -377,13 +377,15 @@ resvg_module = false if not librsvg_found # resvg doesn't ship pkg-config files, so we can't use dependency() resvg_dep = cc.find_library('resvg', has_headers: ['resvg.h'], required: get_option('resvg')) - resvg_module = modules_enabled and not get_option('resvg-module').disabled() - if resvg_module - cfg_var.set('RESVG_MODULE', '1') - else - libvips_deps += resvg_dep + if resvg_dep.found() + resvg_module = modules_enabled and not get_option('resvg-module').disabled() + if resvg_module + cfg_var.set('RESVG_MODULE', '1') + else + libvips_deps += resvg_dep + endif + cfg_var.set('HAVE_RESVG', '1') endif - cfg_var.set('HAVE_RESVG', '1') endif openslide_dep = dependency('openslide', version: '>=3.3.0', required: get_option('openslide')) From b5c4b252be32cad3aab5719aba280812774e5a4e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 24 Jan 2023 11:03:45 +0100 Subject: [PATCH 11/11] Update after cbc753c --- libvips/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvips/meson.build b/libvips/meson.build index 3e68e4d552..fb3c86d775 100644 --- a/libvips/meson.build +++ b/libvips/meson.build @@ -179,7 +179,7 @@ if resvg_module link_args: module_link_args, name_prefix: '', name_suffix: module_suffix, - dependencies: [gmodule_dep, libvips_dep, resvg_dep], + dependencies: [module_dep, resvg_dep], gnu_symbol_visibility: 'hidden', install: true, install_dir: module_dir