note 110703 added to imagick.writeimage

From: Date: Sat, 24 Nov 2012 17:47:50 +0000
Subject: note 110703 added to imagick.writeimage
Groups: php.notes 
Request: Send a blank email to php-notes+get-192131@lists.php.net to get a copy of this message
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). ---- Server IP: 69.147.83.199 Probable Submitter: 85.171.205.231 ---- Manual Page -- http://www.php.net/manual/en/imagick.writeimage.php Edit -- https://master.php.net/note/edit/110703 Del: integrated -- https://master.php.net/note/delete/110703/integrated Del: useless -- https://master.php.net/note/delete/110703/useless Del: bad code -- https://master.php.net/note/delete/110703/bad+code Del: spam -- https://master.php.net/note/delete/110703/spam Del: non-english -- https://master.php.net/note/delete/110703/non-english Del: in docs -- https://master.php.net/note/delete/110703/in+docs Del: other reasons-- https://master.php.net/note/delete/110703 Reject -- https://master.php.net/note/reject/110703 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192131) next »