add "no-subsample" option to jpeg save
turns off chroma subsampling
This commit is contained in:
parent
0444effb8e
commit
c1e7bbab29
22
TODO
22
TODO
@ -1,28 +1,6 @@
|
||||
- large alpha PNGs seem to need huge amounts of ram to process
|
||||
|
||||
john@bambam ~/pics $ vipsthumbnail wtc.png
|
||||
memory: high-water mark 31.37 MB
|
||||
john@bambam ~/pics $ vipsthumbnail wtc.png --linear
|
||||
memory: high-water mark 47.83 MB
|
||||
|
||||
john@bambam ~/pics $ vipsthumbnail wtc_alpha.png
|
||||
memory: high-water mark 41.85 MB
|
||||
john@bambam ~/pics $ vipsthumbnail wtc_alpha.png --linear
|
||||
memory: high-water mark 101.59 MB
|
||||
john@bambam ~/pics $
|
||||
|
||||
it seems to be the vips_colourspace() cast from sRGB to XYZ that's doing it?
|
||||
how odd
|
||||
|
||||
maybe the thing that detaches and reattaches the alpha?
|
||||
|
||||
- still don't get progress feedback in nip2 for a long png save, eg. make a
|
||||
4-band wtc, save as png
|
||||
|
||||
- support --strip for other writers
|
||||
|
||||
- vipstumbnail is broken for the gamma trick png on eric brasseur's page
|
||||
|
||||
- vipsthumbnail could shrink-on-load openslide and pyr tiff as well?
|
||||
|
||||
- look again at gcc auto-vectorisation, what would we need to do to use this?
|
||||
|
@ -1389,7 +1389,7 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class )
|
||||
|
||||
/* I think all savers are sequential. Hopefully.
|
||||
*/
|
||||
operation_class->flags |= VIPS_OPERATION_SEQUENTIAL;
|
||||
operation_class->flags |= VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
||||
|
||||
/* Must not cache savers.
|
||||
*/
|
||||
|
@ -87,6 +87,10 @@ typedef struct _VipsForeignSaveJpeg {
|
||||
*/
|
||||
gboolean interlace;
|
||||
|
||||
/* Disable chroma subsampling.
|
||||
*/
|
||||
gboolean no_subsample;
|
||||
|
||||
} VipsForeignSaveJpeg;
|
||||
|
||||
typedef VipsForeignSaveClass VipsForeignSaveJpegClass;
|
||||
@ -127,26 +131,33 @@ vips_foreign_save_jpeg_class_init( VipsForeignSaveJpegClass *class )
|
||||
1, 100, 75 );
|
||||
|
||||
VIPS_ARG_STRING( class, "profile", 11,
|
||||
_( "profile" ),
|
||||
_( "Profile" ),
|
||||
_( "ICC profile to embed" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSaveJpeg, profile ),
|
||||
NULL );
|
||||
|
||||
VIPS_ARG_BOOL( class, "optimize_coding", 12,
|
||||
_( "optimize_coding" ),
|
||||
_( "Optimize_coding" ),
|
||||
_( "Compute optimal Huffman coding tables" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSaveJpeg, optimize_coding ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_BOOL( class, "interlace", 13,
|
||||
_( "interlace" ),
|
||||
_( "Interlace" ),
|
||||
_( "Generate an interlaced (progressive) jpeg" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSaveJpeg, interlace ),
|
||||
FALSE );
|
||||
|
||||
VIPS_ARG_BOOL( class, "no_subsample", 14,
|
||||
_( "No subsample" ),
|
||||
_( "Disable chroma subsample" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSaveJpeg, no_subsample ),
|
||||
FALSE );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -182,7 +193,7 @@ vips_foreign_save_jpeg_file_build( VipsObject *object )
|
||||
|
||||
if( vips__jpeg_write_file( save->ready, file->filename,
|
||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||
jpeg->interlace, save->strip ) )
|
||||
jpeg->interlace, save->strip, jpeg->no_subsample ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
@ -248,7 +259,7 @@ vips_foreign_save_jpeg_buffer_build( VipsObject *object )
|
||||
|
||||
if( vips__jpeg_write_buffer( save->ready,
|
||||
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||
jpeg->interlace, save->strip ) )
|
||||
jpeg->interlace, save->strip, jpeg->no_subsample ) )
|
||||
return( -1 );
|
||||
|
||||
area = vips_area_new_blob( (VipsCallbackFn) vips_free, obuf, olen );
|
||||
@ -310,7 +321,7 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
||||
|
||||
if( vips__jpeg_write_buffer( save->ready,
|
||||
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||
jpeg->interlace, save->strip ) )
|
||||
jpeg->interlace, save->strip, jpeg->no_subsample ) )
|
||||
return( -1 );
|
||||
|
||||
printf( "Content-length: %zd\r\n", olen );
|
||||
|
@ -60,6 +60,8 @@
|
||||
* - add optimize_coding parameter
|
||||
* 12/11/13
|
||||
* - add "strip" option to remove all metadata
|
||||
* 13/11/13
|
||||
* - add a "no_subsample" option to disable chroma subsample
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -843,7 +845,8 @@ write_jpeg_block( REGION *region, Rect *area, void *a )
|
||||
*/
|
||||
static int
|
||||
write_vips( Write *write, int qfac, const char *profile,
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip )
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip,
|
||||
gboolean no_subsample )
|
||||
{
|
||||
VipsImage *in;
|
||||
J_COLOR_SPACE space;
|
||||
@ -905,6 +908,17 @@ write_vips( Write *write, int qfac, const char *profile,
|
||||
if( progressive )
|
||||
jpeg_simple_progression( &write->cinfo );
|
||||
|
||||
/* Turn off chroma subsampling.
|
||||
*/
|
||||
if( no_subsample ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < in->Bands; i++ ) {
|
||||
write->cinfo.comp_info[i].h_samp_factor = 1;
|
||||
write->cinfo.comp_info[i].v_samp_factor = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Build compress tables.
|
||||
*/
|
||||
jpeg_start_compress( &write->cinfo, TRUE );
|
||||
@ -952,7 +966,8 @@ write_vips( Write *write, int qfac, const char *profile,
|
||||
int
|
||||
vips__jpeg_write_file( VipsImage *in,
|
||||
const char *filename, int Q, const char *profile,
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip )
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip,
|
||||
gboolean no_subsample )
|
||||
{
|
||||
Write *write;
|
||||
|
||||
@ -983,7 +998,8 @@ vips__jpeg_write_file( VipsImage *in,
|
||||
/* Convert!
|
||||
*/
|
||||
if( write_vips( write,
|
||||
Q, profile, optimize_coding, progressive, strip ) ) {
|
||||
Q, profile, optimize_coding, progressive, strip,
|
||||
no_subsample ) ) {
|
||||
write_destroy( write );
|
||||
return( -1 );
|
||||
}
|
||||
@ -1231,7 +1247,7 @@ int
|
||||
vips__jpeg_write_buffer( VipsImage *in,
|
||||
void **obuf, size_t *olen, int Q, const char *profile,
|
||||
gboolean optimize_coding, gboolean progressive,
|
||||
gboolean strip )
|
||||
gboolean strip, gboolean no_subsample )
|
||||
{
|
||||
Write *write;
|
||||
|
||||
@ -1261,7 +1277,8 @@ vips__jpeg_write_buffer( VipsImage *in,
|
||||
/* Convert!
|
||||
*/
|
||||
if( write_vips( write,
|
||||
Q, profile, optimize_coding, progressive, strip ) ) {
|
||||
Q, profile, optimize_coding, progressive, strip,
|
||||
no_subsample ) ) {
|
||||
write_destroy( write );
|
||||
|
||||
return( -1 );
|
||||
|
@ -39,10 +39,12 @@ extern const char *vips__jpeg_suffs[];
|
||||
|
||||
int vips__jpeg_write_file( VipsImage *in,
|
||||
const char *filename, int Q, const char *profile,
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip );
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip,
|
||||
gboolean no_subsample );
|
||||
int vips__jpeg_write_buffer( VipsImage *in,
|
||||
void **obuf, size_t *olen, int Q, const char *profile,
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip );
|
||||
gboolean optimize_coding, gboolean progressive, gboolean strip,
|
||||
gboolean no_subsample );
|
||||
|
||||
int vips__isjpeg( const char *filename );
|
||||
int vips__jpeg_read_file( const char *name, VipsImage *out,
|
||||
|
Loading…
Reference in New Issue
Block a user