【发布时间】:2015-01-17 17:29:46
【问题描述】:
我使用 Imagick 打开图像、调整大小、设置图像格式(如果需要)并将结果写入另一个文件夹。它适用于 ICO 和 PNG,但 无法编写 SVG 文件,说是
ImagickException: 无法写入文件:C:\Sites\devdesktop\test\sites\default\files\tempimages\abstract-spiral-striped-background-100.svg in Imagick->writeimage() ( C:\Sites\devdesktop\test\sites\all\modules\testmodule\testmodule.module 的第 44 行)。
这是来自 Drupal 7 的错误消息。
这是我的代码:
$file = file_load($form_state['values']['fid']);
$image = new Imagick(drupal_realpath($file->uri));
$image->setImageFormat($type[$type_num]);
$image->resizeImage($size[$size_num], $size[$size_num], Imagick::FILTER_UNDEFINED, 1);
$destination = 'public://tempimages/'.substr($file->filename, 0, -4).'-'.$size[$size_num].'.'.$type[$type_num];
$image->writeImage(drupal_realpath($destination)); //<---problem
drupal_goto(base_path().'/sites/default/files/tempimages/'.substr($file->filename, 0, -4).'-'.$size[$size_num].'.'.$type[$type_num]);
这段代码 sn-p 可以完美地与 ICO 和 PNG 一起工作,但不要编写 SVG 格式的文件,除非代码有点和平
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="200" height="200">
<g style="</svg>
为什么会这样?
【问题讨论】:
标签: php image-processing svg imagemagick imagick