PHP MagickWand Examples
example 1
$file='test.pdf';
$ext='PNG' ;
$w = NewMagickWand();
MagickSetResolution( $w, 200, 200 );
MagickReadImage( $w, $file );
MagickSetImageFormat( $w, $ext );
header( 'Content-Type: image/' . $ext );
MagickEchoImageBlob( $w );
$ext='PNG' ;
$w = NewMagickWand();
MagickSetResolution( $w, 200, 200 );
MagickReadImage( $w, $file );
MagickSetImageFormat( $w, $ext );
header( 'Content-Type: image/' . $ext );
MagickEchoImageBlob( $w );
example 2
$magickWand = NewMagickWand();
$drawingWand = NewDrawingWand();
$pixelWand = NewPixelWand();
MagickReadImageBlob(
$magickWand,
$url)
);
$src_w = MagickGetImageWidth($magickWand);
$src_h = MagickGetImageHeight($magickWand);
PixelSetColor($pixelWand, "black");
DrawSetStrokeColor($drawingWand, $pixelWand);
DrawSetStrokeWidth($drawingWand, 5);
DrawSetFillOpacity($drawingWand, 0);
DrawRectangle($drawingWand,0,0,$src_w,$src_h);
MagickDrawImage($magickWand,$drawingWand);
PixelSetColor($pixelWand, "white");
DrawSetFillColor($drawingWand ,$pixelWand);
DrawSetFillOpacity($drawingWand, 0.20);
PixelSetColor($pixelWand, "green");
DrawSetStrokeColor($drawingWand ,$pixelWand);
DrawSetStrokeWidth($drawingWand, 5);
$xratio = $src_w/$w;
$yratio = $src_h/$h;
DrawRectangle($drawingWand,$x1,$y1,$x2,$y2);
MagickDrawImage($magickWand,$drawingWand);
PixelSetColor($pixelWand, "red");
DrawSetStrokeColor($drawingWand ,$pixelWand);
DrawSetStrokeWidth($drawingWand, 3);
DrawRectangle($drawingWand,$x1,$y1,$x2,$y2);
MagickDrawImage($magickWand,$drawingWand);
MagickResizeImage($magickWand,
250, 250 / ($src_w / $src_h),
MW_CubicFilter, 0.75);
MagickSetImageFormat($magickWand, 'PNG');
header('Content-type: image/png');
MagickEchoImageBlob($magickWand);
$drawingWand = NewDrawingWand();
$pixelWand = NewPixelWand();
MagickReadImageBlob(
$magickWand,
$url)
);
$src_w = MagickGetImageWidth($magickWand);
$src_h = MagickGetImageHeight($magickWand);
PixelSetColor($pixelWand, "black");
DrawSetStrokeColor($drawingWand, $pixelWand);
DrawSetStrokeWidth($drawingWand, 5);
DrawSetFillOpacity($drawingWand, 0);
DrawRectangle($drawingWand,0,0,$src_w,$src_h);
MagickDrawImage($magickWand,$drawingWand);
PixelSetColor($pixelWand, "white");
DrawSetFillColor($drawingWand ,$pixelWand);
DrawSetFillOpacity($drawingWand, 0.20);
PixelSetColor($pixelWand, "green");
DrawSetStrokeColor($drawingWand ,$pixelWand);
DrawSetStrokeWidth($drawingWand, 5);
$xratio = $src_w/$w;
$yratio = $src_h/$h;
DrawRectangle($drawingWand,$x1,$y1,$x2,$y2);
MagickDrawImage($magickWand,$drawingWand);
PixelSetColor($pixelWand, "red");
DrawSetStrokeColor($drawingWand ,$pixelWand);
DrawSetStrokeWidth($drawingWand, 3);
DrawRectangle($drawingWand,$x1,$y1,$x2,$y2);
MagickDrawImage($magickWand,$drawingWand);
MagickResizeImage($magickWand,
250, 250 / ($src_w / $src_h),
MW_CubicFilter, 0.75);
MagickSetImageFormat($magickWand, 'PNG');
header('Content-type: image/png');
MagickEchoImageBlob($magickWand);
REFERRERS
MagickWand