fix --without-tiff etc.
This commit is contained in:
parent
5789ca9421
commit
a2ed2edb5d
@ -13,7 +13,7 @@
|
||||
im_moreeq*(), im_remainder*(), im_and*(), im_or*(), im_eor*(), im_shift*(),
|
||||
im_pow*(), im_exp*(), im_ifthenelse(), im_blend(), im_c2amph(), im_c2rect(),
|
||||
im_bandmean(), im_c2real(), im_c2imag(), im_ri2c(), im_jpeg*2vips(),
|
||||
im_vips2jpeg*(), im_tiff2vips(), im_vips2tiff(),
|
||||
im_vips2jpeg*(), im_tiff2vips(), im_vips2tiff(), im_exr2vips()
|
||||
redone as classes
|
||||
- added argument priorites to help control arg ordering
|
||||
- generate has a 'stop' param to signal successful early termination
|
||||
|
20
TODO
20
TODO
@ -1,23 +1,3 @@
|
||||
- the way were handling the format/ compat thing is broken
|
||||
|
||||
if we build without-tiff, tiff compat will break
|
||||
|
||||
we need very loose coupling: tiff compat must just use the foreign
|
||||
interfaceo
|
||||
|
||||
we have vips__istiff() declared in foreign/tiff.h and internal.h
|
||||
|
||||
|
||||
im_tiff2vips.c needs this stuff:
|
||||
|
||||
->read()/->header() ... just use vips_tiffload()
|
||||
|
||||
->is_a() ...
|
||||
|
||||
->flags() ...
|
||||
|
||||
|
||||
|
||||
- "header fred.png" does not work, since header uses im_open() which uses
|
||||
VipsForeign
|
||||
|
||||
|
25
configure.in
25
configure.in
@ -438,6 +438,12 @@ if test x"$with_OpenEXR" != "xno"; then
|
||||
])
|
||||
fi
|
||||
|
||||
if test x"$with_OpenEXR" = x"yes"; then
|
||||
AM_CONDITIONAL(HAVE_OPENEXR, true)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_OPENEXR, false)
|
||||
fi
|
||||
|
||||
# OpenSlide
|
||||
AC_ARG_WITH([openslide],
|
||||
AS_HELP_STRING([--without-openslide], [build without OpenSlide (default: test)]))
|
||||
@ -452,6 +458,12 @@ if test x"$with_openslide" != "xno"; then
|
||||
])
|
||||
fi
|
||||
|
||||
if test x"$with_openslide" = x"yes"; then
|
||||
AM_CONDITIONAL(HAVE_OPENSLIDE, true)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_OPENSLIDE, false)
|
||||
fi
|
||||
|
||||
# matio
|
||||
AC_ARG_WITH([matio],
|
||||
AS_HELP_STRING([--without-matio], [build without matio (default: test)]))
|
||||
@ -501,6 +513,13 @@ FIND_TIFF(
|
||||
[AC_MSG_WARN([libtiff not found; disabling TIFF support])
|
||||
with_tiff=no
|
||||
])
|
||||
|
||||
if test x"$with_tiff" = x"yes"; then
|
||||
AM_CONDITIONAL(HAVE_TIFF, true)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_TIFF, false)
|
||||
fi
|
||||
|
||||
FIND_ZIP(
|
||||
[with_zip=yes],
|
||||
[AC_MSG_WARN([libz not found; disabling ZIP support])
|
||||
@ -512,6 +531,12 @@ FIND_JPEG(
|
||||
with_jpeg=no
|
||||
])
|
||||
|
||||
if test x"$with_jpeg" = x"yes"; then
|
||||
AM_CONDITIONAL(HAVE_JPEG, true)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_JPEG, false)
|
||||
fi
|
||||
|
||||
# look for PNG with pkg-config ... fall back to our tester
|
||||
AC_ARG_WITH([png],
|
||||
AS_HELP_STRING([--without-png], [build without libpng (default: test)]))
|
||||
|
@ -1,24 +1,67 @@
|
||||
noinst_LTLIBRARIES = libforeign.la
|
||||
|
||||
libforeign_la_SOURCES = \
|
||||
openexr2vips.h \
|
||||
openexr2vips.c \
|
||||
openexrload.c \
|
||||
openslide2vips.h \
|
||||
openslide2vips.c \
|
||||
openslideload.c \
|
||||
tiff.h \
|
||||
vips2tiff.c \
|
||||
tiff2vips.c \
|
||||
tiffload.c \
|
||||
tiffsave.c \
|
||||
vips2jpeg.c \
|
||||
jpeg2vips.c \
|
||||
jpeg.h \
|
||||
jpegload.c \
|
||||
jpegsave.c \
|
||||
vipssave.c \
|
||||
vipsload.c \
|
||||
foreign.c
|
||||
|
||||
EXTRA_DIST =
|
||||
|
||||
if HAVE_OPENEXR
|
||||
libforeign_la_SOURCES += \
|
||||
openexr2vips.h \
|
||||
openexr2vips.c \
|
||||
openexrload.c
|
||||
else
|
||||
EXTRA_DIST += \
|
||||
openexr2vips.h \
|
||||
openexr2vips.c \
|
||||
openexrload.c
|
||||
endif
|
||||
|
||||
if HAVE_TIFF
|
||||
libforeign_la_SOURCES += \
|
||||
tiff.h \
|
||||
vips2tiff.c \
|
||||
tiff2vips.c \
|
||||
tiffload.c \
|
||||
tiffsave.c
|
||||
else
|
||||
EXTRA_DIST += \
|
||||
tiff.h \
|
||||
vips2tiff.c \
|
||||
tiff2vips.c \
|
||||
tiffload.c \
|
||||
tiffsave.c
|
||||
endif
|
||||
|
||||
if HAVE_OPENSLIDE
|
||||
libforeign_la_SOURCES += \
|
||||
openslide2vips.h \
|
||||
openslide2vips.c \
|
||||
openslideload.c
|
||||
else
|
||||
EXTRA_DIST += \
|
||||
openslide2vips.h \
|
||||
openslide2vips.c \
|
||||
openslideload.c
|
||||
endif
|
||||
|
||||
if HAVE_JPEG
|
||||
libforeign_la_SOURCES += \
|
||||
vips2jpeg.c \
|
||||
jpeg2vips.c \
|
||||
jpeg.h \
|
||||
jpegload.c \
|
||||
jpegsave.c
|
||||
else
|
||||
EXTRA_DIST += \
|
||||
vips2jpeg.c \
|
||||
jpeg2vips.c \
|
||||
jpeg.h \
|
||||
jpegload.c \
|
||||
jpegsave.c
|
||||
endif
|
||||
|
||||
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||
|
||||
|
@ -352,6 +352,8 @@ vips_foreign_load_print_class( VipsObjectClass *object_class, VipsBuf *buf )
|
||||
vips_buf_appends( buf, ", is_a" );
|
||||
if( class->get_flags )
|
||||
vips_buf_appends( buf, ", get_flags" );
|
||||
if( class->get_flags_filename )
|
||||
vips_buf_appends( buf, ", get_flags_filename" );
|
||||
if( class->header )
|
||||
vips_buf_appends( buf, ", header" );
|
||||
if( class->load )
|
||||
@ -402,13 +404,65 @@ vips_foreign_find_load( const char *filename )
|
||||
(VipsSListMap2Fn) vips_foreign_load_new_from_foreign_sub,
|
||||
(void *) filename, NULL )) ) {
|
||||
vips_error( "VipsForeignLoad",
|
||||
_( "file \"%s\" not a known file" ), filename );
|
||||
_( "\"%s\" not a known file format" ), filename );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return( G_OBJECT_CLASS_NAME( load_class ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_foreign_is_a:
|
||||
* @loader: name of loader to use for test
|
||||
* @filename: file to test
|
||||
*
|
||||
* Return %TRUE if @filename can be loaded by @loader. @loader is something
|
||||
* like "tiffload" or "VipsForeignLoadTiff".
|
||||
*
|
||||
* Returns: %TRUE if @filename can be loaded by @loader.
|
||||
*/
|
||||
gboolean
|
||||
vips_foreign_is_a( const char *loader, const char *filename )
|
||||
{
|
||||
VipsObjectClass *class;
|
||||
VipsForeignLoadClass *load_class;
|
||||
|
||||
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 ) )
|
||||
return( TRUE );
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_foreign_flags:
|
||||
* @loader: name of loader to use for test
|
||||
* @filename: file to test
|
||||
*
|
||||
* Return the flags for @filename using @loader.
|
||||
* @loader is something like "tiffload" or "VipsForeignLoadTiff".
|
||||
*
|
||||
* Returns: the flags for @filename.
|
||||
*/
|
||||
VipsForeignFlags
|
||||
vips_foreign_flags( const char *loader, const char *filename )
|
||||
{
|
||||
VipsObjectClass *class;
|
||||
|
||||
if( (class = vips_class_find( "VipsForeignLoad", loader )) ) {
|
||||
VipsForeignLoadClass *load_class =
|
||||
VIPS_FOREIGN_LOAD_CLASS( class );
|
||||
|
||||
if( load_class->get_flags_filename )
|
||||
return( load_class->get_flags_filename( filename ) );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static VipsObject *
|
||||
vips_foreign_load_new_from_string( const char *string )
|
||||
{
|
||||
@ -1136,3 +1190,413 @@ vips_foreign_operation_init( void )
|
||||
vips_foreign_load_vips_get_type();
|
||||
vips_foreign_save_vips_get_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_tiffload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @page: load this page
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a TIFF file into a VIPS image. It is a full baseline TIFF 6 reader,
|
||||
* with extensions for tiled images, multipage images, LAB colour space,
|
||||
* pyramidal images and JPEG compression. including CMYK and YCbCr.
|
||||
*
|
||||
* @page means load this page from the file. By default the first page (page
|
||||
* 0) is read.
|
||||
*
|
||||
* Any ICC profile is read and attached to the VIPS image.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_tiffload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "tiffload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_tiffsave:
|
||||
* @in: image to save
|
||||
* @filename: file to write to
|
||||
* @compression; use this compression scheme
|
||||
* @Q: quality factor
|
||||
* @predictor; compress with this prediction
|
||||
* @profile: attach this ICC profile
|
||||
* @tile; set %TRUE to write a tiled tiff
|
||||
* @tile_width; set tile size
|
||||
* @tile_height; set tile size
|
||||
* @pyramid; set %TRUE to write an image pyramid
|
||||
* @squash; squash 8-bit images down to 1 bit
|
||||
* @resunit; use pixels per inch or cm for the resolution
|
||||
* @xres; horizontal resolution
|
||||
* @yres; vertical resolution
|
||||
* @bigtiff; write a BigTiff file
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Write a VIPS image to a file as TIFF.
|
||||
*
|
||||
* Use @compression to set the tiff compression. Currently jpeg, packbits,
|
||||
* fax4, lzw, none and deflate are supported. The default is no compression.
|
||||
* JPEG compression is a good lossy compressor for photographs, packbits is
|
||||
* good for 1-bit images, and deflate is the best lossless compression TIFF
|
||||
* can do. LZW has patent problems and is no longer recommended.
|
||||
*
|
||||
* Use @Q to set the JPEG compression factor. Default 75.
|
||||
*
|
||||
* Use @predictor to set the predictor for lzw and deflate compression.
|
||||
*
|
||||
* Predictor is not set by default. There are three predictor values recognised
|
||||
* at the moment (2007, July): 1 is no prediction, 2 is a horizontal
|
||||
* differencing and 3 is a floating point predictor. Refer to the libtiff
|
||||
* specifications for further discussion of various predictors. In short,
|
||||
* predictor helps to better compress image, especially in case of digital
|
||||
* photos or scanned images and bit depths > 8. Try it to find whether it
|
||||
* works for your images.
|
||||
*
|
||||
* Use @profile to give the filename of a profile to be embedded in the TIFF.
|
||||
* This does not affect the pixels which are written, just the way
|
||||
* they are tagged. You can use the special string "none" to mean
|
||||
* "don't attach a profile".
|
||||
*
|
||||
* If no profile is specified and the VIPS header
|
||||
* contains an ICC profile named VIPS_META_ICC_NAME ("icc-profile-data"), the
|
||||
* profile from the VIPS header will be attached.
|
||||
*
|
||||
* Set @tile to TRUE to write a tiled tiff. By default tiff are written in
|
||||
* strips. Use @tile_width and @tile_height to set the tile size. The defaiult
|
||||
* is 128 by 128.
|
||||
*
|
||||
* Set @pyramid to write the image as a set of images, one per page, of
|
||||
* decreasing size.
|
||||
*
|
||||
* Set @squash to make 8-bit uchar images write as 1-bit TIFFs with zero
|
||||
* pixels written as 0 and non-zero as 1.
|
||||
*
|
||||
* Use @resunit to override the default resolution unit.
|
||||
* The default
|
||||
* resolution unit is taken from the header field "resolution-unit"
|
||||
* (#VIPS_META_RESOLUTION_UNIT in C). If this field is not set, then
|
||||
* VIPS defaults to cm.
|
||||
*
|
||||
* Use @xres and @yres to override the default horizontal and vertical
|
||||
* resolutions. By default these values are taken from the VIPS image header.
|
||||
*
|
||||
* Set @bigtiff to attempt to write a bigtiff.
|
||||
* Bigtiff is a variant of the TIFF
|
||||
* format that allows more than 4GB in a file.
|
||||
*
|
||||
* See also: vips_tiffload(), vips_image_write_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_tiffsave( VipsImage *in, const char *filename, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, filename );
|
||||
result = vips_call_split( "tiffsave", ap, in, filename );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegload_buffer:
|
||||
* @buf: memory area to load
|
||||
* @len: size of memory area
|
||||
* @out: image to write
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a JPEG-formatted memory block into a VIPS image. It can read most
|
||||
* 8-bit JPEG images, including CMYK and YCbCr.
|
||||
*
|
||||
* This function is handy for processing JPEG image thumbnails.
|
||||
*
|
||||
* Caution: on return only the header will have been read, the pixel data is
|
||||
* not decompressed until the first pixel is read. Therefore you must not free
|
||||
* @buf until you have read pixel data from @out.
|
||||
*
|
||||
* See also: vips_jpegload().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsArea *area;
|
||||
int result;
|
||||
|
||||
/* We don't take a copy of the data or free it.
|
||||
*/
|
||||
area = vips_area_new_blob( NULL, buf, len );
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "jpegload_buffer", ap, area, out );
|
||||
va_end( ap );
|
||||
|
||||
vips_area_unref( area );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @flags: image flags
|
||||
* @shrink: shrink by this much on load
|
||||
* @fail: fail on warnings
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a JPEG file into a VIPS image. It can read most 8-bit JPEG images,
|
||||
* including CMYK and YCbCr.
|
||||
*
|
||||
* @shrink means shrink by this integer factor during load. Possible values
|
||||
* are 1, 2, 4 and 8. Shrinking during read is very much faster than
|
||||
* decompressing the whole image and then shrinking later.
|
||||
*
|
||||
* Setting @fail to true makes the JPEG reader fail on any warnings.
|
||||
* This can be useful for detecting truncated files, for example. Normally
|
||||
* reading these produces a warning, but no fatal error.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* |[
|
||||
* vips_jpegload( "fred.jpg", &out,
|
||||
* "shrink", 8,
|
||||
* "fail", TRUE,
|
||||
* NULL );
|
||||
* ]|
|
||||
*
|
||||
* Any embedded ICC profiles are ignored: you always just get the RGB from
|
||||
* the file. Instead, the embedded profile will be attached to the image as
|
||||
* metadata. You need to use something like im_icc_import() to get CIE
|
||||
* values from the file. Any EXIF data is also attached as VIPS metadata.
|
||||
*
|
||||
* The int metadata item "jpeg-multiscan" is set to the result of
|
||||
* jpeg_has_multiple_scans(). Interlaced jpeg images need a large amount of
|
||||
* memory to load, so this field gives callers a chance to handle these
|
||||
* images differently.
|
||||
*
|
||||
* The EXIF thumbnail, if present, is attached to the image as
|
||||
* "jpeg-thumbnail-data". See vips_image_get_blob().
|
||||
*
|
||||
* This function only reads the image header and does not decompress any pixel
|
||||
* data. Decompression only occurs when pixels are accessed by some other
|
||||
* function.
|
||||
*
|
||||
* See also: vips_jpegload_buffer(), vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "jpegload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegsave_mime:
|
||||
* @in: image to save
|
||||
* @Q: JPEG quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* As vips_jpegsave(), but save as a mime jpeg on stdout.
|
||||
*
|
||||
* See also: vips_jpegsave(), vips_image_write_to_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave_mime( VipsImage *in, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, in );
|
||||
result = vips_call_split( "jpegsave_mime", ap, in );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegsave_buffer:
|
||||
* @in: image to save
|
||||
* @buf: return output buffer here
|
||||
* @len: return output length here
|
||||
* @Q: JPEG quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* As vips_jpegsave(), 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
|
||||
* are done with it.
|
||||
*
|
||||
* See also: vips_jpegsave(), vips_image_write_to_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsArea *area;
|
||||
int result;
|
||||
|
||||
va_start( ap, len );
|
||||
result = vips_call_split( "jpegsave_buffer", ap, in, &area );
|
||||
va_end( ap );
|
||||
|
||||
if( buf ) {
|
||||
*buf = area->data;
|
||||
area->free_fn = NULL;
|
||||
}
|
||||
if( buf )
|
||||
*len = area->length;
|
||||
|
||||
vips_area_unref( area );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegsave:
|
||||
* @in: image to save
|
||||
* @filename: file to write to
|
||||
* @Q: quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Write a VIPS image to a file as JPEG.
|
||||
*
|
||||
* Use @Q to set the JPEG compression factor. Default 75.
|
||||
*
|
||||
* Use @profile to give the filename of a profile to be em,bedded in the JPEG.
|
||||
* This does not affect the pixels which are written, just the way
|
||||
* they are tagged. You can use the special string "none" to mean
|
||||
* "don't attach a profile".
|
||||
*
|
||||
* If no profile is specified and the VIPS header
|
||||
* contains an ICC profile named VIPS_META_ICC_NAME ("icc-profile-data"), the
|
||||
* profile from the VIPS header will be attached.
|
||||
*
|
||||
* The image is automatically converted to RGB, Monochrome or CMYK before
|
||||
* saving. Any metadata attached to the image is saved as EXIF, if possible.
|
||||
*
|
||||
* See also: vips_jpegsave_buffer(), vips_image_write_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave( VipsImage *in, const char *filename, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, filename );
|
||||
result = vips_call_split( "jpegsave", ap, in, filename );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_openexrload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a OpenEXR file into a VIPS image.
|
||||
*
|
||||
* The reader can handle scanline and tiled OpenEXR images. It can't handle
|
||||
* OpenEXR colour management, image attributes, many pixel formats, anything
|
||||
* other than RGBA.
|
||||
*
|
||||
* This reader uses the rather limited OpenEXR C API. It should really be
|
||||
* redone in C++.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_openexrload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "openexrload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_openslideload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @layer: load this layer
|
||||
* @associated: load this associated image
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a virtual slide supported by the OpenSlide library into a VIPS image.
|
||||
* OpenSlide supports images in Aperio, Hamamatsu VMS, Hamamatsu VMU, MIRAX,
|
||||
* and Trestle formats.
|
||||
*
|
||||
* To facilitate zooming, virtual slide formats include multiple scaled-down
|
||||
* versions of the high-resolution image. These are typically called
|
||||
* "levels", though OpenSlide and im_openslide2vips() call them "layers".
|
||||
* By default, vips_openslideload() reads the highest-resolution layer
|
||||
* (layer 0). Set @layer to the layer number you want.
|
||||
*
|
||||
* In addition to the slide image itself, virtual slide formats sometimes
|
||||
* include additional images, such as a scan of the slide's barcode.
|
||||
* OpenSlide calls these "associated images". To read an associated image,
|
||||
* set @associated to the image's name.
|
||||
* A slide's associated images are listed in the
|
||||
* "slide-associated-images" metadata item.
|
||||
*
|
||||
* The output of this operator is in pre-multipled ARGB format. Use
|
||||
* im_argb2rgba() to decode to png-style RGBA.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_openslideload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "openslideload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -231,69 +231,6 @@ vips_foreign_load_jpeg_file_init( VipsForeignLoadJpegFile *file )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @flags: image flags
|
||||
* @shrink: shrink by this much on load
|
||||
* @fail: fail on warnings
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a JPEG file into a VIPS image. It can read most 8-bit JPEG images,
|
||||
* including CMYK and YCbCr.
|
||||
*
|
||||
* @shrink means shrink by this integer factor during load. Possible values
|
||||
* are 1, 2, 4 and 8. Shrinking during read is very much faster than
|
||||
* decompressing the whole image and then shrinking later.
|
||||
*
|
||||
* Setting @fail to true makes the JPEG reader fail on any warnings.
|
||||
* This can be useful for detecting truncated files, for example. Normally
|
||||
* reading these produces a warning, but no fatal error.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* |[
|
||||
* vips_jpegload( "fred.jpg", &out,
|
||||
* "shrink", 8,
|
||||
* "fail", TRUE,
|
||||
* NULL );
|
||||
* ]|
|
||||
*
|
||||
* Any embedded ICC profiles are ignored: you always just get the RGB from
|
||||
* the file. Instead, the embedded profile will be attached to the image as
|
||||
* metadata. You need to use something like im_icc_import() to get CIE
|
||||
* values from the file. Any EXIF data is also attached as VIPS metadata.
|
||||
*
|
||||
* The int metadata item "jpeg-multiscan" is set to the result of
|
||||
* jpeg_has_multiple_scans(). Interlaced jpeg images need a large amount of
|
||||
* memory to load, so this field gives callers a chance to handle these
|
||||
* images differently.
|
||||
*
|
||||
* The EXIF thumbnail, if present, is attached to the image as
|
||||
* "jpeg-thumbnail-data". See vips_image_get_blob().
|
||||
*
|
||||
* This function only reads the image header and does not decompress any pixel
|
||||
* data. Decompression only occurs when pixels are accessed by some other
|
||||
* function.
|
||||
*
|
||||
* See also: vips_jpegload_buffer(), vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "jpegload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
typedef struct _VipsForeignLoadJpegBuffer {
|
||||
VipsForeignLoadJpeg parent_object;
|
||||
|
||||
@ -364,43 +301,3 @@ vips_foreign_load_jpeg_buffer_init( VipsForeignLoadJpegBuffer *buffer )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vips_jpegload_buffer:
|
||||
* @buf: memory area to load
|
||||
* @len: size of memory area
|
||||
* @out: image to write
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a JPEG-formatted memory block into a VIPS image. It can read most
|
||||
* 8-bit JPEG images, including CMYK and YCbCr.
|
||||
*
|
||||
* This function is handy for processing JPEG image thumbnails.
|
||||
*
|
||||
* Caution: on return only the header will have been read, the pixel data is
|
||||
* not decompressed until the first pixel is read. Therefore you must not free
|
||||
* @buf until you have read pixel data from @out.
|
||||
*
|
||||
* See also: vips_jpegload().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsArea *area;
|
||||
int result;
|
||||
|
||||
/* We don't take a copy of the data or free it.
|
||||
*/
|
||||
area = vips_area_new_blob( NULL, buf, len );
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "jpegload_buffer", ap, area, out );
|
||||
va_end( ap );
|
||||
|
||||
vips_area_unref( area );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -200,48 +200,6 @@ vips_foreign_save_jpeg_file_init( VipsForeignSaveJpegFile *file )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vips_jpegsave:
|
||||
* @in: image to save
|
||||
* @filename: file to write to
|
||||
* @Q: quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Write a VIPS image to a file as JPEG.
|
||||
*
|
||||
* Use @Q to set the JPEG compression factor. Default 75.
|
||||
*
|
||||
* Use @profile to give the filename of a profile to be em,bedded in the JPEG.
|
||||
* This does not affect the pixels which are written, just the way
|
||||
* they are tagged. You can use the special string "none" to mean
|
||||
* "don't attach a profile".
|
||||
*
|
||||
* If no profile is specified and the VIPS header
|
||||
* contains an ICC profile named VIPS_META_ICC_NAME ("icc-profile-data"), the
|
||||
* profile from the VIPS header will be attached.
|
||||
*
|
||||
* The image is automatically converted to RGB, Monochrome or CMYK before
|
||||
* saving. Any metadata attached to the image is saved as EXIF, if possible.
|
||||
*
|
||||
* See also: vips_jpegsave_buffer(), vips_image_write_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave( VipsImage *in, const char *filename, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, filename );
|
||||
result = vips_call_split( "jpegsave", ap, in, filename );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
typedef struct _VipsForeignSaveJpegBuffer {
|
||||
VipsForeignSaveJpeg parent_object;
|
||||
|
||||
@ -309,49 +267,6 @@ vips_foreign_save_jpeg_buffer_init( VipsForeignSaveJpegBuffer *file )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vips_jpegsave_buffer:
|
||||
* @in: image to save
|
||||
* @buf: return output buffer here
|
||||
* @len: return output length here
|
||||
* @Q: JPEG quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* As vips_jpegsave(), 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
|
||||
* are done with it.
|
||||
*
|
||||
* See also: vips_jpegsave(), vips_image_write_to_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsArea *area;
|
||||
int result;
|
||||
|
||||
va_start( ap, len );
|
||||
result = vips_call_split( "jpegsave_buffer", ap, in, &area );
|
||||
va_end( ap );
|
||||
|
||||
if( buf ) {
|
||||
*buf = area->data;
|
||||
area->free_fn = NULL;
|
||||
}
|
||||
if( buf )
|
||||
*len = area->length;
|
||||
|
||||
vips_area_unref( area );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
typedef struct _VipsForeignSaveJpegMime {
|
||||
VipsForeignSaveJpeg parent_object;
|
||||
|
||||
@ -408,29 +323,3 @@ static void
|
||||
vips_foreign_save_jpeg_mime_init( VipsForeignSaveJpegMime *mime )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_jpegsave_mime:
|
||||
* @in: image to save
|
||||
* @Q: JPEG quality factor
|
||||
* @profile: attach this ICC profile
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* As vips_jpegsave(), but save as a mime jpeg on stdout.
|
||||
*
|
||||
* See also: vips_jpegsave(), vips_image_write_to_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_jpegsave_mime( VipsImage *in, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, in );
|
||||
result = vips_call_split( "jpegsave_mime", ap, in );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -64,18 +64,26 @@ G_DEFINE_TYPE( VipsForeignLoadOpenexr, vips_foreign_load_openexr,
|
||||
VIPS_TYPE_FOREIGN_LOAD );
|
||||
|
||||
static VipsForeignFlags
|
||||
vips_foreign_load_openexr_get_flags( VipsForeignLoad *load )
|
||||
vips_foreign_load_openexr_get_flags_filename( const char *filename )
|
||||
{
|
||||
VipsForeignLoadOpenexr *openexr = (VipsForeignLoadOpenexr *) load;
|
||||
VipsForeignFlags flags;
|
||||
|
||||
flags = 0;
|
||||
if( vips__openexr_istiled( openexr->filename ) )
|
||||
if( vips__openexr_istiled( filename ) )
|
||||
flags |= VIPS_FOREIGN_PARTIAL;
|
||||
|
||||
return( flags );
|
||||
}
|
||||
|
||||
static VipsForeignFlags
|
||||
vips_foreign_load_openexr_get_flags( VipsForeignLoad *load )
|
||||
{
|
||||
VipsForeignLoadOpenexr *openexr = (VipsForeignLoadOpenexr *) load;
|
||||
|
||||
return( vips_foreign_load_openexr_get_flags_filename(
|
||||
openexr->filename ) );
|
||||
}
|
||||
|
||||
static int
|
||||
vips_foreign_load_openexr_header( VipsForeignLoad *load )
|
||||
{
|
||||
@ -117,6 +125,8 @@ vips_foreign_load_openexr_class_init( VipsForeignLoadOpenexrClass *class )
|
||||
foreign_class->suffs = vips_foreign_openexr_suffs;
|
||||
|
||||
load_class->is_a = vips__openexr_isexr;
|
||||
load_class->get_flags_filename =
|
||||
vips_foreign_load_openexr_get_flags_filename;
|
||||
load_class->get_flags = vips_foreign_load_openexr_get_flags;
|
||||
load_class->header = vips_foreign_load_openexr_header;
|
||||
load_class->load = vips_foreign_load_openexr_load;
|
||||
@ -133,35 +143,3 @@ static void
|
||||
vips_foreign_load_openexr_init( VipsForeignLoadOpenexr *openexr )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_openexrload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a OpenEXR file into a VIPS image.
|
||||
*
|
||||
* The reader can handle scanline and tiled OpenEXR images. It can't handle
|
||||
* OpenEXR colour management, image attributes, many pixel formats, anything
|
||||
* other than RGBA.
|
||||
*
|
||||
* This reader uses the rather limited OpenEXR C API. It should really be
|
||||
* redone in C++.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_openexrload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "openexrload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -190,48 +190,3 @@ static void
|
||||
vips_foreign_load_openslide_init( VipsForeignLoadOpenslide *openslide )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_openslideload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @layer: load this layer
|
||||
* @associated: load this associated image
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a virtual slide supported by the OpenSlide library into a VIPS image.
|
||||
* OpenSlide supports images in Aperio, Hamamatsu VMS, Hamamatsu VMU, MIRAX,
|
||||
* and Trestle formats.
|
||||
*
|
||||
* To facilitate zooming, virtual slide formats include multiple scaled-down
|
||||
* versions of the high-resolution image. These are typically called
|
||||
* "levels", though OpenSlide and im_openslide2vips() call them "layers".
|
||||
* By default, vips_openslideload() reads the highest-resolution layer
|
||||
* (layer 0). Set @layer to the layer number you want.
|
||||
*
|
||||
* In addition to the slide image itself, virtual slide formats sometimes
|
||||
* include additional images, such as a scan of the slide's barcode.
|
||||
* OpenSlide calls these "associated images". To read an associated image,
|
||||
* set @associated to the image's name.
|
||||
* A slide's associated images are listed in the
|
||||
* "slide-associated-images" metadata item.
|
||||
*
|
||||
* The output of this operator is in pre-multipled ARGB format. Use
|
||||
* im_argb2rgba() to decode to png-style RGBA.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_openslideload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "openslideload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ int vips__tiff_write( VipsImage *in, const char *filename,
|
||||
int vips__tiff_read( const char *filename, VipsImage *out, int page );
|
||||
int vips__tiff_read_header( const char *filename, VipsImage *out, int page );
|
||||
gboolean vips__istifftiled( const char *filename );
|
||||
gboolean vips__istiff( const char *filename );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -67,19 +67,24 @@ typedef VipsForeignLoadClass VipsForeignLoadTiffClass;
|
||||
G_DEFINE_TYPE( VipsForeignLoadTiff, vips_foreign_load_tiff,
|
||||
VIPS_TYPE_FOREIGN_LOAD );
|
||||
|
||||
/* TIFF flags function.
|
||||
*/
|
||||
static VipsForeignFlags
|
||||
vips_foreign_load_tiff_get_flags_filename( const char *filename )
|
||||
{
|
||||
VipsForeignFlags flags;
|
||||
|
||||
flags = 0;
|
||||
if( vips__istifftiled( filename ) )
|
||||
flags |= VIPS_FOREIGN_PARTIAL;
|
||||
|
||||
return( flags );
|
||||
}
|
||||
|
||||
static VipsForeignFlags
|
||||
vips_foreign_load_tiff_get_flags( VipsForeignLoad *load )
|
||||
{
|
||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||
VipsForeignFlags flags;
|
||||
|
||||
flags = 0;
|
||||
if( vips__istifftiled( tiff->filename ) )
|
||||
flags |= VIPS_FOREIGN_PARTIAL;
|
||||
|
||||
return( flags );
|
||||
return( vips_foreign_load_tiff_get_flags_filename( tiff->filename ) );
|
||||
}
|
||||
|
||||
static int
|
||||
@ -123,6 +128,8 @@ vips_foreign_load_tiff_class_init( VipsForeignLoadTiffClass *class )
|
||||
foreign_class->suffs = vips__foreign_tiff_suffs;
|
||||
|
||||
load_class->is_a = vips__istiff;
|
||||
load_class->get_flags_filename =
|
||||
vips_foreign_load_tiff_get_flags_filename;
|
||||
load_class->get_flags = vips_foreign_load_tiff_get_flags;
|
||||
load_class->header = vips_foreign_load_tiff_header;
|
||||
load_class->load = vips_foreign_load_tiff_load;
|
||||
@ -146,36 +153,3 @@ static void
|
||||
vips_foreign_load_tiff_init( VipsForeignLoadTiff *tiff )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_tiffload:
|
||||
* @filename: file to load
|
||||
* @out: decompressed image
|
||||
* @page: load this page
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Read a TIFF file into a VIPS image. It is a full baseline TIFF 6 reader,
|
||||
* with extensions for tiled images, multipage images, LAB colour space,
|
||||
* pyramidal images and JPEG compression. including CMYK and YCbCr.
|
||||
*
|
||||
* @page means load this page from the file. By default the first page (page
|
||||
* 0) is read.
|
||||
*
|
||||
* Any ICC profile is read and attached to the VIPS image.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_tiffload( const char *filename, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "tiffload", ap, filename, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -276,91 +276,3 @@ vips_foreign_save_tiff_init( VipsForeignSaveTiff *tiff )
|
||||
tiff->xres = 1.0;
|
||||
tiff->yres = 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_tiffsave:
|
||||
* @in: image to save
|
||||
* @filename: file to write to
|
||||
* @compression; use this compression scheme
|
||||
* @Q: quality factor
|
||||
* @predictor; compress with this prediction
|
||||
* @profile: attach this ICC profile
|
||||
* @tile; set %TRUE to write a tiled tiff
|
||||
* @tile_width; set tile size
|
||||
* @tile_height; set tile size
|
||||
* @pyramid; set %TRUE to write an image pyramid
|
||||
* @squash; squash 8-bit images down to 1 bit
|
||||
* @resunit; use pixels per inch or cm for the resolution
|
||||
* @xres; horizontal resolution
|
||||
* @yres; vertical resolution
|
||||
* @bigtiff; write a BigTiff file
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Write a VIPS image to a file as TIFF.
|
||||
*
|
||||
* Use @compression to set the tiff compression. Currently jpeg, packbits,
|
||||
* fax4, lzw, none and deflate are supported. The default is no compression.
|
||||
* JPEG compression is a good lossy compressor for photographs, packbits is
|
||||
* good for 1-bit images, and deflate is the best lossless compression TIFF
|
||||
* can do. LZW has patent problems and is no longer recommended.
|
||||
*
|
||||
* Use @Q to set the JPEG compression factor. Default 75.
|
||||
*
|
||||
* Use @predictor to set the predictor for lzw and deflate compression.
|
||||
*
|
||||
* Predictor is not set by default. There are three predictor values recognised
|
||||
* at the moment (2007, July): 1 is no prediction, 2 is a horizontal
|
||||
* differencing and 3 is a floating point predictor. Refer to the libtiff
|
||||
* specifications for further discussion of various predictors. In short,
|
||||
* predictor helps to better compress image, especially in case of digital
|
||||
* photos or scanned images and bit depths > 8. Try it to find whether it
|
||||
* works for your images.
|
||||
*
|
||||
* Use @profile to give the filename of a profile to be embedded in the TIFF.
|
||||
* This does not affect the pixels which are written, just the way
|
||||
* they are tagged. You can use the special string "none" to mean
|
||||
* "don't attach a profile".
|
||||
*
|
||||
* If no profile is specified and the VIPS header
|
||||
* contains an ICC profile named VIPS_META_ICC_NAME ("icc-profile-data"), the
|
||||
* profile from the VIPS header will be attached.
|
||||
*
|
||||
* Set @tile to TRUE to write a tiled tiff. By default tiff are written in
|
||||
* strips. Use @tile_width and @tile_height to set the tile size. The defaiult
|
||||
* is 128 by 128.
|
||||
*
|
||||
* Set @pyramid to write the image as a set of images, one per page, of
|
||||
* decreasing size.
|
||||
*
|
||||
* Set @squash to make 8-bit uchar images write as 1-bit TIFFs with zero
|
||||
* pixels written as 0 and non-zero as 1.
|
||||
*
|
||||
* Use @resunit to override the default resolution unit.
|
||||
* The default
|
||||
* resolution unit is taken from the header field "resolution-unit"
|
||||
* (#VIPS_META_RESOLUTION_UNIT in C). If this field is not set, then
|
||||
* VIPS defaults to cm.
|
||||
*
|
||||
* Use @xres and @yres to override the default horizontal and vertical
|
||||
* resolutions. By default these values are taken from the VIPS image header.
|
||||
*
|
||||
* Set @bigtiff to attempt to write a bigtiff.
|
||||
* Bigtiff is a variant of the TIFF
|
||||
* format that allows more than 4GB in a file.
|
||||
*
|
||||
* See also: vips_tiffload(), vips_image_write_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
vips_tiffsave( VipsImage *in, const char *filename, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, filename );
|
||||
result = vips_call_split( "tiffsave", ap, in, filename );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -62,20 +62,6 @@
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#ifndef HAVE_OPENEXR
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
im_exr2vips( const char *name, IMAGE *out )
|
||||
{
|
||||
im_error( "im_exr2vips", "%s",
|
||||
_( "OpenEXR support disabled" ) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#else /*HAVE_OPENEXR*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@ -85,8 +71,6 @@ im_exr2vips( const char *name, IMAGE *out )
|
||||
#include <vips/thread.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
#include "../foreign/openexr2vips.h"
|
||||
|
||||
int
|
||||
im_exr2vips( const char *filename, IMAGE *out )
|
||||
{
|
||||
@ -106,15 +90,25 @@ im_exr2vips( const char *filename, IMAGE *out )
|
||||
static const char *exr_suffs[] = { ".exr", NULL };
|
||||
|
||||
static VipsFormatFlags
|
||||
exr_flags( const char *filename )
|
||||
exr_flags( const char *name )
|
||||
{
|
||||
VipsFormatFlags flags;
|
||||
char filename[FILENAME_MAX];
|
||||
char mode[FILENAME_MAX];
|
||||
|
||||
flags = 0;
|
||||
if( vips__openexr_istiled( filename ) )
|
||||
flags |= VIPS_FORMAT_PARTIAL;
|
||||
im_filename_split( name, filename, mode );
|
||||
|
||||
return( flags );
|
||||
return( vips_foreign_flags( "openexrload", filename ) );
|
||||
}
|
||||
|
||||
static int
|
||||
isexr( const char *name )
|
||||
{
|
||||
char filename[FILENAME_MAX];
|
||||
char mode[FILENAME_MAX];
|
||||
|
||||
im_filename_split( name, filename, mode );
|
||||
|
||||
return( vips_foreign_is_a( "openexrload", filename ) );
|
||||
}
|
||||
|
||||
/* exr format adds no new members.
|
||||
@ -131,7 +125,7 @@ vips_format_exr_class_init( VipsFormatExrClass *class )
|
||||
object_class->nickname = "exr";
|
||||
object_class->description = _( "OpenEXR" );
|
||||
|
||||
format_class->is_a = vips__openexr_isexr;
|
||||
format_class->is_a = isexr;
|
||||
format_class->header = im_exr2vips;
|
||||
format_class->load = im_exr2vips;
|
||||
format_class->get_flags = exr_flags;
|
||||
@ -145,4 +139,3 @@ vips_format_exr_init( VipsFormatExr *object )
|
||||
|
||||
G_DEFINE_TYPE( VipsFormatExr, vips_format_exr, VIPS_TYPE_FORMAT );
|
||||
|
||||
#endif /*HAVE_OPENEXR*/
|
||||
|
@ -154,15 +154,14 @@ im_bufjpeg2vips( void *buf, size_t len, IMAGE *out, gboolean header_only )
|
||||
}
|
||||
|
||||
static int
|
||||
isjpeg( const char *filename )
|
||||
isjpeg( const char *name )
|
||||
{
|
||||
unsigned char buf[2];
|
||||
char filename[FILENAME_MAX];
|
||||
char mode[FILENAME_MAX];
|
||||
|
||||
if( im__get_bytes( filename, buf, 2 ) )
|
||||
if( (int) buf[0] == 0xff && (int) buf[1] == 0xd8 )
|
||||
return( 1 );
|
||||
im_filename_split( name, filename, mode );
|
||||
|
||||
return( 0 );
|
||||
return( vips_foreign_is_a( "jpegload", filename ) );
|
||||
}
|
||||
|
||||
static const char *jpeg_suffs[] = { ".jpg", ".jpeg", ".jpe", NULL };
|
||||
|
@ -83,15 +83,21 @@ tiff_flags( const char *name )
|
||||
{
|
||||
char filename[FILENAME_MAX];
|
||||
char mode[FILENAME_MAX];
|
||||
VipsFormatFlags flags;
|
||||
|
||||
im_filename_split( name, filename, mode );
|
||||
|
||||
flags = 0;
|
||||
if( vips__istifftiled( filename ) )
|
||||
flags |= VIPS_FORMAT_PARTIAL;
|
||||
return( vips_foreign_flags( "tiffload", filename ) );
|
||||
}
|
||||
|
||||
return( flags );
|
||||
static int
|
||||
istiff( const char *name )
|
||||
{
|
||||
char filename[FILENAME_MAX];
|
||||
char mode[FILENAME_MAX];
|
||||
|
||||
im_filename_split( name, filename, mode );
|
||||
|
||||
return( vips_foreign_is_a( "tiffload", filename ) );
|
||||
}
|
||||
|
||||
static const char *tiff_suffs[] = { ".tif", ".tiff", NULL };
|
||||
@ -108,7 +114,7 @@ vips_format_tiff_class_init( VipsFormatTiffClass *class )
|
||||
object_class->nickname = "tiff";
|
||||
object_class->description = _( "TIFF" );
|
||||
|
||||
format_class->is_a = vips__istiff;
|
||||
format_class->is_a = istiff;
|
||||
format_class->header = im_tiff2vips;
|
||||
format_class->load = NULL;
|
||||
format_class->save = im_vips2tiff;
|
||||
|
@ -139,10 +139,15 @@ typedef struct _VipsForeignLoadClass {
|
||||
*/
|
||||
gboolean (*is_a)( const char * );
|
||||
|
||||
/* Get the flags for this file.
|
||||
/* Get the flags for this image.
|
||||
*/
|
||||
VipsForeignFlags (*get_flags)( VipsForeignLoad * );
|
||||
|
||||
/* Get the flags from a filename. This is needed for vips7compat but
|
||||
* newer loaders don't have to define it.
|
||||
*/
|
||||
VipsForeignFlags (*get_flags_filename)( const char * );
|
||||
|
||||
/* Set the header fields in @out from @filename. If you can read the
|
||||
* whole image as well with no performance cost (as with vipsload),
|
||||
* leave ->load() NULL and only @header will be used.
|
||||
@ -162,6 +167,9 @@ GType vips_foreign_load_get_type( void );
|
||||
|
||||
const char *vips_foreign_find_load( const char *foreignname );
|
||||
|
||||
VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename );
|
||||
gboolean vips_foreign_is_a( const char *loader, const char *filename );
|
||||
|
||||
#define VIPS_TYPE_FOREIGN_SAVE (vips_foreign_save_get_type())
|
||||
#define VIPS_FOREIGN_SAVE( obj ) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST( (obj), \
|
||||
|
@ -299,9 +299,6 @@ guint64 vips__parse_size( const char *size_string );
|
||||
IMAGE *vips__deprecated_open_read( const char *filename );
|
||||
IMAGE *vips__deprecated_open_write( const char *filename );
|
||||
|
||||
gboolean vips__istiff( const char *filename );
|
||||
gboolean vips__istifftiled( const char *filename );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
@ -1082,8 +1082,11 @@ vips_object_real_new_from_string( const char *string )
|
||||
|
||||
/* The main arg selects the subclass.
|
||||
*/
|
||||
if( !(type = vips_type_find( NULL, string )) )
|
||||
if( !(type = vips_type_find( NULL, string )) ) {
|
||||
vips_error( "VipsObject",
|
||||
_( "class \"%s\" not found" ), string );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return( VIPS_OBJECT( g_object_new( type, NULL ) ) );
|
||||
}
|
||||
@ -1830,6 +1833,8 @@ test_name( VipsObjectClass *class, const char *nickname )
|
||||
|
||||
/* Find a class ... search below base, return the first match on a nickname or
|
||||
* a name. If basename is NULL, search all of VipsObject.
|
||||
*
|
||||
* If not found, return NULL without setting an error message.
|
||||
*/
|
||||
VipsObjectClass *
|
||||
vips_class_find( const char *basename, const char *nickname )
|
||||
@ -1839,18 +1844,10 @@ vips_class_find( const char *basename, const char *nickname )
|
||||
VipsObjectClass *class;
|
||||
GType base;
|
||||
|
||||
if( !(base = g_type_from_name( classname )) ) {
|
||||
vips_error( "VipsObject",
|
||||
_( "base class \"%s\" not found" ), classname );
|
||||
if( !(base = g_type_from_name( classname )) ||
|
||||
!(class = vips_class_map_all( base,
|
||||
(VipsClassMapFn) test_name, (void *) nickname )) )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if( !(class = vips_class_map_all( base,
|
||||
(VipsClassMapFn) test_name, (void *) nickname )) ) {
|
||||
vips_error( "VipsObject",
|
||||
_( "class \"%s\" not found" ), nickname );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return( class );
|
||||
}
|
||||
|
@ -232,8 +232,11 @@ vips_operation_new( const char *name )
|
||||
|
||||
vips_check_init();
|
||||
|
||||
if( !(type = vips_type_find( "VipsOperation", name )) )
|
||||
if( !(type = vips_type_find( "VipsOperation", name )) ) {
|
||||
vips_error( "VipsOperation",
|
||||
_( "class \"%s\" not found" ), name );
|
||||
return( NULL );
|
||||
}
|
||||
operation = VIPS_OPERATION( g_object_new( type, NULL ) );
|
||||
|
||||
VIPS_DEBUG_MSG( "vips_operation_new: %s (%p)\n", name, operation );
|
||||
|
@ -610,8 +610,11 @@ vips_interpolate_new( const char *nickname )
|
||||
{
|
||||
GType type;
|
||||
|
||||
if( !(type = vips_type_find( "VipsInterpolate", nickname )) )
|
||||
if( !(type = vips_type_find( "VipsInterpolate", nickname )) ) {
|
||||
vips_error( "VipsInterpolate",
|
||||
_( "class \"%s\" not found" ), nickname );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return( VIPS_INTERPOLATE( vips_object_new( type, NULL, NULL, NULL ) ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user