turn format/*jpeg* into stubs
the old im_vips2jpeg.c and im_jpeg2vips.c are now just stubs calling the new foreign/ things
This commit is contained in:
parent
f6ac8570dc
commit
4fd37502bc
9
TODO
9
TODO
@ -10,6 +10,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- "header" with more than one arg should put the filename before each printed
|
||||||
|
line so eg.
|
||||||
|
|
||||||
|
$ header *.jpg | grep -i prof
|
||||||
|
|
||||||
|
works
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- make compat wrappers for old im_jpeg2vips() and im_vips2jpeg()
|
- make compat wrappers for old im_jpeg2vips() and im_vips2jpeg()
|
||||||
|
|
||||||
make sure we are using the operation cache for jpegload
|
make sure we are using the operation cache for jpegload
|
||||||
|
@ -217,13 +217,18 @@ vips_image_open_lazy( VipsImage *image,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
vips_demand_hint( image, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
vips_demand_hint( image, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
||||||
|
|
||||||
/* Then 'start' creates the real image and 'gen' paints 'out' with
|
/* If there's no load function, assume header has done everything
|
||||||
* pixels from the real image on demand.
|
* already.
|
||||||
*/
|
*/
|
||||||
if( vips_image_generate( image,
|
if( format->load ) {
|
||||||
open_lazy_start, open_lazy_generate, vips_stop_one,
|
/* Then 'start' creates the real image and 'gen' paints 'image'
|
||||||
lazy, NULL ) )
|
* with pixels from the real image on demand.
|
||||||
return( -1 );
|
*/
|
||||||
|
if( vips_image_generate( image,
|
||||||
|
open_lazy_start, open_lazy_generate, vips_stop_one,
|
||||||
|
lazy, NULL ) )
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -235,6 +235,68 @@ 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
|
||||||
|
*
|
||||||
|
* 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 {
|
typedef struct _VipsForeignLoadJpegBuffer {
|
||||||
VipsForeignLoadJpeg parent_object;
|
VipsForeignLoadJpeg parent_object;
|
||||||
|
|
||||||
@ -304,3 +366,43 @@ static void
|
|||||||
vips_foreign_load_jpeg_buffer_init( VipsForeignLoadJpegBuffer *buffer )
|
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
|
||||||
|
*
|
||||||
|
* 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,6 +200,47 @@ 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
|
||||||
|
*
|
||||||
|
* 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 {
|
typedef struct _VipsForeignSaveJpegBuffer {
|
||||||
VipsForeignSaveJpeg parent_object;
|
VipsForeignSaveJpeg parent_object;
|
||||||
|
|
||||||
@ -267,6 +308,48 @@ 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
|
||||||
|
*
|
||||||
|
* 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 {
|
typedef struct _VipsForeignSaveJpegMime {
|
||||||
VipsForeignSaveJpeg parent_object;
|
VipsForeignSaveJpeg parent_object;
|
||||||
|
|
||||||
@ -323,3 +406,28 @@ static void
|
|||||||
vips_foreign_save_jpeg_mime_init( VipsForeignSaveJpegMime *mime )
|
vips_foreign_save_jpeg_mime_init( VipsForeignSaveJpegMime *mime )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_jpegsave_mime:
|
||||||
|
* @in: image to save
|
||||||
|
* @Q: JPEG quality factor
|
||||||
|
* @profile: attach this ICC profile
|
||||||
|
*
|
||||||
|
* 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 );
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -229,6 +229,13 @@ int vips_foreign_write( VipsImage *in, const char *filename, ... );
|
|||||||
|
|
||||||
void vips_foreign_operation_init( void );
|
void vips_foreign_operation_init( void );
|
||||||
|
|
||||||
|
int vips_jpegload( const char *filename, VipsImage **out, ... );
|
||||||
|
int vips_jpegload_buffer( void *buf, size_t len, VipsImage **out, ... );
|
||||||
|
|
||||||
|
int vips_jpegsave( VipsImage *in, const char *filename, ... );
|
||||||
|
int vips_jpegsave_buffer( VipsImage *in, void **buf, size_t *len, ... );
|
||||||
|
int vips_jpegsave_mime( VipsImage *in, ... );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -147,22 +147,22 @@ vips_value_hash( GParamSpec *pspec, GValue *value )
|
|||||||
else if( generic == G_TYPE_PARAM_STRING ) {
|
else if( generic == G_TYPE_PARAM_STRING ) {
|
||||||
const char *s = g_value_get_string( value );
|
const char *s = g_value_get_string( value );
|
||||||
|
|
||||||
return( g_str_hash( s ) );
|
return( s ? g_str_hash( s ) : 0 );
|
||||||
}
|
}
|
||||||
else if( generic == G_TYPE_PARAM_BOXED ) {
|
else if( generic == G_TYPE_PARAM_BOXED ) {
|
||||||
void *p = g_value_get_boxed( value );
|
void *p = g_value_get_boxed( value );
|
||||||
|
|
||||||
return( g_direct_hash( p ) );
|
return( p ? g_direct_hash( p ) : 0 );
|
||||||
}
|
}
|
||||||
else if( generic == G_TYPE_PARAM_POINTER ) {
|
else if( generic == G_TYPE_PARAM_POINTER ) {
|
||||||
void *p = g_value_get_pointer( value );
|
void *p = g_value_get_pointer( value );
|
||||||
|
|
||||||
return( g_direct_hash( p ) );
|
return( p ? g_direct_hash( p ) : 0 );
|
||||||
}
|
}
|
||||||
else if( generic == G_TYPE_PARAM_OBJECT ) {
|
else if( generic == G_TYPE_PARAM_OBJECT ) {
|
||||||
void *p = g_value_get_object( value );
|
void *p = g_value_get_object( value );
|
||||||
|
|
||||||
return( g_direct_hash( p ) );
|
return( p ? g_direct_hash( p ) : 0 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Fallback: convert to a string and hash that.
|
/* Fallback: convert to a string and hash that.
|
||||||
|
Loading…
Reference in New Issue
Block a user