Added quality option.
This commit is contained in:
parent
c7992bf6d9
commit
ccf894c738
@ -1033,7 +1033,8 @@ write_close( VipsImage *im, Write *write )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Write *
|
static Write *
|
||||||
write_new( VipsImage *im, const char *filename, const char *format )
|
write_new( VipsImage *im, const char *filename, const char *format,
|
||||||
|
const size_t quality )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
@ -1107,8 +1108,6 @@ write_new( VipsImage *im, const char *filename, const char *format )
|
|||||||
vips_strncpy( write->image_info->magick,
|
vips_strncpy( write->image_info->magick,
|
||||||
format, MaxPathExtent );
|
format, MaxPathExtent );
|
||||||
if ( filename ) {
|
if ( filename ) {
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
(void) vips_snprintf( write->image_info->filename,
|
(void) vips_snprintf( write->image_info->filename,
|
||||||
MaxPathExtent, "%s:%s", format, filename );
|
MaxPathExtent, "%s:%s", format, filename );
|
||||||
}
|
}
|
||||||
@ -1118,6 +1117,10 @@ write_new( VipsImage *im, const char *filename, const char *format )
|
|||||||
filename, MaxPathExtent );
|
filename, MaxPathExtent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( quality > 0 ) {
|
||||||
|
write->image_info->quality = quality;
|
||||||
|
}
|
||||||
|
|
||||||
write->exception = AcquireExceptionInfo();
|
write->exception = AcquireExceptionInfo();
|
||||||
if( !write->exception) {
|
if( !write->exception) {
|
||||||
write_free(write);
|
write_free(write);
|
||||||
@ -1250,11 +1253,11 @@ magick_write_images_buf( Write *write, void **obuf, size_t *olen )
|
|||||||
|
|
||||||
int
|
int
|
||||||
vips__magick_write( VipsImage *im, const char *filename,
|
vips__magick_write( VipsImage *im, const char *filename,
|
||||||
const char *format )
|
const char *format, const size_t quality )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
if( !(write = write_new( im, filename, format )) )
|
if( !(write = write_new( im, filename, format, quality )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if ( magick_create_images( write ) ) {
|
if ( magick_create_images( write ) ) {
|
||||||
@ -1279,11 +1282,11 @@ vips__magick_write( VipsImage *im, const char *filename,
|
|||||||
|
|
||||||
int
|
int
|
||||||
vips__magick_write_buf( VipsImage *im, void **obuf, size_t *olen,
|
vips__magick_write_buf( VipsImage *im, void **obuf, size_t *olen,
|
||||||
const char *format )
|
const char *format, const size_t quality )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
if( !(write = write_new( im, NULL, format )) )
|
if( !(write = write_new( im, NULL, format, quality )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if ( magick_create_images( write ) ) {
|
if ( magick_create_images( write ) ) {
|
||||||
|
@ -99,6 +99,7 @@ typedef struct _VipsForeignSaveMagickFile {
|
|||||||
|
|
||||||
char *filename;
|
char *filename;
|
||||||
char *format;
|
char *format;
|
||||||
|
int quality;
|
||||||
|
|
||||||
} VipsForeignSaveMagickFile;
|
} VipsForeignSaveMagickFile;
|
||||||
|
|
||||||
@ -118,7 +119,8 @@ vips_foreign_save_magick_file_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__magick_write( save->ready, file->filename, file->format ) )
|
if( vips__magick_write( save->ready, file->filename, file->format,
|
||||||
|
file->quality ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -152,6 +154,13 @@ vips_foreign_save_magick_file_class_init(
|
|||||||
G_STRUCT_OFFSET( VipsForeignSaveMagickFile, format ),
|
G_STRUCT_OFFSET( VipsForeignSaveMagickFile, format ),
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
|
VIPS_ARG_INT( class, "quality", 3,
|
||||||
|
_( "Quality" ),
|
||||||
|
_( "Quality to use" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignSaveMagickFile, quality ),
|
||||||
|
0, 100, 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -166,6 +175,7 @@ typedef struct _VipsForeignSaveMagickBuffer {
|
|||||||
*/
|
*/
|
||||||
VipsArea *buf;
|
VipsArea *buf;
|
||||||
char *format;
|
char *format;
|
||||||
|
int quality;
|
||||||
|
|
||||||
} VipsForeignSaveMagickBuffer;
|
} VipsForeignSaveMagickBuffer;
|
||||||
|
|
||||||
@ -190,7 +200,7 @@ vips_foreign_save_magick_buffer_build( VipsObject *object )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__magick_write_buf( save->ready, &obuf, &olen,
|
if( vips__magick_write_buf( save->ready, &obuf, &olen,
|
||||||
buffer->format ) )
|
buffer->format, buffer->quality ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* obuf is a g_free() buffer, not vips_free().
|
/* obuf is a g_free() buffer, not vips_free().
|
||||||
@ -226,8 +236,15 @@ vips_foreign_save_magick_buffer_class_init( VipsForeignSaveMagickBufferClass *cl
|
|||||||
_( "Format" ),
|
_( "Format" ),
|
||||||
_( "Format to save in" ),
|
_( "Format to save in" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveMagickFile, format ),
|
G_STRUCT_OFFSET( VipsForeignSaveMagickBuffer, format ),
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
|
VIPS_ARG_INT( class, "quality", 3,
|
||||||
|
_( "Quality" ),
|
||||||
|
_( "Quality to use" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignSaveMagickBuffer, quality ),
|
||||||
|
0, 100, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -133,9 +133,9 @@ int vips__magick_read_buffer_header( const void *buf, const size_t len,
|
|||||||
VipsImage *out, const char *density, int page, int n );
|
VipsImage *out, const char *density, int page, int n );
|
||||||
|
|
||||||
int vips__magick_write( VipsImage *in, const char *filename,
|
int vips__magick_write( VipsImage *in, const char *filename,
|
||||||
const char *format );
|
const char *format, const size_t quality );
|
||||||
int vips__magick_write_buf( VipsImage *in, void **obuf, size_t *olen,
|
int vips__magick_write_buf( VipsImage *in, void **obuf, size_t *olen,
|
||||||
const char *format );
|
const char *format, const size_t quality );
|
||||||
|
|
||||||
extern const char *vips__mat_suffs[];
|
extern const char *vips__mat_suffs[];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user