| Current File : /home/mmdealscpanel/yummmdeals.com/alt-php83-pecl-imagick_3.8.0-7.el8.tar |
util/functions.php 0000644 00000020647 15041263517 0010257 0 ustar 00 <?php
// Mirrored from https://github.com/Danack/HexFloat
require_once __DIR__ . "/FloatInfo.php";
require_once __DIR__ . "/Float32Info.php";
use HexFloat\FloatInfo;
use HexFloat\Float32Info;
/**
* Returns a string containing a hexadecimal representation of the given float,
* using 64 bits of info
*
* @param float $number
* @return string
*/
function floathex(float $number)
{
return strrev(unpack('h*', pack('d', $number))[1]);
}
/**
* Returns a string containing a hexadecimal representation of the given float,
* using 32 bits of info
*
* @param float $number
* @return string
*/
function floathex32(float $num)
{
return strrev(unpack('h*', pack('f', $num))[1]);
}
/**
* Convert a floating point number to a FloatInfo object,
* which contains string representations of the float's sign,
* exponent and mantissa
* @param float $num
* @return FloatInfo
*/
function float_info(float $num)
{
$float64 = floathex($num);
//Sign bit: 1 bit
//Exponent: 11 bits
//Significand precision: 53 bits (52 explicitly stored)
$chars = str_split($float64);
// 3 bits from this
$byte1 = hexdec($chars[0]);
// 4 bits from this
$byte2 = hexdec($chars[1]);
// 1 bit from this
$byte3 = hexdec($chars[2]);
$sign = '0';
if ($byte1 >= 8) {
$sign = '1';
}
$exponentString = substr($float64, 0, 3);
$exponentValue = hexdec($exponentString) & 0x7ff;
$exponent = sprintf("%b", $exponentValue);
$exponent = str_pad($exponent, 11, '0', STR_PAD_LEFT);
$mantissa = substr($float64, 2);
$mantissa = hexdec($mantissa) & 0xfffffffffffff;
$mantissa = sprintf("%b", $mantissa);
$mantissa = str_pad($mantissa, 52, '0', STR_PAD_LEFT);
return new FloatInfo(
$sign,
$exponent,
$mantissa
);
}
/**
* Convert a floating point number to a Float32Info object,
* which contains string representations of the float's sign,
* exponent and mantissa
*
* @param float $num
* @return Float32Info
*/
function float_info_32(float $num)
{
$float32 = floathex32($num);
$chars = str_split($float32);
// 3 bits from this
$byte1 = hexdec($chars[0]);
// 4 bits from this
$byte2 = hexdec($chars[1]);
// 1 bit from this
$byte3 = hexdec($chars[2]);
$sign = '0';
if ($byte1 >= 8) {
$sign = '1';
}
$exponent3Bits = ($byte1 & 0x7);
$exponent4Bits = $byte2;
$exponent1Bit = ($byte3 & 0x8) >> 3;
$exponent = ($exponent3Bits << 5) | ($exponent4Bits << 1) | $exponent1Bit;
$exponent = sprintf("%b", $exponent);
$exponent = str_pad($exponent, 8, '0', STR_PAD_LEFT);
$mantissa = substr($float32, 2, 6);
$mantissa = hexdec($mantissa) & 0x7fffff;
$mantissa = sprintf("%b", $mantissa);
$mantissa = str_pad($mantissa, 23, '0', STR_PAD_LEFT);
return new Float32Info(
$sign,
$exponent,
$mantissa
);
}
/**
* Produce a debug string that shows the Sign, Exponent and Mantissa for
* two floating point numbers, using 64bit precision
*
*
* @param float $value1
* @param float $value2
* @return string
*
* Example result
* ┌──────┬─────────────┬──────────────────────────────────────────────────────┐
* │ Sign │ Exponent │ Mantissa │
* │ 0 │ 01111111011 │ 1001100110011001100110011001100110011001100110011010 │
* │ 0 │ 10000011001 │ 0111110101111000010000000100000000000000000000000000 │
* └──────┴─────────────┴──────────────────────────────────────────────────────┘
*
*/
function float_compare(float $value1, float $value2)
{
$float_info_1 = float_info($value1);
$float_info_2 = float_info($value2);
//Sign bit: 1 bit
//Exponent: 11 bits
//Significand precision: 53 bits (52 explicitly stored)
$output = "┌──────┬─────────────┬──────────────────────────────────────────────────────┐\n";
$output .= "│ Sign │ Exponent │ Mantissa │\n";
$format_string = "│ %s │ %s │ %s │\n";
$output .= sprintf($format_string, $float_info_1->getSign(), $float_info_1->getExponent(), $float_info_1->getMantissa());
$output .= sprintf($format_string, $float_info_2->getSign(), $float_info_2->getExponent(), $float_info_2->getMantissa());
$output .= "└──────┴─────────────┴──────────────────────────────────────────────────────┘\n";
return $output;
}
/**
* Produce a debug string that shows the Sign, Exponent and Mantissa for
* two floating point numbers, using 32bit precision
*
* @param float $value1
* @param float $value2
* @return string
*
* Example result
* ┌──────┬──────────┬─────────────────────────┐
* │ Sign │ Exponent │ Mantissa │
* │ 0 │ 01111011 │ 10011001100110011001101 │
* │ 0 │ 10011001 │ 01111101011110000100000 │
* └──────┴──────────┴─────────────────────────┘
*
*/
function float_compare_32(float $value1, float $value2)
{
$float_info_1 = float_info_32($value1);
$float_info_2 = float_info_32($value2);
$output = "┌──────┬──────────┬─────────────────────────┐\n";
$output .= "│ Sign │ Exponent │ Mantissa │\n";
$format_string = "│ %s │ %s │ %s │\n";
$output .= sprintf($format_string, $float_info_1->getSign(), $float_info_1->getExponent(), $float_info_1->getMantissa());
$output .= sprintf($format_string, $float_info_2->getSign(), $float_info_2->getExponent(), $float_info_2->getMantissa());
$output .= "└──────┴──────────┴─────────────────────────┘\n";
return $output;
}
/**
* So. One of the disadvantages of non-HDRI compiled Image Magick
* is that it can't accurately represent a '50%' color accurately.
*
* For example, if ImageMagick is compiled with 16bit color depth
* then the two closest colors to midpoint are:
* 32767 / 65535 = 0.5 - (1 / (2 ^ 17)) = 0.499992370...
* or
* 32768 / 65535 = 0.5 + (1 / (2 ^ 17)) = 0.50000762951
*
* Either way there is going to be 'error' of
* 0.00000762939453125
*
* The problem is even worse when ImageMagick is compiled with 8-bit
* numbers (though this really shouldn't be used any more) and the
* error would be 0.001953125
*
*/
function get_epsilon_for_off_by_half_errors()
{
// These could be defined better...
$epsilon_values_for_non_hdri = [
'255' => (1 / (pow(2, 8) - 1)) + 0.0000000000001,
'65535' => (1 / (pow(2, 16) - 1)) + 0.0000000000001,
'16777215' => (1 / (pow(2, 24) - 1) ) + 0.0000000000001,
'4294967295' => (1 / (pow(2, 32) - 1)) + 0.0000000000001,
];
// These could definitely be defined better...
$epsilon_values_for_hdri = [
'255' => 0.0000000000001,
'65535' => 0.0000000000001,
'16777215' => 0.0000000000001,
'4294967295' => 0.0000000000001
];
if (Imagick::getHdriEnabled() === false) {
$quantum = (string)Imagick::getQuantum();
if (array_key_exists($quantum, $epsilon_values_for_non_hdri) !== true) {
throw new Exception(
"Quantum values is $quantum which is not any of (2^(8|16|24|32)) - 1. Please report this as a bug."
);
}
return $epsilon_values_for_non_hdri[$quantum];
}
$quantum = Imagick::getQuantum();
if (array_key_exists($quantum, $epsilon_values_for_hdri) !== true) {
throw new Exception(
"Quantum values is $quantum which is not any of (2^(8|16|24|32)) - 1. Please report this as a bug."
);
}
return $epsilon_values_for_hdri[$quantum];
} util/fixup_arginfo.php 0000644 00000010301 15041263517 0011071 0 ustar 00 <?php
declare(strict_types = 1);
if ($argc !== 2) {
fwrite(STDERR, "usage php fixup_arginfo.php \$arginfo_filename\n");
exit(-1);
}
$filename = $argv[1];
$fixup_note = "file has been fixedup for different versions";
echo "Fixing $filename\n";
$input_lines = file($filename);
foreach ($input_lines as $input_line) {
if (strpos($input_line, $fixup_note) !== false) {
echo "File has already been fixedup.\n";
exit(0);
}
}
$output_lines = [];
$search = [];
$replace = [];
$search[] = "#.*Stub hash: (.*) .*/#iu";
$replace[] = "* Stub hash: regen with 'sh regen_arginfo.sh' \n* $fixup_note */";
$search[] = "#ZEND_ARG_OBJ_INFO\(0, (\w*), IMAGICK_QUANTUM_TYPE, 0\)#iu";
$replace[] = "
#if MAGICKCORE_HDRI_ENABLE
ZEND_ARG_TYPE_INFO(0, $1, IS_DOUBLE, 0)
#else
ZEND_ARG_TYPE_INFO(0, $1, IS_LONG, 0)
#endif
";
// ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
// ZEND_ARG_INFO(pass_by_ref, name)
$search[] = "#ZEND_ARG_TYPE_INFO\((\w*), (\w*), (\w*), (\w*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO($1, $2, $3, $4)
#else
ZEND_ARG_INFO($1, $2)
#endif";
$search[] = "#ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX\((\w*), 0, (\w*), IMAGICK_QUANTUM_TYPE, 0\)#iu";
$replace[] = "
#if MAGICKCORE_HDRI_ENABLE
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX($1, 0, $2, IS_DOUBLE, 0)
#else
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX($1, 0, $2, IS_LONG, 0)
#endif
";
//ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)
$search[] = "#ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX\((\w*), (\w*), (\w*), (\w*), (\w*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX($1, $2, $3, $4, $5)
#else
ZEND_BEGIN_ARG_INFO_EX($1, 0, $2, $3)
#endif
";
//#define ZEND_ARG_TYPE_MASK(pass_by_ref, name, type_mask, default_value) \
$search[] = "#.*ZEND_ARG_TYPE_MASK\(([\w|\|]*), ([\w|\|]*), ([\w|\|]*), ([\w\|\"]*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_MASK($1, $2, $3, $4)
#else
ZEND_ARG_INFO($1, $2)
#endif
";
//ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, required_num_args, type)
//ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)
$search[] = "#.*ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX\(([\w|\|]*), ([\w|\|]*), ([\w|\|]*), ([\w|\|]*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX($1, $2, $3, $4)
#else
ZEND_BEGIN_ARG_INFO_EX($1, 0, $2, $3)
#endif
";
//ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null)
$search[] = "#ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX\((\w*), (\w*), (\w*), (\w*), (\w*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX($1, $2, $3, $4, $5)
#else
ZEND_BEGIN_ARG_INFO_EX($1, 0, $2, $3)
#endif
";
//ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) \
$search[] = "#.*ZEND_ARG_OBJ_INFO\((\w*), (\w*), resource, (\w*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
\tZEND_ARG_OBJ_INFO($1, $2, resource, $3)
#else
\tZEND_ARG_INFO($1, $2)
#endif
";
// ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 1, "null")
$search[] = "#.*ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE\((\w*), (\w*), (\w*), (\w*), ([\w\"]*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE($1, $2, $3, $4, $5)
#else
ZEND_ARG_INFO($1, $2)
#endif
";
// ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, filename, "null")
$search[] = "#.*ZEND_ARG_INFO_WITH_DEFAULT_VALUE\((\w*), (\w*), ([\w\"]*)\)#iu";
$replace[] = "
#if PHP_VERSION_ID >= 80000
ZEND_ARG_INFO_WITH_DEFAULT_VALUE($1, $2, $3)
#else
ZEND_ARG_INFO($1, $2)
#endif
";
//#if PHP_VERSION_ID >= 80000
//ZEND_ARG_TYPE_MASK(0, files, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_NULL, NULL)
//#else
// ZEND_ARG_INFO(0, files)
//#endif
foreach ($input_lines as $input_line) {
$input_line = rtrim($input_line);
$input_line = preg_replace($search, $replace, $input_line);
$output_lines[] = $input_line;
}
file_put_contents($filename, implode("\n", $output_lines));
echo "File has now been fixedup.\n";
util/Float32Info.php 0000644 00000001341 15041263517 0010263 0 ustar 00 <?php
namespace HexFloat;
// Mirrored from https://github.com/Danack/HexFloat
class Float32Info
{
//Sign bit: 1 bit
private $sign;
//Exponent: 11 bits
private $exponent;
//Mantissa precision: 53 bits (52 explicitly stored)
private $mantissa;
public function __construct(
$sign,
$exponent,
$mantissa
) {
// TODO - check lengths
$this->sign = $sign;
$this->exponent = $exponent;
$this->mantissa = $mantissa;
}
public function getSign()
{
return $this->sign;
}
public function getExponent()
{
return $this->exponent;
}
public function getMantissa()
{
return $this->mantissa;
}
}
util/FloatInfo.php 0000644 00000001342 15041263517 0010117 0 ustar 00 <?php
namespace HexFloat;
// Mirrored from https://github.com/Danack/HexFloat
class FloatInfo
{
//Sign bit: 1 bit
private $sign;
//Exponent: 11 bits
private $exponent;
//Mantissa precision: 53 bits (52 explicitly stored)
private $mantissa;
public function __construct(
$sign,
$exponent,
$mantissa
) {
// TODO - check lengths
$this->sign = $sign;
$this->exponent = $exponent;
$this->mantissa = $mantissa;
}
public function getSign()
{
return $this->sign;
}
public function getExponent()
{
return $this->exponent;
}
public function getMantissa()
{
return $this->mantissa;
}
}
tests/306_Imagick_interpolativeResizeImage.phpt 0000644 00000001037 15041263517 0015636 0 ustar 00 --TEST--
Test Imagick, interpolativeResizeImage
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('interpolativeResizeImage'));
?>
--FILE--
<?php
function interpolativeResizeImage() {
$imagick = new \Imagick(__DIR__ . '/Biter_500.jpg');
$imagick->interpolativeResizeImage(
320,
200,
Imagick::INTERPOLATE_CATROM
);
// $imagick->writeImage(__DIR__ . '/claheImage_output_image.png');
$imagick->getImageBlob();
}
interpolativeResizeImage() ;
echo "Ok";
?>
--EXPECTF--
Ok
tests/159_Imagick_transformImage_basic.phpt 0000644 00000001143 15041263517 0014747 0 ustar 00 --TEST--
Test Imagick, transformImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('transformimage'));
?>
--FILE--
<?php
function transformimage() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$newImage = $imagick->transformImage("400x600", "200x300");
$bytes = $newImage->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
transformimage() ;
echo "Ok";
?>
--EXPECTF--
Deprecated: %s Imagick::transformImage() is deprecated in %s
Ok
tests/173_ImagickDraw_bezier_basic.phpt 0000644 00000004353 15041263517 0014071 0 ustar 00 --TEST--
Test ImagickDraw, bezier
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function bezier($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$strokeColor = new \ImagickPixel($strokeColor);
$fillColor = new \ImagickPixel($fillColor);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
$smoothPointsSet = array(
array(
array('x' => 10.0 * 5, 'y' => 10.0 * 5),
array('x' => 30.0 * 5, 'y' => 90.0 * 5),
array('x' => 25.0 * 5, 'y' => 10.0 * 5),
array('x' => 50.0 * 5, 'y' => 50.0 * 5),
),
array(
array('x' => 50.0 * 5, 'y' => 50.0 * 5),
array('x' => 75.0 * 5, 'y' => 90.0 * 5),
array('x' => 70.0 * 5, 'y' => 10.0 * 5),
array('x' => 90.0 * 5, 'y' => 40.0 * 5),
),
);
foreach ($smoothPointsSet as $points) {
$draw->bezier($points);
}
$disjointPoints = array(
array(
array('x' => 10 * 5, 'y' => 10 * 5),
array('x' => 30 * 5, 'y' => 90 * 5),
array('x' => 25 * 5, 'y' => 10 * 5),
array('x' => 50 * 5, 'y' => 50 * 5),
),
array(
array('x' => 50 * 5, 'y' => 50 * 5),
array('x' => 80 * 5, 'y' => 50 * 5),
array('x' => 70 * 5, 'y' => 10 * 5),
array('x' => 90 * 5, 'y' => 40 * 5),
)
);
$draw->translate(0, 200);
foreach ($disjointPoints as $points) {
$draw->bezier($points);
}
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
bezier($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/004_clone.phpt 0000644 00000000772 15041263517 0010300 0 ustar 00 --TEST--
Testing clone keyword
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
print "--- Testing clone keyword\n";
try {
$im = new Imagick();
$im->newImage(100, 100, new ImagickPixel("white"));
$new = clone $im;
if ($new->getImageWidth() == 100 && $new->getImageHeight() == 100) {
echo "Cloning succeeded\n";
} else {
echo "Cloning failed\n";
}
} catch (Exception $e) {
echo "Cloning failed\n";
}
?>
--EXPECTF--
--- Testing clone keyword
Cloning succeeded tests/236_Imagick_identify_basic.phpt 0000644 00000001607 15041263517 0013605 0 ustar 00 --TEST--
Test Imagick, identifyImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->setImageFormat('png');
$data = $imagick->identifyimage();
echo "format: " . strtolower($data["format"]) . "\n";
echo "units: " . strtolower($data["units"]) . "\n";
echo "type: " . strtolower($data["type"]) . "\n";
if (array_key_exists('geometry', $data)) {
$geometry = $data['geometry'];
if (array_key_exists('width', $geometry) && array_key_exists('height', $geometry)) {
printf(
"Image geometry %dx%d",
$geometry['width'],
$geometry['height']
);
exit(0);
}
}
echo "Failed get geometry from identifyimage:\n";
var_dump($data);
?>
--EXPECTF--
format: png (portable network graphics)
units: undefined
type: palette
Image geometry 640x480 tests/119_Imagick_sepiaToneImage_basic.phpt 0000644 00000000754 15041263517 0014666 0 ustar 00 --TEST--
Test Imagick, sepiaToneImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$sepia = 55;
function sepiaToneImage($sepia) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->sepiaToneImage($sepia);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
sepiaToneImage($sepia) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/070_Imagick_equalizeImage_case2.phpt 0000644 00000001275 15041263517 0014465 0 ustar 00 --TEST--
Test Imagick, equalizeImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
//This appears to corrupt the image colors?
function extentImage($startX, $startY, $width, $height) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->equalizeImage();
$imagick->extentImage(
$startX, $startY, $width, $height
);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
$startX = 50;
$startY = 50;
$width = 150;
$height = 150;
extentImage($startX, $startY, $width, $height) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/144_Imagick_spliceImage_basic.phpt 0000644 00000001133 15041263517 0014204 0 ustar 00 --TEST--
Test Imagick, spliceImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$startX = 50;
$startY = 50;
$width = 50;
$height = 50;
function spliceImage($startX, $startY, $width, $height) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->spliceImage($width, $height, $startX, $startY);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
spliceImage($startX, $startY, $width, $height) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/074_Imagick_flopImage_basic.phpt 0000644 00000000672 15041263517 0013676 0 ustar 00 --TEST--
Test Imagick, flopImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
function flopImage() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->flopImage();
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
flopImage() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/266_ImagickDraw_getFontResolution_basic.phpt 0000644 00000003474 15041263517 0016311 0 ustar 00 --TEST--
Test ImagickDraw, getFontResolution
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('ImagickDraw', array('getFontResolution', 'setFontResolution'));
?>
--FILE--
<?php
require_once(dirname(__FILE__) . '/functions.inc');
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
$draw = new \ImagickDraw();
setFontForImagickDraw($draw);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$fontResolution = $draw->getFontResolution();
if (isset($fontResolution["x"]) == false || isset($fontResolution["y"]) == false) {
echo "$fontResolution doesn't contain expected values:\n";
var_dump($fontResolution);
}
if ($fontResolution["x"] < 8 || $fontResolution["x"] > 100) {
echo "Font resolution x outside expected range: ".$fontResolution["x"]."\n";
}
if ($fontResolution["y"] < 8 || $fontResolution["y"] > 100) {
echo "Font resolution y outside expected range: ".$fontResolution["y"]."\n";
}
$resolutionToSet = 36;
$draw->setFontResolution($resolutionToSet, $resolutionToSet);
$fontResolution = $draw->getFontResolution();
if (abs($fontResolution["x"] - $resolutionToSet) > 0.0001) {
echo "Font resolution x after set is not $resolutionToSet instead: ".$fontResolution["x"]."\n";
}
if (abs($fontResolution["y"] - $resolutionToSet) > 0.0001) {
echo "Font resolution y after set is not $resolutionToSet instead: ".$fontResolution["y"]."\n";
}
$draw->line(125, 70, 100, 50);
$draw->annotation(50, 32, "Lorem Ipsum!");
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
echo "Ok";
?>
--EXPECTF--
Ok tests/251_ImagickPixelIterator_setIteratorRow_basic.phpt 0000644 00000002001 15041263517 0017465 0 ustar 00 --TEST--
Test ImagickPixelIterator, setIteratorRow
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
function setIteratorRow() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imageIterator = $imagick->getPixelRegionIterator(200, 100, 200, 200);
for ($x = 0; $x < 20; $x++) {
$imageIterator->setIteratorRow($x * 5);
$pixels = $imageIterator->getCurrentIteratorRow();
/* Loop through the pixels in the row (columns) */
foreach ($pixels as $pixel) {
/** @var $pixel \ImagickPixel */
/* Paint every second pixel black*/
$pixel->setColor("rgba(0, 0, 0, 0)");
}
/* Sync the iterator, this is important to do on each iteration */
$imageIterator->syncIterator();
}
$bytes = $imagick;
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
setIteratorRow() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/280_imagickkernel_exception_invalid_origin.phpt 0000644 00000004442 15041263517 0017144 0 ustar 00 --TEST--
ImagickKernel::fromMatrix exceptions
--SKIPIF--
<?php
$imageMagickRequiredVersion = 0x680;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$kernelArray = array(
array(1, 0, -1),
array(1, 0, -1),
array(1, 0, -1),
);
$validOrigins = [
[0, 0],
[2, 0],
[0, 2],
[2, 2],
[1, 2]
];
$invalidOrigins = [
[-1, 0],
[3, 0],
[0, 3],
[3, 3],
[1, PHP_INT_MAX - 10],
];
foreach ($validOrigins as $validOrigin) {
try {
$kernel = ImagickKernel::fromMatrix($kernelArray, $validOrigin);
}
catch (\Exception $e) {
echo "unexpected exception: " . $e->getMessage();
}
}
foreach ($invalidOrigins as $invalidOrigin) {
try {
$kernel = ImagickKernel::fromMatrix($kernelArray, $invalidOrigin);
echo "Exception wasn't thrown for case: \n";
var_dump($invalidOrigin);
}
catch (\ImagickKernelException $e) {
$message = $e->getMessage();
if (strpos($message, "origin_y for matrix is outside bounds of rows") === 0) {
// this is fine.
}
else if (strpos($message, "origin_x for matrix is outside bounds of columns") === 0) {
// this is fine.
}
else {
echo "Unexpected message: " . $message . "\n";
}
}
}
$flatKernelArray = array(
array(1, 0, -2, 0, 1),
);
try {
$kernel = ImagickKernel::fromMatrix($flatKernelArray, [1, 4]);
echo "Exception wasn't thrown for case: \n";
var_dump($invalidOrigin);
}
catch (\ImagickKernelException $e) {
$message = $e->getMessage();
if (strpos($message, "origin_y for matrix is outside bounds of rows") === 0) {
// this is fine.
}
else {
echo "Unexpected message: " . $message . "\n";
}
}
$tallKernelArray = array(
array(1),
array(0),
array(-2),
array(0),
array(1),
);
try {
$kernel = ImagickKernel::fromMatrix($tallKernelArray, [4, 1]);
echo "Exception wasn't thrown for case: \n";
var_dump($invalidOrigin);
}
catch (\ImagickKernelException $e) {
$message = $e->getMessage();
if (strpos($message, "origin_x for matrix is outside bounds of columns") === 0) {
// this is fine.
}
else {
echo "Unexpected message: " . $message . "\n";
}
}
echo "Complete".PHP_EOL;
?>
--EXPECTF--
Complete
tests/100_Imagick_posterizeImage_basic.phpt 0000644 00000001115 15041263517 0014741 0 ustar 00 --TEST--
Test Imagick, posterizeImage
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$posterizeType = 2;
$numberLevels = 8;
function posterizeImage($posterizeType, $numberLevels) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->posterizeImage($numberLevels, $posterizeType);
$imagick->setImageFormat('png');
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
posterizeImage($posterizeType, $numberLevels) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/220_ImagickDraw_setStrokeOpacity_basic.phpt 0000644 00000002201 15041263517 0016104 0 ustar 00 --TEST--
Test ImagickDraw, setStrokeOpacity
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function setStrokeOpacity($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeWidth(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(10);
$draw->setStrokeOpacity(1);
$draw->line(100, 80, 400, 125);
$draw->rectangle(25, 200, 150, 350);
$draw->setStrokeOpacity(0.5);
$draw->line(100, 100, 400, 145);
$draw->rectangle(200, 200, 325, 350);
$draw->setStrokeOpacity(0.2);
$draw->line(100, 120, 400, 165);
$draw->rectangle(375, 200, 500, 350);
$image = new \Imagick();
$image->newImage(550, 400, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);
$bytes = $image->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
setStrokeOpacity($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/217_ImagickDraw_setStrokeMiterLimit_basic.phpt 0000644 00000002644 15041263517 0016574 0 ustar 00 --TEST--
Test ImagickDraw, setStrokeMiterLimit
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function setStrokeMiterLimit($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setStrokeOpacity(0.6);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(10);
$yOffset = 100;
$draw->setStrokeLineJoin(\Imagick::LINEJOIN_MITER);
for ($y = 0; $y < 3; $y++) {
$draw->setStrokeMiterLimit(40 * $y);
$points = array(
array('x' => 22 * 3, 'y' => 15 * 4 + $y * $yOffset),
array('x' => 20 * 3, 'y' => 20 * 4 + $y * $yOffset),
array('x' => 70 * 5, 'y' => 45 * 4 + $y * $yOffset),
);
$draw->polygon($points);
}
$image = new \Imagick();
$image->newImage(500, 500, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);
$image->setImageType(\Imagick::IMGTYPE_PALETTE);
//TODO - this should either be everywhere or nowhere
$image->setImageCompressionQuality(100);
$image->stripImage();
$bytes = $image->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
setStrokeMiterLimit($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/320_Imagick_getOptions.phpt 0000644 00000001614 15041263517 0012754 0 ustar 00 --TEST--
Test Imagick, getOptions
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('getOptions'));
?>
--FILE--
<?php
function getOptions() {
$imagick = new \Imagick(__DIR__ . '/Biter_500.jpg');
$result = $imagick->getOptions();
if ($result !== []) {
echo "unexpected contents of options:\n";
var_dump($result);
}
$imagick->setOption("jpeg:preserve", "yes");
$result = $imagick->getOptions();
$expected = ["jpeg:preserve" => "yes"];
if ($result !== $expected) {
echo "unexpected contents of options:\n";
var_dump($result);
}
$imagick->deleteOption("jpeg:preserve");
$result = $imagick->getOptions();
if ($result !== []) {
echo "unexpected contents of options, failed to delete the set one:\n";
var_dump($result);
}
}
getOptions() ;
echo "Ok";
?>
--EXPECTF--
Ok
tests/276_Imagick_artifacts.phpt 0000644 00000001176 15041263517 0012616 0 ustar 00 --TEST--
Test Imagick::setImageArtifact and Imagick::getImageArtifact
--SKIPIF--
<?php
$imageMagickRequiredVersion = 0x656;
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('setImageArtifact', 'getImageArtifact', 'deleteImageArtifact'));
?>
--FILE--
<?php
$im = new IMagick(__DIR__ . '/php.gif');
/* Examle from http://php.net/manual/de/imagick.setimageartifact.php */
var_dump($im->setImageArtifact('compose:args', '1,0,-0.5,0.5'));
var_dump($im->getImageArtifact('compose:args'));
var_dump($im->deleteImageArtifact('compose:args'));
?>
--EXPECT--
bool(true)
string(12) "1,0,-0.5,0.5"
bool(true) tests/106_Imagick_reduceNoiseImage_basic.phpt 0000644 00000001105 15041263517 0015167 0 ustar 00 --TEST--
Test Imagick, reduceNoiseImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('reduceNoiseImage'));
?>
--FILE--
<?php
$reduceNoise = 5;
function reduceNoiseImage($reduceNoise) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
@$imagick->reduceNoiseImage($reduceNoise);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
reduceNoiseImage($reduceNoise) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/294_Imagick_cannyEdgeImage.phpt 0000644 00000001151 15041263517 0013467 0 ustar 00 --TEST--
Test Imagick, cannyEdgeImage
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('cannyEdgeImage'));
?>
--FILE--
<?php
function cannyEdgeImage() {
$path = realpath(__DIR__ . '/Biter_500.jpg');
if ($path === false) {
echo "Image is not readable.\n";
exit(-1);
}
$imagick = new \Imagick();
$imagick->readImage($path);
$imagick->cannyEdgeImage(10, 4, 0.1, 0.5);
// $imagick->writeImage(__DIR__ . '/cannyEdgeImage_output_image.png');
$imagick->getImageBlob();
}
cannyEdgeImage() ;
echo "Ok";
?>
--EXPECTF--
Ok
tests/188_ImagickDraw_pushPattern_basic.phpt 0000644 00000002753 15041263517 0015136 0 ustar 00 --TEST--
Test ImagickDraw, pushPattern
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function pushPattern($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(1);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(1);
$draw->pushPattern("MyFirstPattern", 0, 0, 50, 50);
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$positionX = $x + (($y / 5) % 5);
$draw->rectangle($positionX, $y, $positionX + 5, $y + 5);
}
}
$draw->popPattern();
$draw->setFillOpacity(0);
$draw->rectangle(100, 100, 400, 400);
$draw->setFillOpacity(1);
$draw->setFillOpacity(1);
$draw->push();
$draw->setFillPatternURL('#MyFirstPattern');
$draw->setFillColor('yellow');
$draw->rectangle(100, 100, 400, 400);
$draw->pop();
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
pushPattern($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/261_compositeImageGravity.phpt 0000644 00000001446 15041263517 0013517 0 ustar 00 --TEST--
Test compositeImageGravity
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc');
$v = Imagick::getVersion();
if ($v['versionNumber'] < 0x693)
die ('skip too old ImageMagick');
// if ($v ['versionNumber'] >= 0x660 && $v ['versionNumber'] < 0x670)
// die ('skip seems to be broken in this version of ImageMagick');
?>
--FILE--
<?php
$im1 = new Imagick("magick:logo");
$im2 = new Imagick("magick:logo");
$im2->scaleImage(
$im2->getImageWidth() / 2,
$im2->getImageHeight() / 2
);
$im1->compositeImageGravity(
$im2,
\Imagick::COMPOSITE_ATOP,
\Imagick::GRAVITY_NORTHEAST
);
$im1->compositeImageGravity(
$im2,
\Imagick::COMPOSITE_ATOP,
\Imagick::GRAVITY_SOUTH
);
// $im1->setImageFormat('png');
// $im1->writeImage('compositeImageGravity.png');
echo "Ok";
?>
--EXPECT--
Ok tests/131_Imagick_setOption_case2.phpt 0000644 00000001003 15041263517 0013652 0 ustar 00 --TEST--
Test Imagick, setOption
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$imageOption = 0;
$format = 'png64';
function renderPNG($format) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->setImageFormat('png');
$imagick->setOption('png:format', $format);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
renderPNG($format) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/314_Imagick_getBackgroundColor.phpt 0000644 00000001365 15041263517 0014405 0 ustar 00 --TEST--
Test Imagick, getBackgroundColor
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('getBackgroundColor'));
?>
--FILE--
<?php
function getBackgroundColor() {
$imagick = new \Imagick();
$background_color = $imagick->getBackgroundColor();
/** @var $background_color \ImagickPixel */
echo "Color is: " . $background_color->getColorAsString() . "\n";
$imagick->setBackgroundColor('red');
$background_color = $imagick->getBackgroundColor();
/** @var $background_color \ImagickPixel */
echo "Color is now: " . $background_color->getColorAsString() . "\n";
}
getBackgroundColor() ;
echo "Ok";
?>
--EXPECTF--
Color is: srgb(255,255,255)
Color is now: srgb(255,0,0)
Ok
tests/027_Imagick_adaptiveResizeImage_basic.phpt 0000644 00000001131 15041263517 0015702 0 ustar 00 --TEST--
Test Imagick, adaptiveResizeImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$width = 200;
$height = 200;
$bestFit = 1;
function adaptiveResizeImage($width, $height, $bestFit) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->adaptiveResizeImage($width, $height, $bestFit);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
adaptiveResizeImage($width, $height, $bestFit) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/321_Imagick_getOrientation.phpt 0000644 00000001143 15041263517 0013612 0 ustar 00 --TEST--
Test Imagick, getOrientation/setOrientation
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('getOrientation'));
?>
--FILE--
<?php
function getOrientation() {
$imagick = new \Imagick(__DIR__ . '/Biter_500.jpg');
$orientation = $imagick->getOrientation();
echo "Orientation is $orientation\n";
$imagick->setOrientation(Imagick::ORIENTATION_LEFTBOTTOM);
$orientation = $imagick->getOrientation();
echo "Orientation is now $orientation\n";
}
getOrientation() ;
echo "Ok";
?>
--EXPECTF--
Orientation is 0
Orientation is now 8
Ok
tests/073_Imagick_forwardFourierTransformImage_basic.phpt 0000644 00000003432 15041263517 0017626 0 ustar 00 --TEST--
Test Imagick, forwardFourierTransformImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
require_once(dirname(__FILE__) . '/skipprobefourier.inc');
?>
--FILE--
<?php
//Utility function for forwardTransformImage
function createMask() {
$draw = new \ImagickDraw();
$draw->setStrokeOpacity(0);
$draw->setStrokeColor('rgb(255, 255, 255)');
$draw->setFillColor('rgb(255, 255, 255)');
//Draw a circle on the y-axis, with it's centre
//at x, y that touches the origin
$draw->circle(250, 250, 220, 250);
$imagick = new \Imagick();
$imagick->newImage(512, 512, "black");
$imagick->drawImage($draw);
$imagick->gaussianBlurImage(20, 20);
$imagick->autoLevelImage();
return $imagick;
}
function forwardFourierTransformImage() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->resizeimage(512, 512, \Imagick::FILTER_LANCZOS, 1);
$mask = createMask();
$imagick->forwardFourierTransformImage(true);
$imagick->setIteratorIndex(0);
$magnitude = $imagick->getimage();
$imagick->setIteratorIndex(1);
$imagickPhase = $imagick->getimage();
if (true) {
$imagickPhase->compositeImage($mask, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
}
if (false) {
$output = clone $imagickPhase;
$output->setimageformat('png');
$bytes = $output->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
$magnitude->inverseFourierTransformImage($imagickPhase, true);
$magnitude->setimageformat('png');
$bytes = $magnitude->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
forwardFourierTransformImage() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/243_Tutorial_svgExample_basic.phpt 0000644 00000002516 15041263517 0014342 0 ustar 00 --TEST--
Test Tutorial, svgExample
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
function svgExample() {
$svg = <<< END
<?xml version="1.0"?>
<svg version='1.0' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='746' height='742' viewBox='-362 -388 746 742' encoding='UTF-8' standalone='no'>
<defs>
<ellipse id='ellipse' cx='36' cy='-56' rx='160' ry='320' />
<g id='ellipses'>
<use xlink:href='#ellipse' fill='#0000ff' />
<use xlink:href='#ellipse' fill='#0099ff' transform='rotate(72)' />
</g>
</defs>
</svg>
END;
$svg = '<?xml version="1.0"?>
<svg width="120" height="120"
viewPort="0 0 120 120" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="myClip">
<circle cx="30" cy="30" r="20"/>
<circle cx="70" cy="70" r="20"/>
</clipPath>
</defs>
<rect x="10" y="10" width="100" height="100"
clip-path="url(#myClip)"/>
</svg>';
$image = new \Imagick();
$image->readImageBlob($svg);
$image->setImageFormat("jpg");
$bytes = $image;
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
svgExample() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/198_ImagickDraw_setClipPath_basic.phpt 0000644 00000002016 15041263517 0015032 0 ustar 00 --TEST--
Test ImagickDraw, setClipPath
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function setClipPath($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeOpacity(1);
$draw->setStrokeWidth(2);
$clipPathName = 'testClipPath';
$draw->pushClipPath($clipPathName);
$draw->rectangle(0, 0, 250, 250);
$draw->popClipPath();
$draw->setClipPath($clipPathName);
$draw->rectangle(100, 100, 400, 400);
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
setClipPath($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/227_ImagickDraw_skewY_basic.phpt 0000644 00000002220 15041263517 0013702 0 ustar 00 --TEST--
Test ImagickDraw, skewY
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
$fillModifiedColor = 'LightCoral';
$startX = 50;
$startY = 50;
$endX = 400;
$endY = 400;
$skew = 10;
function skewY($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor,
$startX, $startY, $endX, $endY, $skew) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth(2);
$draw->setFillColor($fillColor);
$draw->rectangle($startX, $startY, $endX, $endY);
$draw->setFillColor($fillModifiedColor);
$draw->skewY($skew);
$draw->rectangle($startX, $startY, $endX, $endY);
$image = new \Imagick();
$image->newImage(500, 500, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);
$bytes = $image->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
skewY($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor,
$startX, $startY, $endX, $endY, $skew);
echo "Ok";
?>
--EXPECTF--
Ok tests/281_imagick_houghLineImage_basic.phpt 0000644 00000001351 15041263520 0014705 0 ustar 00 --TEST--
Test Imagick, houghLineImage
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('houghLineImage'));
?>
--FILE--
<?php
function houghLineImage() {
$path = realpath(__DIR__ . '/houghline_input_image.png');
if ($path === false) {
echo "Image is not readable.\n";
exit(-1);
}
$imagick = new \Imagick();
$imagick->readImage($path);
$imagick->setbackgroundcolor('rgb(64, 64, 64)');
$imagick->houghLineImage(20,40, 40);
$imagick->writeImage(__DIR__ . '/houghline_output_image.png');
}
houghLineImage() ;
echo "Ok";
?>
--CLEAN--
<?php
$f = __DIR__ . '/houghline_output_image.png';
if (file_exists($f)) {
@unlink($f);
}
?>
--EXPECTF--
Ok
tests/088_Imagick_implodeImageWithMethod_basic.phpt 0000644 00000001347 15041263520 0016363 0 ustar 00 --TEST--
Test Imagick, implodeImageWithMethod
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x700;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
function implodeImage($method) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->implodeImageWithMethod(1.15, $method);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
// $imagick->writeImage(__DIR__ . "/implodeImageWithMethod_$method.png");
}
$methods = [
Imagick::INTERPOLATE_SPLINE,
Imagick::INTERPOLATE_AVERAGE_16,
Imagick::INTERPOLATE_BACKGROUND_COLOR
];
foreach ($methods as $method) {
implodeImage($method);
}
echo "Ok";
?>
--EXPECTF--
Ok tests/076_Imagick_fxImage_basic.phpt 0000644 00000001103 15041263520 0013335 0 ustar 00 --TEST--
Test Imagick, fxImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
checkFormatPresent('png');
?>
--FILE--
<?php
function fxImage() {
$imagick = new \Imagick();
$imagick->newPseudoImage(200, 200, "xc:white");
$fx = 'xx=i-w/2; yy=j-h/2; rr=hypot(xx,yy); (.5-rr/140)*1.2+.5';
$fxImage = $imagick->fxImage($fx);
$fxImage->setimageformat('png');
$bytes = $fxImage->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
fxImage() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/028_Imagick_adaptiveSharpenImage_basic.phpt 0000644 00000001157 15041263520 0016044 0 ustar 00 --TEST--
Test Imagick, adaptiveSharpenImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$radius = 5;
$sigma = 1;
$channel = Imagick::CHANNEL_DEFAULT;
function adaptiveSharpenImage($radius, $sigma, $channel) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->adaptiveSharpenImage($radius, $sigma, $channel);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
adaptiveSharpenImage($radius, $sigma, $channel) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/272_imagick_identifyimagetype.phpt 0000644 00000000675 15041263520 0014407 0 ustar 00 --TEST--
Test identifyImageType
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('identifyImageType'));
?>
--FILE--
<?php
$im = new Imagick();
$im->newPseudoImage(100, 100, "magick:logo");
$type = $im->identifyImageType();
if ($type !== Imagick::IMGTYPE_PALETTE) {
echo "Unexpected type value. Expecting: ".Imagick::IMGTYPE_PALETTE.", but got $type. \n";
}
echo "Ok";
?>
--EXPECTF--
Ok tests/132_Imagick_setOption_case3.phpt 0000644 00000001054 15041263520 0013654 0 ustar 00 --TEST--
Test Imagick, setOption
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$imageOption = 0;
function renderCustomBitDepthPNG() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->setImageFormat('png');
$imagick->setOption('png:bit-depth', '16');
$imagick->setOption('png:color-type', 6);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
renderCustomBitDepthPNG() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/175_ImagickDraw_arc_basic.phpt 0000644 00000002412 15041263520 0013344 0 ustar 00 --TEST--
Test ImagickDraw, arc
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
$startX = 50;
$startY = 50;
$endX = 400;
$endY = 400;
$startAngle = 0;
$endAngle = 270;
function arc($strokeColor, $fillColor, $backgroundColor, $startX, $startY, $endX, $endY, $startAngle, $endAngle) {
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$draw->setStrokeWidth(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
$draw->arc($startX, $startY, $endX, $endY, $startAngle, $endAngle);
//Create an image object which the draw commands can be rendered into
$image = new \Imagick();
$image->newImage(500, 500, $backgroundColor);
$image->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$image->drawImage($draw);
//Send the image to the browser
$bytes = $image->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
arc($strokeColor, $fillColor, $backgroundColor, $startX, $startY, $endX, $endY, $startAngle, $endAngle) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/250_ImagickPixelIterator_resetIterator_basic.phpt 0000644 00000003204 15041263520 0017323 0 ustar 00 --TEST--
Test ImagickPixelIterator, resetIterator
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
function resetIterator() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imageIterator = $imagick->getPixelIterator();
/* Loop trough pixel rows */
foreach ($imageIterator as $pixels) {
/* Loop through the pixels in the row (columns) */
foreach ($pixels as $column => $pixel) {
/** @var $pixel \ImagickPixel */
if ($column % 2) {
/* Make every second pixel 25% red*/
$pixel->setColorValue(\Imagick::COLOR_RED, 64);
}
}
/* Sync the iterator, this is important to do on each iteration */
$imageIterator->syncIterator();
}
$imageIterator->resetiterator();
/* Loop trough pixel rows */
foreach ($imageIterator as $pixels) {
/* Loop through the pixels in the row (columns) */
foreach ($pixels as $column => $pixel) {
/** @var $pixel \ImagickPixel */
if ($column % 3) {
$pixel->setColorValue(\Imagick::COLOR_BLUE, 64); /* Make every second pixel a little blue*/
//$pixel->setColor("rgba(0, 0, 128, 0)"); /* Paint every second pixel black*/
}
}
$imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
}
$imageIterator->clear();
$bytes = $imagick;
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
resetIterator() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/025-get-color.phpt 0000644 00000006523 15041263520 0011006 0 ustar 00 --TEST--
Test getColor and getColorQuantum
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
define('ORIGINAL', 'ORIGINAL');
define('NORMALISED', 'NORMALISED');
define('NORMALISED_INCLUDING_ALPHA', 'NORMALISED_INCLUDING_ALPHA');
define('QUANTUM', 'QUANTUM');
function checkExpectedValue($expectedValue, $actualValue, $hasVariance) {
$variance = 0;
// Behaviour of 50% pixel was changed in
// key = version
// value = variance expected in result
$troubledVersions = array(
0x692 => 1
);
$v = Imagick::getVersion();
$versionNumber = $v['versionNumber'];
if (array_key_exists($versionNumber, $troubledVersions)) {
$variance = $troubledVersions[$versionNumber];
}
if (Imagick::getHDRIEnabled()) {
return abs($expectedValue - $actualValue) < (0.01 + $variance);
}
if ($hasVariance) {
$difference = abs($expectedValue - $actualValue);
if ($difference < 1 + $variance) {
return true;
}
echo "difference $difference not < 1 + variance $variance\n";
return false;
}
else if($expectedValue == $actualValue) {
return true;
}
return false;
}
function getExpectedValue($someValue) {
if (Imagick::getHDRIEnabled()) {
return $someValue;
}
$v = Imagick::getVersion();
if ($v['versionNumber'] >= 0x692) {
//this is the new correct behaviour
return (intval(round($someValue, 0, PHP_ROUND_HALF_UP)));
}
else {
//old behaviour had wrong rounding.
return (intval(round($someValue, 0, PHP_ROUND_HALF_DOWN)));
}
}
$tests = array(
array(
'red',
ORIGINAL,
array(
array('r', getExpectedValue(255), 0),
array('a', getExpectedValue(1.0), 0)
),
),
array(
'red',
QUANTUM,
array(
array('r', getExpectedValue(\Imagick::getQuantum()), 0),
array('a', getExpectedValue(\Imagick::getQuantum()), 0)
),
),
array(
'rgb(25%, 25%, 25%)',
QUANTUM,
array(
array('r', getExpectedValue(\Imagick::getQuantum() / 4), 0),
array('a', getExpectedValue(\Imagick::getQuantum()), 0),
)
)
);
$version = Imagick::getVersion();
// The following don't seem stable in lesser versions.
if ($version['versionNumber'] >= 0x687) {
$tests[] = array(
'green',
QUANTUM,
array(
array('g', getExpectedValue(\Imagick::getQuantum() * (128 / 255)), 1),
array('a', getExpectedValue(\Imagick::getQuantum()), 1)
),
);
$tests[] = array(
'rgb(0, 50%, 0)',
QUANTUM,
array(
array('g', getExpectedValue(\Imagick::getQuantum() / 2), 1),
array('a', getExpectedValue(\Imagick::getQuantum()), 0)
),
);
}
foreach ($tests as $test) {
list($colorString, $type, $expectations) = $test;
$pixel = new ImagickPixel($colorString);
switch ($type) {
case(ORIGINAL): {
$color = $pixel->getColor();
break;
}
case(NORMALISED): {
$color = $pixel->getColor(true);
break;
}
case(NORMALISED_INCLUDING_ALPHA): {
$color = $pixel->getColor(2);
break;
}
case(QUANTUM): {
$color = $pixel->getColorQuantum();
break;
}
default:{
echo "Unknown test type $type" . PHP_EOL;
break;
}
}
foreach ($expectations as $test) {
list($key, $expectedValue, $hasVariance) = $test;
if (!checkExpectedValue($expectedValue, $color[$key], $hasVariance)) {
printf(
"%s %s is wrong for colorString '%s': actual %s != expected %s" . PHP_EOL,
$type,
$key, $colorString,
$color[$key], $expectedValue
);
}
}
}
echo "OK" . PHP_EOL;
?>
--EXPECT--
OK tests/152_Imagick_swirlImageWithMethod_basic.phpt 0000644 00000001044 15041263520 0016054 0 ustar 00 --TEST--
Test Imagick, swirlImageWithMethod
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x700;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$swirl = 100;
function swirlImageWithMethod($swirl) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->swirlImageWithMethod($swirl, Imagick::INTERPOLATE_BILINEAR);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
swirlImageWithMethod($swirl) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/185_ImagickDraw_point_basic.phpt 0000644 00000001370 15041263520 0013733 0 ustar 00 --TEST--
Test ImagickDraw, point
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function point($fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setFillColor($fillColor);
for ($x = 0; $x < 10000; $x++) {
$draw->point(rand(0, 500), rand(0, 500));
}
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
point($fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/239_Tutorial_gradientReflection_basic.phpt 0000644 00000002511 15041263520 0016031 0 ustar 00 --TEST--
Test Tutorial, gradientReflection
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
function gradientReflection() {
$im = new \Imagick();
$im->newPseudoImage(640, 480, "magick:logo");
$reflection = clone $im;
$reflection->flipImage();
$reflection->cropImage($im->getImageWidth(), $im->getImageHeight() * 0.75, 0, 0);
$gradient = new \Imagick();
$gradient->newPseudoImage(
$reflection->getImageWidth(),
$reflection->getImageHeight(),
//Putting spaces in the rgba string is bad
'gradient:rgba(255,0,255,0.6)-rgba(255,255,0,0.99)'
);
$reflection->compositeimage(
$gradient,
\Imagick::COMPOSITE_DSTOUT,
0, 0
);
$canvas = new \Imagick();
$canvas->newImage($im->getImageWidth(), $im->getImageHeight() * 1.75, new \ImagickPixel('rgba(255, 255, 255, 0)'));
$canvas->compositeImage($im, \Imagick::COMPOSITE_BLEND, 0, 0);
$canvas->setImageFormat('png');
$canvas->compositeImage($reflection, \Imagick::COMPOSITE_BLEND, 0, $im->getImageHeight());
$canvas->stripImage();
$canvas->setImageFormat('png');
header('Content-Type: image/png');
$bytes = $canvas;
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
gradientReflection() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/213_ImagickDraw_setStrokeAlpha_basic.phpt 0000644 00000001717 15041263520 0015530 0 ustar 00 --TEST--
Test ImagickDraw, setStrokeAlpha
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';
function setStrokeAlpha($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(4);
$draw->line(100, 100, 400, 145);
$draw->rectangle(100, 200, 225, 350);
$draw->setStrokeOpacity(0.1);
$draw->line(100, 120, 400, 165);
$draw->rectangle(275, 200, 400, 350);
$image = new \Imagick();
$image->newImage(500, 400, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);
$bytes = $image->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
setStrokeAlpha($strokeColor, $fillColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/048_Imagick_cropImage_basic.phpt 0000644 00000001123 15041263520 0013664 0 ustar 00 --TEST--
Test Imagick, cropImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$startX = 50;
$startY = 50;
$width = 50;
$height = 50;
function cropImage($startX, $startY, $width, $height) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->cropImage($width, $height, $startX, $startY);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
cropImage($startX, $startY, $width, $height) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/041_Imagick_chopImage_basic.phpt 0000644 00000001124 15041263520 0013644 0 ustar 00 --TEST--
Test Imagick, chopImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$startX = 50;
$startY = 50;
$width = 100;
$height = 50;
function chopImage($startX, $startY, $width, $height) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->chopImage($width, $height, $startX, $startY);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
chopImage($startX, $startY, $width, $height) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/bug21229.phpt 0000644 00000001262 15041263520 0007757 0 ustar 00 --TEST--
Test PECL bug #21229
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class ImagickTest extends Imagick {
/* Protected property */
protected $test;
/* Override width property */
public $width = 112233;
public function setTestValue($value) {
$this->test = $value;
return $this;
}
public function getTestValue() {
return $this->test;
}
}
$test = new ImagickTest("magick:logo");
$test->setTestValue("test value");
echo "Value: " , $test->getTestValue() , PHP_EOL;
var_dump($test->width, $test->height);
echo "OK" , PHP_EOL;
?>
--EXPECTF--
Value: test value
int(112233)
int(%d)
OK tests/093_Imagick_modulateImage_basic.phpt 0000644 00000001125 15041263520 0014535 0 ustar 00 --TEST--
Test Imagick, modulateImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$hue = 150;
$saturation = 100;
$brightness = 100;
function modulateImage($hue, $brightness, $saturation) {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->modulateImage($brightness, $saturation, $hue);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
modulateImage($hue, $brightness, $saturation) ;
echo "Ok";
?>
--EXPECTF--
Ok tests/138_Imagick_shaveImage_basic.phpt 0000644 00000000704 15041263520 0014033 0 ustar 00 --TEST--
Test Imagick, shaveImage
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
function shaveImage() {
$imagick = new \Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagick->shaveImage(100, 50);
$bytes = $imagick->getImageBlob();
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
}
shaveImage() ;
echo "Ok";
?>
--EXPECTF--
Ok tests/278_Imagick_optimaze_gif.phpt 0000644 00000004426 15041263520 0013310 0 ustar 00 --TEST--
Test Imagick::optimizeimagelayers and Imagick::optimizeimagetransparency
--SKIPIF--
<?php
$imageMagickRequiredVersion = 0x686;
require_once(dirname(__FILE__) . '/skipif.inc');
checkClassMethods('Imagick', array('optimizeimagelayers'));
checkClassMethods('Imagick', array('optimizeimagetransparency'));
?>
--FILE--
<?php
function makeSimpleGif() {
$aniGif = new \Imagick();
$aniGif->setFormat("gif");
$circleRadius = 20;
$imageFrames = 6;
$imageSize = 200;
$background = new \Imagick();
$background->newpseudoimage($imageSize, $imageSize, "canvas:gray");
$blackWhite = new \Imagick();
$blackWhite->newpseudoimage($imageSize, $imageSize, "gradient:black-white");
$backgroundPalette = clone $background;
$backgroundPalette->quantizeImage(240, \Imagick::COLORSPACE_RGB, 8, false, false);
$blackWhitePalette = clone $blackWhite;
$blackWhitePalette->quantizeImage(16, \Imagick::COLORSPACE_RGB, 8, false, false);
$backgroundPalette->addimage($blackWhitePalette);
for($count=0 ; $count<$imageFrames ; $count++) {
echo "Frame: ".$count."\n";
$drawing = new \ImagickDraw();
$drawing->setFillColor('white');
$drawing->setStrokeColor('rgba(64, 64, 64, 0.8)');
$strokeWidth = 4;
$drawing->setStrokeWidth($strokeWidth);
$distanceToMove = $imageSize + (($circleRadius + $strokeWidth) * 2);
$offset = ($distanceToMove * $count / ($imageFrames -1)) - ($circleRadius + $strokeWidth);
$drawing->translate($offset, ($imageSize / 2) + ($imageSize / 3 * cos(20 * $count / $imageFrames)));
$drawing->circle(0, 0, $circleRadius, 0);
$frame = clone $background;
$frame->drawimage($drawing);
$frame->clutimage($backgroundPalette);
$frame->setImageDelay(10);
$aniGif->addImage($frame);
}
$aniGif = $aniGif->deconstructImages();
$bytes = $aniGif->getImagesBlob();
if (strlen($bytes) <= 0) {
echo "Failed to generate image.";
}
return $aniGif;
}
function optimizeGif($im) {
$im = $im->coalesceImages();
$im->optimizeImageLayers();
$im->optimizeimagetransparency();
}
$simpleGif = makeSimpleGif();
optimizeGif($simpleGif);
echo "Ok"
?>
--EXPECT--
Frame: 0
Frame: 1
Frame: 2
Frame: 3
Frame: 4
Frame: 5
Ok
tests/houghline_input_image.png 0000644 00000003110 15041263520 0012750 0 ustar 00 �PNG
IHDR � , e�� gAMA ���a cHRM z&