"Resize" SVG (setResolution) without scaling stroke
Posted: 2009-08-05T18:11:27-07:00
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
$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