I am wondering if anyone know how to prevent strokes from being scaled when using setResolution. I guess I am looking for the equivalent of Illustrator's "Scale Strokes and Effects" option - I want to be able to turn it off because a hairline stroke becomes quite thick and ugly when I use this code to convert:
$im = new Imagick();
$im->readImage(imagick_path($path_to_image));
$res = $im->getImageResolution();
$x_ratio = $res['x'] / $im->getImageWidth();
$y_ratio = $res['y'] / $im->getImageHeight();
$im->removeImage();
$im->setResolution(300 * $x_ratio, 300 * $y_ratio);
$im->readImage(imagick_path($path_to_image));
$im->writeImage(imagick_path($path_to_preview));
$im->clear();
$im->destroy();
Thanks,
Adrian
"Resize" SVG (setResolution) without scaling stroke
"Resize" SVG (setResolution) without scaling stroke
Last edited by adrianj on 2009-08-07T15:34:52-07:00, edited 1 time in total.
Re: SVG to PNG conversion scale stroke
Hate to bump, but bumping my other post just got me the exact answer I needed
"Resize"SVG with Imagick::setResolution() depends on version
Hi,
Imagick::setResolution() after removing and followed by rereading an image was indeed a solution for me, to resize SVG-graphics without the need of scaling with interpolation.
It WAS with
PHP 5.2.xx, ImageMagick-6.4.5 or ImageMagick-6.5.1 and php-imagick-2.2.2
However this procedure did not work with
PHP 5.2.xx, ImageMagick-6.4.5 or ImageMagick-6.5.1 and php-imagick-2.2.1
Now I have the problem, that I updated to
PHP 5.3.1
ImageMagick-6.5.8
php-imagick-2.3.0
and this procedure is not applicable for SVG anymore.
(However this resizing procedure works with PDF, PS, EPS perfectly, independent of the tried versions!)
Does anybody have any other good idea to get the same functionality as "convert -density" with php5-imagick? What is the provided way to resize SVG-Images?
Thanks for your help and comments!
Barpfotenbaer
Imagick::setResolution() after removing and followed by rereading an image was indeed a solution for me, to resize SVG-graphics without the need of scaling with interpolation.
It WAS with
PHP 5.2.xx, ImageMagick-6.4.5 or ImageMagick-6.5.1 and php-imagick-2.2.2
However this procedure did not work with
PHP 5.2.xx, ImageMagick-6.4.5 or ImageMagick-6.5.1 and php-imagick-2.2.1
Now I have the problem, that I updated to
PHP 5.3.1
ImageMagick-6.5.8
php-imagick-2.3.0
and this procedure is not applicable for SVG anymore.
(However this resizing procedure works with PDF, PS, EPS perfectly, independent of the tried versions!)
Does anybody have any other good idea to get the same functionality as "convert -density" with php5-imagick? What is the provided way to resize SVG-Images?
Thanks for your help and comments!
Barpfotenbaer
Re: "Resize" SVG (setResolution) without scaling stroke
I am also having problems scaling SVG without first rasterizing. The method mentioned above definitely does not work using Imagick 6.6.1 and PHP 5.2.13. Any help with the appropriate means to approximate "convert -density" correctly would be greatly appreciated.