Imagick
在线手册:中文  英文

Imagick::writeImage

(PECL imagick 0.9.0-0.9.9)

Imagick::writeImageWrites an image to the specified filename

说明

bool Imagick::writeImage ([ string $filename ] )

Writes an image to the specified filename. If the filename parameter is NULL, the image is written to the filename set by Imagick::ReadImage() or Imagick::SetImageFilename().

参数

filename

返回值

成功时返回 TRUE


Imagick
在线手册:中文  英文

用户评论:

abcrdw at gmail dot com (2013-06-06 12:14:34)

If you also want to output the image to the browser:

<?php
$img 
= new Imagick();
$img->readImage('test.jpp');
$img->writeImage('test.jpg');       // Write to disk
ob_clean();                         // Clear buffer
header('Content-Type: image/jpeg'); // Send JPEG header
echo $img;                          // Output to browser
$img->destroy();
?>

pfz at pfzone dot org (2012-11-24 17:47:48)

With Imagick 3.1.0RC2, PHP4.8
If you plan to overwrite the file you're working on, before doing writeImage, consider clearing the file buffer before the write statement : 

<?php
$image 
= new Imagick($your_file);
/* some processing */

clearstatcache(dirname($your_file));
// or
unlink($your_file);
$image->writeImage($your_file);
?>
It happened to me that the resulting file size was wrong. This could lead to truncation, as the file is not expanded.
This happened while working on JPEG, and PNG. 

this line worked for me without this hack. 
<?php
file_put_contents
($your_file$image);
?>

Do not rely on getImageLength() for sending your image, especially when keepalive is ON. Content length is then relevant, and must be set. If the wrong size is given, your image will be truncated.
Use filesize($your_file_) once written or strlen($image) instead (which renders your image and updates getImageLength() result).

icinagle at gmail dot com (2011-05-23 18:47:01)

If you are trying to manipulate a uploaded file and then save the file all in the same request with Apache + mod_dav this will fail.
mod_dav puts a lock on the file during the request where the file is uploaded so trying to save the smallest file, e.g. 1kb will fail with a "Failed to allocate memory" error.

http://aotd.ru (2008-04-19 04:12:35)

$thumb = new Imagick();
$thumb->readImage('test.gif');
$thumb->writeImage('test.jpg');
$thumb->clear();
$thumb->destroy();

易百教程