Merge pull request #2119 from lovell/compress-profiles

Compress fallback colour profiles with zlib (zopfli, via pigz)
This commit is contained in:
John Cupitt 2021-02-26 23:29:30 +00:00 committed by GitHub
commit dd57463c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32357 additions and 80720 deletions

View File

@ -66,10 +66,30 @@ vips_profile_fallback_get( const char *name, size_t *length )
for( i = 0; (fallback = vips__profile_fallback_table[i]); i++ ) for( i = 0; (fallback = vips__profile_fallback_table[i]); i++ )
if( g_ascii_strcasecmp( fallback->name, name ) == 0 ) { if( g_ascii_strcasecmp( fallback->name, name ) == 0 ) {
if( length ) void *data;
*length = fallback->length; GConverter *converter;
GConverterResult res;
gsize bytes_read;
gsize bytes_written;
return( fallback->data ); data = g_malloc0( fallback->length );
converter = G_CONVERTER( g_zlib_decompressor_new(
G_ZLIB_COMPRESSOR_FORMAT_ZLIB ) );
res = g_converter_convert( converter,
fallback->data, fallback->length,
data, fallback->length,
G_CONVERTER_INPUT_AT_END,
&bytes_read, &bytes_written, NULL );
g_object_unref( converter );
if( res == G_CONVERTER_FINISHED ) {
*length = fallback->length;
return( data );
} else {
g_free( data );
g_warning( "fallback profile decompression failed" );
}
} }
return( NULL ); return( NULL );
@ -92,7 +112,8 @@ vips_profile_load_build( VipsObject *object )
if( g_ascii_strcasecmp( load->name, "none" ) == 0 ) if( g_ascii_strcasecmp( load->name, "none" ) == 0 )
profile = NULL; profile = NULL;
else if( (data = vips_profile_fallback_get( load->name, &length )) ) else if( (data = vips_profile_fallback_get( load->name, &length )) )
profile = vips_blob_new( NULL, data, length ); profile = vips_blob_new(
(VipsCallbackFn) vips_area_free_cb, data, length );
else if( (data = vips__file_read_name( load->name, else if( (data = vips__file_read_name( load->name,
vips__icc_dir(), &length )) ) vips__icc_dir(), &length )) )
profile = vips_blob_new( profile = vips_blob_new(

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ echo "#include \"profiles.h\"" >> $out
echo "" >> $out echo "" >> $out
profile_names= profile_names=
for file in $in/*; do for file in $in/*.icm; do
root=${file%.icm} root=${file%.icm}
base=${root##*/} base=${root##*/}
profile_name=vips__profile_fallback_$base profile_name=vips__profile_fallback_$base
@ -24,7 +24,7 @@ for file in $in/*; do
echo " \"$base\"," >> $out echo " \"$base\"," >> $out
echo " $(stat --format=%s $file)," >> $out echo " $(stat --format=%s $file)," >> $out
echo " {" >> $out echo " {" >> $out
hexdump -v -e '" 0x" 1/1 "%02X,"' $file | fmt >> $out pigz -c -z -11 $file | hexdump -v -e '" 0x" 1/1 "%02X,"' | fmt >> $out
echo " }" >> $out echo " }" >> $out
echo "};" >> $out echo "};" >> $out
echo >> $out echo >> $out