MagickSetImageFormat / MagickWriteImageFile
Posted: 2013-09-29T00:11:20-07:00
Hello,
following bug was reported against Imagick: Bug #64208 [Com]: writeImageFile does not respect setImageFormat (https://bugs.php.net/bug.php?id=64208)
It seems that this is not Imagick specific but can be reproduced with MagickWand API:
Output:
$ cc -o wand `pkg-config --cflags --libs MagickWand` wand.c
$ ./wand
Format: png
$ file out.png
out.png: JPEG image data, JFIF standard 1.01
following bug was reported against Imagick: Bug #64208 [Com]: writeImageFile does not respect setImageFormat (https://bugs.php.net/bug.php?id=64208)
It seems that this is not Imagick specific but can be reproduced with MagickWand API:
Code: Select all
#include <wand/MagickWand.h>
#include <assert.h>
int main () {
MagickBooleanType rc;
MagickWand *w = NewMagickWand ();
assert (w);
rc = MagickReadImage (w, "test.jpg");
assert (rc == MagickTrue);
FILE *fp = fopen ("out.png", "w+");
assert (fp);
rc = MagickSetImageFormat (w, "png");
assert (rc == MagickTrue);
char *format = MagickGetImageFormat (w);
fprintf (stderr, "Format: %s\n", format);
MagickRelinquishMemory (format);
rc = MagickWriteImageFile (w, fp);
assert (rc == MagickTrue);
fclose (fp);
return 0;
}
$ cc -o wand `pkg-config --cflags --libs MagickWand` wand.c
$ ./wand
Format: png
$ file out.png
out.png: JPEG image data, JFIF standard 1.01