Update ImageMagick support to API version 7

pull/1/head
Andreas Eversberg 5 years ago
parent 3b81007210
commit 3438402fe2
  1. 2
      configure.ac
  2. 22
      src/libimage/img.c
  3. 2
      src/tv/main.c

@ -35,7 +35,7 @@ AC_ARG_WITH([imagemagick], [AS_HELP_STRING([--with-imagemagick], [compile with I
AS_IF([test "x$with_alsa" != xno], [PKG_CHECK_MODULES(ALSA, alsa >= 1.0, with_alsa=yes, with_alsa=no)])
AS_IF([test "x$with_uhd" != xno], [PKG_CHECK_MODULES(UHD, uhd >= 3.0.0, with_sdr=yes with_uhd=yes, with_uhd=no)])
AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.6.0, with_sdr=yes with_soapy=yes, with_soapy=no)])
AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick >= 6.0.0, with_imagemagick=yes, with_imagemagick=no)])
AS_IF([test "x$with_imagemagick" != xno], [PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick >= 7.0.0, with_imagemagick=yes, with_imagemagick=no)])
AM_CONDITIONAL(HAVE_ALSA, test "x$with_alsa" == "xyes" )
AM_CONDITIONAL(HAVE_UHD, test "x$with_uhd" == "xyes" )
AM_CONDITIONAL(HAVE_SOAPY, test "x$with_soapy" == "xyes" )

@ -6,24 +6,24 @@
int save_depth = 16;
#ifdef HAVE_MAGICK
#include <magick/api.h>
#include <MagickCore/MagickCore.h>
/* load given image to memory. return short RGB values */
unsigned short *load_img(int *width, int *height, const char *filename, int index)
{
Image *image = NULL;
ImageInfo *imageinfo = NULL;
ExceptionInfo exception;
ExceptionInfo *exception;
unsigned short *img = NULL;
MagickCoreGenesis(NULL, MagickFalse);
// InitializeMagick(NULL);
imageinfo = CloneImageInfo(0);
GetExceptionInfo(&exception);
exception = AcquireExceptionInfo();
sprintf(imageinfo->filename, filename, index);
image = ReadImage(imageinfo, &exception);
image = ReadImage(imageinfo, exception);
if (!image) {
// printf("failed to read image '%s' via *magick\n", filename);
goto exit;
@ -48,6 +48,9 @@ exit:
if (imageinfo)
DestroyImageInfo(imageinfo);
if (exception)
DestroyExceptionInfo(exception);
MagickCoreTerminus();
// DestroyMagick();
@ -60,18 +63,18 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char *
int rc = -1;
Image *image = NULL;
ImageInfo *imageinfo = NULL;
ExceptionInfo exception;
ExceptionInfo *exception;
MagickCoreGenesis(NULL, MagickFalse);
// InitializeMagick(NULL);
imageinfo = CloneImageInfo(0);
GetExceptionInfo(&exception);
exception = AcquireExceptionInfo();
imageinfo->quality = 100;
if (strlen(filename) >= 4 && !strcmp(filename + strlen(filename) - 4, ".png"))
imageinfo->quality = 1;
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, &exception);
image=ConstituteImage(width, height, (alpha)?"RGBA":"RGB", ShortPixel, img, exception);
if (!image) {
printf("%s:failed to prepare to write image\n", __func__);
goto exit;
@ -81,7 +84,7 @@ int save_img(unsigned short *img, int width, int height, int alpha, const char *
image->depth = save_depth;
sprintf(image->filename, filename, index); /* ACHTUNG: nicht imageinfo!!! */
if (!WriteImage(imageinfo, image)) {
if (!WriteImage(imageinfo, image, exception)) {
printf("%s:failed to write image\n", __func__);
goto exit;
}
@ -95,6 +98,9 @@ exit:
if (imageinfo)
DestroyImageInfo(imageinfo);
if (exception)
DestroyExceptionInfo(exception);
MagickCoreTerminus();
// DestroyMagick();

@ -377,7 +377,7 @@ static int tx_img(const char *filename)
img = load_img(&width, &height, filename, 0);
if (!img) {
fprintf(stderr, "Failed to load grey image '%s'\n", filename);
fprintf(stderr, "Failed to load image '%s'\n", filename);
return -1;
}

Loading…
Cancel
Save