Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Test PHP bug #59378 writing to php://temp is incomplete --SKIPIF-- <?php require_..

Decoded Output download

--TEST--
Test PHP bug #59378 writing to php://temp is incomplete
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$imagick = new Imagick();
$imagick->newPseudoImage(640, 480, "LOGO:");
$imagick->setFormat("png");

// Although the bug was about php://memory, that isn'--TEST--
// available to use as a filehandle on Windows, so may as well
// just test php://temp instead.
$fp = fopen("php://temp", 'r+');
$imagick->writeImageFile($fp);
rewind($fp);
$memoryBlob = stream_get_contents($fp);
fclose($fp);

//This test depends on getImageBlob working correctly.
$imageBlob = $imagick->getImageBlob();

//Read the images from the data blobs.
$imageReopened = new Imagick();
$imageReopened->readImageBlob($imageBlob);
$memoryReopened = new Imagick();
$memoryReopened->readImageBlob($memoryBlob);

//Compare to see if they are identical.
$result = $imageReopened->compareImages($memoryReopened, \Imagick::METRIC_MEANABSOLUTEERROR);

if ($result[1] == 0) {
    echo "Reopened images are identical.";
}
else {
    echo "Error, reopened images have changed.";
    var_dump($result);
}

?>
--EXPECTF--
Reopened images are identical.

Did this file decode correctly?

Original Code

--TEST--
Test PHP bug #59378 writing to php://temp is incomplete
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$imagick = new Imagick();
$imagick->newPseudoImage(640, 480, "LOGO:");
$imagick->setFormat("png");

// Although the bug was about php://memory, that isn'--TEST--
// available to use as a filehandle on Windows, so may as well
// just test php://temp instead.
$fp = fopen("php://temp", 'r+');
$imagick->writeImageFile($fp);
rewind($fp);
$memoryBlob = stream_get_contents($fp);
fclose($fp);

//This test depends on getImageBlob working correctly.
$imageBlob = $imagick->getImageBlob();

//Read the images from the data blobs.
$imageReopened = new Imagick();
$imageReopened->readImageBlob($imageBlob);
$memoryReopened = new Imagick();
$memoryReopened->readImageBlob($memoryBlob);

//Compare to see if they are identical.
$result = $imageReopened->compareImages($memoryReopened, \Imagick::METRIC_MEANABSOLUTEERROR);

if ($result[1] == 0) {
    echo "Reopened images are identical.";
}
else {
    echo "Error, reopened images have changed.";
    var_dump($result);
}

?>
--EXPECTF--
Reopened images are identical.

Function Calls

dirname 1

Variables

None

Stats

MD5 d2eb37e87563eca6906b788bab9fea8d
Eval Count 0
Decode Time 90 ms