php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59378 Imagick::writeImageFile can't write whole data using php://memory output stream
Submitted: 2010-08-20 14:50 UTC Modified: 2015-01-25 04:22 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: karateka2000 at gmail dot com Assigned: mkoppanen (profile)
Status: No Feedback Package: imagick (PECL)
PHP Version: 5.2.11 OS: CentOS 5.5 x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: karateka2000 at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-20 14:50 UTC] karateka2000 at gmail dot com
Description:
------------
"Imagick::writeImageFile" works properly if the file handler is created from usual filesystems.
And, using file handler from other stream wrappers (i.e. php://memory , php://temp), it works, but not complete.

I tried some type of images (gif, jpeg, and png), the image cut off the bottom in all cases.

Reproduce code:
---------------
<?php
$im = new Imagick();
$im->readImage('test.jpg');
$fp = fopen("php://memory", 'r+');
$im->writeImageFile($fp);
rewind($fp);
$out = stream_get_contents($fp);
fclose($fp);
header("Content-type: image/jpeg");
echo $out;
?>

Expected result:
----------------
the browser shows the image same as "test.jpg". 

Actual result:
--------------
the browser shows half or more topside part of "test.jpg".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-18 04:09 UTC] mkoppanen@php.net
I can reproduce this and will look into it.
 [2011-12-15 18:41 UTC] neel dot basu dot z at gmail dot com
Confirmed. This bellow code should produce base64encoded thumb data. but it 
produces an empty string

$image = new Imagick($destPath);
$image->thumbnailimage(0, 250);
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(70);
$image->stripImage();
$handle = fopen("php://memory", "rw+");
$image->writeImageFile($handle);
fseek($handle, 0);
$base64Thumb = base64_encode(stream_get_contents($handle));
fclose($handle);
var_dump($base64Thumb);
 [2013-12-03 11:35 UTC] mike@php.net
-Assigned To: +Assigned To: mkoppanen
 [2015-01-15 19:50 UTC] danack@php.net
-Status: Verified +Status: Feedback
 [2015-01-15 19:50 UTC] danack@php.net
Hi,

I can't reproduce this on a supported version of PHP. Please can you test again with a supported version.

I've also added a test to hopefully spot if it should occur again:
https://github.com/mkoppanen/imagick/pull/61
 [2015-01-25 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:21 2019 UTC