start adding ICC and XMP support
not quite working though ... seems to need a fix in libspng still
This commit is contained in:
parent
a44814018d
commit
ef408d630b
@ -171,6 +171,11 @@ vips_foreign_load_png_get_flags_filename( const char *filename )
|
|||||||
static void
|
static void
|
||||||
vips_foreign_load_png_set_header( VipsForeignLoadPng *png, VipsImage *image )
|
vips_foreign_load_png_set_header( VipsForeignLoadPng *png, VipsImage *image )
|
||||||
{
|
{
|
||||||
|
struct spng_iccp iccp;
|
||||||
|
struct spng_text *text;
|
||||||
|
guint32 n_text;
|
||||||
|
int ret;
|
||||||
|
|
||||||
vips_image_init_fields( image,
|
vips_image_init_fields( image,
|
||||||
png->ihdr.width, png->ihdr.height, png->bands,
|
png->ihdr.width, png->ihdr.height, png->bands,
|
||||||
png->format, VIPS_CODING_NONE, png->interpretation,
|
png->format, VIPS_CODING_NONE, png->interpretation,
|
||||||
@ -178,6 +183,34 @@ vips_foreign_load_png_set_header( VipsForeignLoadPng *png, VipsImage *image )
|
|||||||
VIPS_SETSTR( image->filename,
|
VIPS_SETSTR( image->filename,
|
||||||
vips_connection_filename( VIPS_CONNECTION( png->source ) ) );
|
vips_connection_filename( VIPS_CONNECTION( png->source ) ) );
|
||||||
|
|
||||||
|
/* Attach ICC profile.
|
||||||
|
*/
|
||||||
|
if( !spng_get_iccp( png->ctx, &iccp ) ) {
|
||||||
|
printf( "attaching profile %s, %zd bytes\n",
|
||||||
|
iccp.profile_name, iccp.profile_len );
|
||||||
|
|
||||||
|
vips_image_set_blob_copy( image,
|
||||||
|
VIPS_META_ICC_NAME, iccp.profile, iccp.profile_len );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
spng_get_text( png->ctx, NULL, &n_text );
|
||||||
|
printf( "reading %" G_GUINT32_FORMAT " text chunks\n", n_text );
|
||||||
|
text = VIPS_ARRAY( VIPS_OBJECT( png ), n_text, struct spng_text );
|
||||||
|
if( !spng_get_text( png->ctx, text, &n_text ) ) {
|
||||||
|
guint32 i;
|
||||||
|
|
||||||
|
for( i = 0; i < n_text; i++ ) {
|
||||||
|
printf( "chunk %d: keyword %s, type %d, length %zd\n",
|
||||||
|
i, text[i].keyword, text[i].type,
|
||||||
|
text[i].length );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* FIXME ... get resolution, exif, xmp, etc. etc.
|
||||||
|
*/
|
||||||
|
|
||||||
/* 0 is no interlace.
|
/* 0 is no interlace.
|
||||||
*/
|
*/
|
||||||
if( png->ihdr.interlace_method == 0 )
|
if( png->ihdr.interlace_method == 0 )
|
||||||
@ -289,9 +322,6 @@ vips_foreign_load_png_header( VipsForeignLoad *load )
|
|||||||
else
|
else
|
||||||
png->format = VIPS_FORMAT_UCHAR;
|
png->format = VIPS_FORMAT_UCHAR;
|
||||||
|
|
||||||
/* FIXME ... get resolution, profile, exif, xmp, etc. etc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
vips_source_minimise( png->source );
|
vips_source_minimise( png->source );
|
||||||
|
|
||||||
vips_foreign_load_png_set_header( png, load->out );
|
vips_foreign_load_png_set_header( png, load->out );
|
||||||
|
Loading…
Reference in New Issue
Block a user