remove the embedded thumbnail reader
remove the embedded thumbnail reader, embedded thumbnails are too unlike the main image wrt. rotation / colour / etc.
This commit is contained in:
parent
40a15b3aa0
commit
66d0e28dc2
@ -10,6 +10,8 @@
|
|||||||
- VipsStatistic operations are sequential
|
- VipsStatistic operations are sequential
|
||||||
- vipsthumbnail attaches main image metadata to embedded thumbnails
|
- vipsthumbnail attaches main image metadata to embedded thumbnails
|
||||||
- vipsthumbnail has --rotate auto-rotate option
|
- vipsthumbnail has --rotate auto-rotate option
|
||||||
|
- removed embedded thumbnail reader from vipsthumbnail: embedded thumbnails
|
||||||
|
are too unlike the main image
|
||||||
|
|
||||||
6/3/14 started 7.38.6
|
6/3/14 started 7.38.6
|
||||||
- grey ramp minimum was wrong
|
- grey ramp minimum was wrong
|
||||||
|
6
TODO
6
TODO
@ -1,11 +1,5 @@
|
|||||||
- vipsthumbnail needs to know about more exif orientation tags
|
- vipsthumbnail needs to know about more exif orientation tags
|
||||||
|
|
||||||
- vipsthumbnail --rotate breaks for embedded thumbnail sources
|
|
||||||
|
|
||||||
embedded thumbnails seems to have had the orientation applied already
|
|
||||||
|
|
||||||
need to not copy orientation tag from main to thumb? is this right for all
|
|
||||||
images?
|
|
||||||
|
|
||||||
|
|
||||||
- think of a better way to support skipahead
|
- think of a better way to support skipahead
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
* - copy main image metadata to embedded thumbnails, thanks ottob
|
* - copy main image metadata to embedded thumbnails, thanks ottob
|
||||||
* 6/3/14
|
* 6/3/14
|
||||||
* - add --rotate flag
|
* - add --rotate flag
|
||||||
|
* 7/3/14
|
||||||
|
* - remove the embedded thumbnail reader, embedded thumbnails are too
|
||||||
|
* unlike the main image wrt. rotation / colour / etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -219,88 +222,7 @@ thumbnail_find_jpegshrink( VipsImage *im )
|
|||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#define THUMBNAIL "jpeg-thumbnail-data"
|
|
||||||
|
|
||||||
static void *
|
|
||||||
copy_jpeg_field( VipsImage *from, const char *field, GValue *value, void *a )
|
|
||||||
{
|
|
||||||
VipsImage *to = (VipsImage *) a;
|
|
||||||
|
|
||||||
if( vips_isprefix( "exif-", field ) ||
|
|
||||||
strcmp( field, VIPS_META_EXIF_NAME ) == 0 ||
|
|
||||||
strcmp( field, VIPS_META_XMP_NAME ) == 0 ||
|
|
||||||
strcmp( field, VIPS_META_IPCT_NAME ) == 0 ||
|
|
||||||
strcmp( field, VIPS_META_ICC_NAME ) == 0 )
|
|
||||||
vips_image_set( to, field, value );
|
|
||||||
|
|
||||||
return( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to read an embedded thumbnail.
|
|
||||||
*/
|
|
||||||
static VipsImage *
|
|
||||||
thumbnail_get_thumbnail( VipsImage *im, int jpegshrink )
|
|
||||||
{
|
|
||||||
void *ptr;
|
|
||||||
size_t size;
|
|
||||||
VipsImage *thumb;
|
|
||||||
|
|
||||||
if( !vips_image_get_typeof( im, THUMBNAIL ) ||
|
|
||||||
vips_image_get_blob( im, THUMBNAIL, &ptr, &size ) ||
|
|
||||||
vips_jpegload_buffer( ptr, size, &thumb,
|
|
||||||
"shrink", jpegshrink,
|
|
||||||
NULL ) ) {
|
|
||||||
vips_info( "vipsthumbnail", "no jpeg thumbnail" );
|
|
||||||
return( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy over the metadata from the main image. We want our thumbnail
|
|
||||||
* to have the orientation, profile etc. from there.
|
|
||||||
*/
|
|
||||||
(void) vips_image_map( im, copy_jpeg_field, thumb );
|
|
||||||
|
|
||||||
return( thumb );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get an embedded thumb with the appropriate shrink.
|
|
||||||
*/
|
|
||||||
static VipsImage *
|
|
||||||
thumbnail_get_thumbnail_shrink( VipsImage *im )
|
|
||||||
{
|
|
||||||
VipsImage *thumb;
|
|
||||||
double residual;
|
|
||||||
int jpegshrink;
|
|
||||||
|
|
||||||
if( !(thumb = thumbnail_get_thumbnail( im, 1 )) )
|
|
||||||
return( NULL );
|
|
||||||
|
|
||||||
calculate_shrink( thumb, &residual );
|
|
||||||
if( residual > 1.0 ) {
|
|
||||||
vips_info( "vipsthumbnail", "jpeg thumbnail too small" );
|
|
||||||
g_object_unref( thumb );
|
|
||||||
return( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reload with the correct downshrink.
|
|
||||||
*/
|
|
||||||
jpegshrink = thumbnail_find_jpegshrink( thumb );
|
|
||||||
vips_info( "vipsthumbnail",
|
|
||||||
"loading jpeg thumbnail with factor %d pre-shrink",
|
|
||||||
jpegshrink );
|
|
||||||
g_object_unref( thumb );
|
|
||||||
|
|
||||||
if( !(thumb = thumbnail_get_thumbnail( im, jpegshrink )) )
|
|
||||||
return( NULL );
|
|
||||||
|
|
||||||
vips_info( "vipsthumbnail", "using %dx%d jpeg thumbnail",
|
|
||||||
thumb->Xsize, thumb->Ysize );
|
|
||||||
|
|
||||||
return( thumb );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open an image, returning the best version of that image for thumbnailing.
|
/* Open an image, returning the best version of that image for thumbnailing.
|
||||||
*
|
|
||||||
* jpegs can have embedded thumbnails ... use that if it's large enough.
|
|
||||||
*
|
*
|
||||||
* libjpeg supports fast shrink-on-read, so if we have a JPEG, we can ask
|
* libjpeg supports fast shrink-on-read, so if we have a JPEG, we can ask
|
||||||
* VIPS to load a lower resolution version.
|
* VIPS to load a lower resolution version.
|
||||||
@ -322,45 +244,26 @@ thumbnail_open( VipsObject *process, const char *filename )
|
|||||||
vips_info( "vipsthumbnail", "selected loader is %s", loader );
|
vips_info( "vipsthumbnail", "selected loader is %s", loader );
|
||||||
|
|
||||||
if( strcmp( loader, "VipsForeignLoadJpegFile" ) == 0 ) {
|
if( strcmp( loader, "VipsForeignLoadJpegFile" ) == 0 ) {
|
||||||
VipsImage *thumb;
|
int jpegshrink;
|
||||||
|
|
||||||
/* This will just read in the header and is quick.
|
/* This will just read in the header and is quick.
|
||||||
*/
|
*/
|
||||||
if( !(im = vips_image_new_from_file( filename )) )
|
if( !(im = vips_image_new_from_file( filename )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
/* Try to read an embedded thumbnail. If we find one, use that
|
jpegshrink = thumbnail_find_jpegshrink( im );
|
||||||
* instead.
|
|
||||||
*/
|
|
||||||
if( (thumb = thumbnail_get_thumbnail_shrink( im )) ) {
|
|
||||||
/* @thumb has not been fully decoded yet ...
|
|
||||||
* we must not close @im
|
|
||||||
* until we're done with @thumb.
|
|
||||||
*/
|
|
||||||
vips_object_local( VIPS_OBJECT( thumb ), im );
|
|
||||||
|
|
||||||
im = thumb;
|
g_object_unref( im );
|
||||||
}
|
|
||||||
else {
|
|
||||||
int jpegshrink;
|
|
||||||
|
|
||||||
vips_info( "vipsthumbnail",
|
vips_info( "vipsthumbnail",
|
||||||
"processing main jpeg image" );
|
"loading jpeg with factor %d pre-shrink",
|
||||||
|
jpegshrink );
|
||||||
|
|
||||||
jpegshrink = thumbnail_find_jpegshrink( im );
|
if( vips_foreign_load( filename, &im,
|
||||||
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
g_object_unref( im );
|
"shrink", jpegshrink,
|
||||||
|
NULL ) )
|
||||||
vips_info( "vipsthumbnail",
|
return( NULL );
|
||||||
"loading jpeg with factor %d pre-shrink",
|
|
||||||
jpegshrink );
|
|
||||||
|
|
||||||
if( vips_foreign_load( filename, &im,
|
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
|
||||||
"shrink", jpegshrink,
|
|
||||||
NULL ) )
|
|
||||||
return( NULL );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* All other formats.
|
/* All other formats.
|
||||||
|
Loading…
Reference in New Issue
Block a user