This commit is contained in:
John Cupitt 2010-04-30 19:16:39 +00:00
parent 1cab57014c
commit 1d473ef5cc
6 changed files with 126 additions and 36 deletions

View File

@ -17,6 +17,7 @@
- add --enable-debug=xxx flag
- im_iterate() -> vips_sink()
- better number-of-bands detection for im_magick2vips()
- added im_get_argv0()
16/1/10 started 7.21.2
- "invalidate" is careful to keep images alive, so invalidate callbacks can do

2
TODO
View File

@ -1,5 +1,3 @@
- im_magick2vips() needs rewriting, argh
- add support for PFM files, portable float maps

View File

@ -323,18 +323,6 @@ if test x"$with_magick" != "xno"; then
])
fi
if test x"$with_magick" != "xno"; then
# we need ResetImageAttributeIterator() / GetNextImageAttribute() to loop
# over attrs, but that's 6.2+ I think ... test for them
# graphicsmagick only has GetImageAttribute(), test for that as a fallback
save_LIBS=$LIBS
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(GetNextImageAttribute GetImageAttribute,
AC_DEFINE(HAVE_MAGICK_ATTR,1,
[define if your magick has attribute support.]))
LIBS=$save_LIBS
fi
if test x"$with_magick" != "xno"; then
# we SetImageOption to disable some DICOM read processing, but that's only
# in more recent imagemagicks and not in graphicsmagick
@ -346,6 +334,47 @@ if test x"$with_magick" != "xno"; then
LIBS=$save_LIBS
fi
if test x"$with_magick" != "xno"; then
# newer ImageMagicks use MagickCoreGenesis instead of InitializeMagick argh
save_LIBS=$LIBS
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(MagickCoreGenesis,
AC_DEFINE(HAVE_MAGICKCOREGENESIS,1,
[define if your magick has MagickCoreGenesis.]))
LIBS=$save_LIBS
fi
if test x"$with_magick" != "xno"; then
# newer ImageMagicks use ResetImagePropertyIterator instead of
# ResetImageAttributeIterator argh
save_LIBS=$LIBS
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(ResetImagePropertyIterator,
AC_DEFINE(HAVE_RESETIMAGEPROPERTYITERATOR,1,
[define if your magick has ResetImagePropertyIterator.]))
LIBS=$save_LIBS
fi
if test x"$with_magick" != "xno"; then
# so ... do we have ResetImageAttributeIterator()? GM does not
save_LIBS=$LIBS
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(ResetImageAttributeIterator,
AC_DEFINE(HAVE_RESETIMAGEATTRIBUTEITERATOR,1,
[define if your magick has ResetImageAttributeIterator.]))
LIBS=$save_LIBS
fi
if test x"$with_magick" != "xno"; then
# more recent magicks have GetVirtualPixels rather than GetImagePixels
save_LIBS=$LIBS
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(GetVirtualPixels,
AC_DEFINE(HAVE_GETVIRTUALPIXELS,1,
[define if your magick has GetVirtualPixels.]))
LIBS=$save_LIBS
fi
# liboil
AC_ARG_WITH([liboil],
AS_HELP_STRING([--without-liboil], [build without liboil (default: test)]))

View File

