EPS Vector in - EPS Vector out?

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
ChrisM

EPS Vector in - EPS Vector out?

Post by ChrisM »

With MagickWand for PHP, is it possible to read in a vector based EPS file (created in Adobe Illustrator), add some text to the image, and then output the whole thing in vector format?

I'm struggling to get my head around the techniques involved and am trying to adapt the original MagickWand example. Here's the code I have so far:

Code: Select all

<?php

$font_file = '100.ttf';
$photo_file = 'test.eps';

$magick_wand=NewMagickWand();
MagickSetFormat($magick_wand, 'eps');
MagickReadImage($magick_wand,$photo_file);

$drawing_wand=NewDrawingWand();

DrawSetFont($drawing_wand,"$font_file");
DrawSetFontSize($drawing_wand,100);
DrawSetGravity($drawing_wand,MW_CenterGravity);
$pixel_wand=NewPixelWand();
PixelSetColor($pixel_wand,"#c0c0c0");
DrawSetFillColor($drawing_wand,$pixel_wand);

if (!IsDrawingWand($drawing_wand)) echo "\$drawing_wand is not a DrawingWand resource";

if (MagickAnnotateImage($magick_wand,$drawing_wand,0,0,0,"Rose") != 0) {
	header('Content-type: image/eps');
	header('Content-Disposition: attachment; filename="vector_test.eps"');
	MagickEchoImageBlob( $magick_wand );
} else {
	echo "Exception: " . MagickGetExceptionString($magick_wand);
}
?>
This works, but produces a non-vector image which looks much like a low quality JPEG/GIF. Can anyone help or point me in the right direction?

Thanks in advance.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: EPS Vector in - EPS Vector out?

Post by magick »

ImageMagick rasterizes vector files into pixels. For vector-in to vector-out you will need to use some other application.
ChrisM

Re: EPS Vector in - EPS Vector out?

Post by ChrisM »

Thanks for clarifying that. Any suggestions on what other software I can use to output vector-based EPS images with PHP?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: EPS Vector in - EPS Vector out?

Post by anthony »

See A Word about Vector Image Formats, which also includes links to alternatives.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply