Multi-page PDF

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
watson

Post by watson »

Code: Select all

MagickEchoImagesBlob($w);
is your problem; you used MagickEchoImageSBlob() instead of MagickEchoImageBlob() (no "s"). The former echoes the MagickWand's blob, while the latter echoes the blob of the current active image in the MagickWand.

In the MagickWand API, if you set a MagickWand's image format, when you retrieve the MagickWand's blob (or write it), the operation obeys the rules of that format.

If the MagickWand contains multiple images, and you set the MagickWand's format to a multi-frame image capable format (like GIF or PDF), then all the frames are echoed/written as the multi-frame image; if however, the format is not multi-frame image capable (like JPEG), then the first image in the MagickWand is echoed/written.

Instead of setting individual image atributes, and retrieving the individual Images, you have set the MagickWand's attributes, and retrieved the MagickWand's blob.

Change

Code: Select all

MagickSetFormat($w, 'JPG');
to

Code: Select all

MagickSetImageFormat($w, 'JPG');
and change

Code: Select all

MagickEchoImagesBlob($w);
to

Code: Select all

MagickEchoImageBlob($w);
Post your results.
watson

Post by watson »

If you are seeking to control how PDF (and all vector formats for that matter) are rendered/rasterized, then

Code: Select all

MagickSetResolution($wnd, $x_res, $y_res);
MagickSetSize($wnd, $img_w, $img_h);
are what you are looking for.

Call the above BEFORE reading in the image with MagickReadImage() and its ilk.
Post Reply