@ -35,6 +35,7 @@
* - gtkdoc
* 30/4/10
* - better number of bands detection with GetImageType()
* - use new API stuff, argh
*/
/*
@ -158,7 +159,11 @@ read_new( const char *filename, IMAGE *im )
static int inited = 0;
if( !inited ) {
#ifdef HAVE_MAGICKCOREGENESIS
MagickCoreGenesis( im_get_argv0(), MagickFalse );
#else /*!HAVE_MAGICKCOREGENESIS*/
InitializeMagick( "" );
#endif /*HAVE_MAGICKCOREGENESIS*/
inited = 1;
}
@ -241,9 +246,6 @@ parse_header( Read *read )
IMAGE *im = read->im;
Image *image = read->image;
#ifdef HAVE_MAGICK_ATTR
const ImageAttribute *attr;
#endif /*HAVE_MAGICK_ATTR*/
Image *p;
int i;
@ -353,34 +355,60 @@ parse_header( Read *read )
*/
im->Coding = IM_CODING_NONE;
#ifdef HAVE_MAGICK_ATTR
#ifdef HAVE_GETNEXTIMAGEATTRIBUTE
/* Gah, magick6.something and later only. Attach any attributes.
/* Three ways to loop over attributes / properties :-(
*/
#ifdef HAVE_RESETIMAGEPROPERTYITERATOR
{
char *key;
/* This is the most recent imagemagick API, test for this first.
*/
ResetImagePropertyIterator( image );
while( (key = GetNextImageProperty( image )) ) {
char name_text[256];
VipsBuf name;
vips_buf_init_static( &name, name_text, 256 );
vips_buf_appendf( &name, "magick-%s", key );
im_meta_set_string( im,
vips_buf_all( &name ), GetImageProperty( image, key ) );
}
}
#elif defined(HAVE_RESETIMAGEATTRIBUTEITERATOR)
{
const ImageAttribute *attr;
/* magick6.1-ish and later, deprecated in 6.5ish.
*/
ResetImageAttributeIterator( image );
while( (attr = GetNextImageAttribute( image )) ) {
#elif defined(HAVE_GETIMAGEATTRIBUTE)
/* GraphicsMagick is missing the iterator: we have to loop ourselves.
* ->attributes is marked as private in the header, but there's no
* getter so we have to access it directly.
*/
for( attr = image->attributes; attr; attr = attr->next ) {
#else /*stuff*/
#error attributes enabled, but no access funcs found
#endif
char name_text[256];
VipsBuf name;
vips_buf_init_static( &name, name_text, 256 );
vips_buf_appendf( &name, "magick-%s", attr->key );
im_meta_set_string( im, vips_buf_all( &name ), attr->value );
#ifdef DEBUG
printf( "key = \"%s\", value = \"%s\"\n",
attr->key, attr->value );
#endif /*DEBUG*/
}
#endif /*HAVE_MAGICK_ATTR*/
}
#else
{
const ImageAttribute *attr;
/* GraphicsMagick is missing the iterator: we have to loop ourselves.
* ->attributes is marked as private in the header, but there's no
* getter so we have to access it directly.
*/
for( attr = image->attributes; attr; attr = attr->next ) {
char name_text[256];
VipsBuf name;
vips_buf_init_static( &name, name_text, 256 );
vips_buf_appendf( &name, "magick-%s", attr->key );
im_meta_set_string( im, vips_buf_all( &name ), attr->value );
}
}
#endif
/* Do we have a set of equal-sized frames? Append them.
@ -556,8 +584,13 @@ static PixelPacket *
get_pixels( Image *image, int left, int top, int width, int height )
{
PixelPacket *pixels;
#ifdef HAVE_GETVIRTUALPIXELS
if( !(pixels = (PixelPacket *) GetVirtualPixels( image,
left, top, width, height, &image->exception )) )
#else
if( !(pixels = GetImagePixels( image, left, top, width, height )) )
#endif
return( NULL );
/* Can't happen if red/green/blue are doubles.
@ -566,7 +599,13 @@ get_pixels( Image *image, int left, int top, int width, int height )
/* Unpack palette.
*/
if( image->storage_class == PseudoClass ) {
#ifdef HAVE_GETVIRTUALPIXELS
IndexPacket *indexes = (IndexPacket *)
GetVirtualIndexQueue( image );
#else
IndexPacket *indexes = GetIndexes( image );
#endif
int i;
for( i = 0; i < width * height; i++ ) {

View File

@ -291,6 +291,7 @@ extern const size_t im__sizeof_bandfmt[];
(X) * IM_IMAGE_SIZEOF_PEL(I))
#endif /*DEBUG*/
const char *im_get_argv0( void );
int im_init_world( const char *argv0 );
GOptionGroup *im_get_option_group( void );

View File

@ -58,6 +58,8 @@
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <string.h>
#include <vips/vips.h>
#include <vips/thread.h>
#include <vips/internal.h>
@ -75,6 +77,24 @@
*/
GMutex *im__global_lock = NULL;
/* Keep a copy of the argv0 here.
*/
static char *im__argv0 = NULL;
/**
* im_get_argv0:
*
* See also: im_init_world().
*
* Returns: a pointer to an internal copy of the argv0 string passed to
* im_init_world(). Do not free this value
*/
const char *
im_get_argv0( void )
{
return( im__argv0 );
}
/**
* im_init_world:
* @argv0: name of application
@ -147,6 +167,8 @@ im_init_world( const char *argv0 )
return( 0 );
started = TRUE;
IM_SETSTR( im__argv0, argv0 );
/* Need gobject etc.
*/
g_type_init();