diff --git a/ChangeLog b/ChangeLog index a62a3331..d2845ac9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ - always fetch HEIC metadata from the main image [zhoux2016] - fix loop in malformed ppm [Kyle-Kyle] - better support for PNGs with long comment names +- fix build with GM 24/5/19 started 8.8.1 - improve realpath() use on older libc diff --git a/configure.ac b/configure.ac index e9f8d2f1..8f636916 100644 --- a/configure.ac +++ b/configure.ac @@ -662,68 +662,6 @@ else with_magickpackage=none fi -if test x"$magick6" = x"yes"; then - # we SetImageOption to disable some DICOM read processing, but that's only - # in more recent imagemagicks and not in graphicsmagick - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(SetImageOption, - AC_DEFINE(HAVE_SETIMAGEOPTION,1,[define if your magick has SetImageOption.]) - ) - LIBS="$save_LIBS" -fi - -if test x"$magick6" = x"yes"; 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"$magick6" = x"yes"; 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"$magick6" = x"yes"; 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"$magick6" = x"yes"; then - # GM does not have ResetImageProfileIterator - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(ResetImageProfileIterator, - AC_DEFINE(HAVE_RESETIMAGEPROFILEITERATOR,1, - [define if your magick has ResetImageProfileIterator.])) - LIBS="$save_LIBS" -fi - -if test x"$magick6" = x"yes"; 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 - if test x"$magick6" = x"yes"; then # do we have number_scenes in image_info ... imagemagick uses this save_CFLAGS="$CFLAGS" @@ -737,63 +675,41 @@ if test x"$magick6" = x"yes"; then fi if test x"$magick6" = x"yes"; then - # more recent magick6s have AcquireImage rather than AllocateImage argh + # the magick6 API varies a lot between magick versions, and between GM and + # IM save_LIBS="$LIBS" LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(AcquireImage, - AC_DEFINE(HAVE_ACQUIREIMAGE,1, - [define if your magick has AcquireImage.])) + AC_CHECK_FUNCS([InheritException AcquireExceptionInfo SetImageProperty SetImageExtent AcquireImage GetVirtualPixels ResetImageProfileIterator ResetImageAttributeIterator ResetImagePropertyIterator MagickCoreGenesis SetImageOption BlobToStringInfo]) LIBS="$save_LIBS" fi if test x"$magick6" = x"yes"; then - # more recent magick6s have SetImageExtent - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(SetImageExtent, - AC_DEFINE(HAVE_SETIMAGEEXTENT,1, - [define if your magick has SetImageExtent.])) - LIBS="$save_LIBS" -fi + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $MAGICK_CFLAGS" -if test x"$magick6" = x"yes"; then - # GM uses SetImageAttribute(), IM uses SetImageProperty() - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(SetImageProperty, - AC_DEFINE(HAVE_SETIMAGEPROPERTY,1, - [define if your magick has SetImageProperty.])) - LIBS="$save_LIBS" -fi + # the range of ColorspaceType has expanded several times + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [ColorspaceType colorspace = CMYColorspace] + )], + [AC_DEFINE(HAVE_CMYCOLORSPACE,1, + [define if your Magick has CMYColorspace.]) + ] + ) -if test x"$magick6" = x"yes"; then - # IM uses SetImageProfile() with StringInfo - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(BlobToStringInfo, - AC_DEFINE(HAVE_BLOBTOSTRINGINFO,1, - [define if your magick has BlobToStringInfo().])) - LIBS="$save_LIBS" -fi + # GetImageMagick() takes two args under GM, three under IM + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [(void)GetImageMagick(NULL, 0, NULL)] + )], + [AC_DEFINE(HAVE_GETIMAGEMAGICK3,1, + [define if your GetImageMagick() takes three arguments.]) + ] + ) -if test x"$magick6" = x"yes"; then - # GM is missing InheritException - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(InheritException, - AC_DEFINE(HAVE_INHERITEXCEPTION,1, - [define if your magick has InheritException.])) - LIBS="$save_LIBS" -fi - -if test x"$magick6" = x"yes"; then - # GM is missing AcquireExceptionInfo - save_LIBS="$LIBS" - LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(AcquireExceptionInfo, - AC_DEFINE(HAVE_ACQUIREEXCEPTIONINFO,1, - [define if your magick has AcquireExceptionInfo.])) - LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" fi # have flags to turn load and save off independently ... some people will want diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index 9cb54d43..e1327d87 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -278,7 +278,7 @@ magick_set_profile( Image *image, string = BlobToStringInfo( data, length ); result = SetImageProfile( image, name, string ); DestroyStringInfo( string ); -#else /*HAVE_BLOBTOSTRINGINFO*/ +#else /*!HAVE_BLOBTOSTRINGINFO*/ result = SetImageProfile( image, name, data, length ); #endif /*HAVE_BLOBTOSTRINGINFO*/ @@ -410,16 +410,32 @@ typedef struct _MagickColorspaceTypeNames { static MagickColorspaceTypeNames magick_colorspace_names[] = { { UndefinedColorspace, "UndefinedColorspace" }, - { CMYColorspace, "CMYColorspace" }, { CMYKColorspace, "CMYKColorspace" }, { GRAYColorspace, "GRAYColorspace" }, + { HSLColorspace, "HSLColorspace" }, + { HWBColorspace, "HWBColorspace" }, + { OHTAColorspace, "OHTAColorspace" }, + { Rec601YCbCrColorspace, "Rec601YCbCrColorspace" }, + { Rec709YCbCrColorspace, "Rec709YCbCrColorspace" }, + { RGBColorspace, "RGBColorspace" }, + { sRGBColorspace, "sRGBColorspace" }, + { TransparentColorspace, "TransparentColorspace" }, + { XYZColorspace, "XYZColorspace" }, + { YCbCrColorspace, "YCbCrColorspace" }, + { YCCColorspace, "YCCColorspace" }, + { YIQColorspace, "YIQColorspace" }, + { YPbPrColorspace, "YPbPrColorspace" }, + { YUVColorspace, "YUVColorspace" }, + + /* More recent imagemagicks add these. + */ +#ifdef HAVE_CMYCOLORSPACE + { CMYColorspace, "CMYColorspace" }, { HCLColorspace, "HCLColorspace" }, { HCLpColorspace, "HCLpColorspace" }, { HSBColorspace, "HSBColorspace" }, { HSIColorspace, "HSIColorspace" }, - { HSLColorspace, "HSLColorspace" }, { HSVColorspace, "HSVColorspace" }, - { HWBColorspace, "HWBColorspace" }, { LabColorspace, "LabColorspace" }, { LCHColorspace, "LCHColorspace" }, { LCHabColorspace, "LCHabColorspace" }, @@ -427,23 +443,12 @@ static MagickColorspaceTypeNames magick_colorspace_names[] = { { LogColorspace, "LogColorspace" }, { LMSColorspace, "LMSColorspace" }, { LuvColorspace, "LuvColorspace" }, - { OHTAColorspace, "OHTAColorspace" }, - { Rec601YCbCrColorspace, "Rec601YCbCrColorspace" }, - { Rec709YCbCrColorspace, "Rec709YCbCrColorspace" }, - { RGBColorspace, "RGBColorspace" }, { scRGBColorspace, "scRGBColorspace" }, - { sRGBColorspace, "sRGBColorspace" }, - { TransparentColorspace, "TransparentColorspace" }, { xyYColorspace, "xyYColorspace" }, - { XYZColorspace, "XYZColorspace" }, - { YCbCrColorspace, "YCbCrColorspace" }, - { YCCColorspace, "YCCColorspace" }, { YDbDrColorspace, "YDbDrColorspace" }, - { YIQColorspace, "YIQColorspace" }, - { YPbPrColorspace, "YPbPrColorspace" }, - { YUVColorspace, "YUVColorspace" } +#endif /*HAVE_CMYCOLORSPACE*/ - /* More recent imagemagicks add these. + /* im7 has this, I think * { LinearGRAYColorspace, "LinearGRAYColorspace" } * @@ -645,6 +650,12 @@ magick_set_magick_profile( Image *image, */ gboolean magick_ismagick( const unsigned char *bytes, size_t length ) +{ + magick_genesis(); + + /* Try with our custom sniffers first. + */ +#ifdef HAVE_GETIMAGEMAGICK3 { #ifdef HAVE_MAGICK7 char format[MagickPathExtent]; @@ -652,12 +663,15 @@ magick_ismagick( const unsigned char *bytes, size_t length ) char format[MaxTextExtent]; #endif - magick_genesis(); - - /* Try with our custom sniffers first. - */ return( magick_sniff( bytes, length ) || GetImageMagick( bytes, length, format ) ); } +#else /*!HAVE_GETIMAGEMAGICK3*/ + /* The GM one returns a static string. + */ + return( magick_sniff( bytes, length ) || + GetImageMagick( bytes, length ) ); +#endif +} #endif /*HAVE_MAGICK*/ diff --git a/test/test-suite/helpers/helpers.py b/test/test-suite/helpers/helpers.py index 09cc3b47..f254bd16 100644 --- a/test/test-suite/helpers/helpers.py +++ b/test/test-suite/helpers/helpers.py @@ -21,9 +21,9 @@ FITS_FILE = os.path.join(IMAGES, "WFPC2u5780205r_c0fx.fits") OPENSLIDE_FILE = os.path.join(IMAGES, "CMU-1-Small-Region.svs") PDF_FILE = os.path.join(IMAGES, "ISO_12233-reschart.pdf") CMYK_PDF_FILE = os.path.join(IMAGES, "cmyktest.pdf") -SVG_FILE = os.path.join(IMAGES, "vips-profile.svg") -SVGZ_FILE = os.path.join(IMAGES, "vips-profile.svgz") -SVG_GZ_FILE = os.path.join(IMAGES, "vips-profile.svg.gz") +SVG_FILE = os.path.join(IMAGES, "logo.svg") +SVGZ_FILE = os.path.join(IMAGES, "logo.svgz") +SVG_GZ_FILE = os.path.join(IMAGES, "logo.svg.gz") GIF_ANIM_FILE = os.path.join(IMAGES, "cogs.gif") DICOM_FILE = os.path.join(IMAGES, "dicom_test_image.dcm") BMP_FILE = os.path.join(IMAGES, "MARBLES.BMP") diff --git a/test/test-suite/images/logo.svg b/test/test-suite/images/logo.svg new file mode 100644 index 00000000..b378eb1d --- /dev/null +++ b/test/test-suite/images/logo.svg @@ -0,0 +1,31 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/test/test-suite/images/logo.svg.gz b/test/test-suite/images/logo.svg.gz new file mode 100644 index 00000000..62bfce65 Binary files /dev/null and b/test/test-suite/images/logo.svg.gz differ diff --git a/test/test-suite/images/logo.svgz b/test/test-suite/images/logo.svgz new file mode 100644 index 00000000..62bfce65 Binary files /dev/null and b/test/test-suite/images/logo.svgz differ diff --git a/test/test-suite/images/vips-profile.svg b/test/test-suite/images/vips-profile.svg deleted file mode 100644 index a9c3f016..00000000 --- a/test/test-suite/images/vips-profile.svg +++ /dev/null @@ -1,2011 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/test-suite/images/vips-profile.svg.gz b/test/test-suite/images/vips-profile.svg.gz deleted file mode 100644 index 8ccb610f..00000000 Binary files a/test/test-suite/images/vips-profile.svg.gz and /dev/null differ diff --git a/test/test-suite/images/vips-profile.svgz b/test/test-suite/images/vips-profile.svgz deleted file mode 100644 index 8ccb610f..00000000 Binary files a/test/test-suite/images/vips-profile.svgz and /dev/null differ diff --git a/test/test-suite/test_foreign.py b/test/test-suite/test_foreign.py index b260705a..f91d7d51 100644 --- a/test/test-suite/test_foreign.py +++ b/test/test-suite/test_foreign.py @@ -388,9 +388,9 @@ class TestForeign: self.buffer_loader("magickload_buffer", BMP_FILE, bmp_valid) # we should have rgb or rgba for svg files ... different versions of - # IM handle this differently + # IM handle this differently. GM even gives 1 band. im = pyvips.Image.magickload(SVG_FILE) - assert im.bands == 3 or im.bands == 4 + assert im.bands == 3 or im.bands == 4 or im.bands == 1 # density should change size of generated svg im = pyvips.Image.magickload(SVG_FILE, density='100') @@ -454,10 +454,10 @@ class TestForeign: assert self.colour.height == x.height assert self.colour.bands == x.bands max_diff = (self.colour - x).abs().max() - assert max_diff < 40 + assert max_diff < 60 self.save_load_buffer("magicksave_buffer", "magickload_buffer", - self.colour, 40, format="JPG") + self.colour, 60, format="JPG") @skip_if_no("webpload") def test_webp(self): @@ -644,15 +644,9 @@ class TestForeign: def test_svgload(self): def svg_valid(im): a = im(10, 10) - - # some old rsvg versions are way, way off - assert abs(a[0] - 79) < 2 - assert abs(a[1] - 79) < 2 - assert abs(a[2] - 132) < 2 - assert abs(a[3] - 255) < 2 - - assert im.width == 288 - assert im.height == 470 + assert_almost_equal_objects(a, [0, 0, 0, 0]) + assert im.width == 736 + assert im.height == 552 assert im.bands == 4 self.file_loader("svgload", SVG_FILE, svg_valid)