add jpeg-chroma-subsample to jpegload
The jpeg loader now sets the field jpeg-chroma-subsample to record chroma subsample. See https://github.com/jcupitt/libvips/issues/954
This commit is contained in:
parent
38ea5937ca
commit
4f22e8d1dc
@ -16,6 +16,8 @@
|
|||||||
- set "interlaced=1" for interlaced JPG and PNG images
|
- set "interlaced=1" for interlaced JPG and PNG images
|
||||||
- add PDFium PDF loader
|
- add PDFium PDF loader
|
||||||
- add @format option to magickload
|
- add @format option to magickload
|
||||||
|
- jpegload adds a jpeg-chroma-subsample field with eg. 4:4:4 for no
|
||||||
|
chrominance subsampling.
|
||||||
|
|
||||||
12/3/18 started 8.6.4
|
12/3/18 started 8.6.4
|
||||||
- better fitting of fonts with overhanging edges [Adrià]
|
- better fitting of fonts with overhanging edges [Adrià]
|
||||||
|
@ -279,6 +279,25 @@ readjpeg_file( ReadJpeg *jpeg, const char *filename )
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
find_chroma_subsample( struct jpeg_decompress_struct *cinfo )
|
||||||
|
{
|
||||||
|
gboolean has_subsample;
|
||||||
|
|
||||||
|
/* libjpeg only uses 4:4:4 and 4:2:0, confusingly.
|
||||||
|
*
|
||||||
|
* http://poynton.ca/PDFs/Chroma_subsampling_notation.pdf
|
||||||
|
*/
|
||||||
|
has_subsample = cinfo->max_h_samp_factor > 1 ||
|
||||||
|
cinfo->max_v_samp_factor > 1;
|
||||||
|
if( cinfo->num_components > 3 )
|
||||||
|
/* A cmyk image.
|
||||||
|
*/
|
||||||
|
return( has_subsample ? "4:2:0:4" : "4:4:4:4" );
|
||||||
|
else
|
||||||
|
return( has_subsample ? "4:2:0" : "4:4:4" );
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
attach_blob( VipsImage *im, const char *field, void *data, int data_length )
|
attach_blob( VipsImage *im, const char *field, void *data, int data_length )
|
||||||
{
|
{
|
||||||
@ -439,6 +458,9 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
|
|||||||
if( jpeg_has_multiple_scans( cinfo ) )
|
if( jpeg_has_multiple_scans( cinfo ) )
|
||||||
vips_image_set_int( out, "interlaced", 1 );
|
vips_image_set_int( out, "interlaced", 1 );
|
||||||
|
|
||||||
|
(void) vips_image_set_string( out, "jpeg-chroma-subsample",
|
||||||
|
find_chroma_subsample( cinfo ) );
|
||||||
|
|
||||||
/* Look for EXIF and ICC profile.
|
/* Look for EXIF and ICC profile.
|
||||||
*/
|
*/
|
||||||
for( p = cinfo->marker_list; p; p = p->next ) {
|
for( p = cinfo->marker_list; p; p = p->next ) {
|
||||||
|
@ -374,6 +374,11 @@ vips_foreign_load_jpeg_buffer_init( VipsForeignLoadJpegBuffer *buffer )
|
|||||||
* memory to load, so this field gives callers a chance to handle these
|
* memory to load, so this field gives callers a chance to handle these
|
||||||
* images differently.
|
* images differently.
|
||||||
*
|
*
|
||||||
|
* The string-valued field "jpeg-chroma-subsample" gives the chroma subsample
|
||||||
|
* in standard notation. 4:4:4 means no subsample, 4:2:0 means YCbCr with
|
||||||
|
* Cb and Cr subsampled horizontally and vertically, 4:4:4:4 means a CMYK
|
||||||
|
* image with no subsampling.
|
||||||
|
*
|
||||||
* The EXIF thumbnail, if present, is attached to the image as
|
* The EXIF thumbnail, if present, is attached to the image as
|
||||||
* "jpeg-thumbnail-data". See vips_image_get_blob().
|
* "jpeg-thumbnail-data". See vips_image_get_blob().
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user