Skip to content
Permalink
Browse files

Check gd extension on test Phalcon

Closes #14348
  • Loading branch information...
sergeyklay committed Sep 8, 2019
1 parent b2c72e8 commit 8f185e4818c5c52f82640c20a328a8b9344beadd
@@ -41,6 +41,7 @@
"psr/simple-cache": "^1.0"
},
"require-dev": {
"ext-gd": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
@@ -40,8 +40,9 @@ private function getImages(): array
/**
* @param string $image path to image
* @param string $hash expected hasd
* @param int $simility percent of similarity
* @param string $hash expected hash
* @param float $simility percent of similarity
* @return bool
*/
private function checkImageHash(string $image, string $hash, float $simility = 95.0): bool
{
@@ -56,8 +57,11 @@ private function checkImageHash(string $image, string $hash, float $simility = 9
* as hashes.
*
* @author https://github.com/xwiz/phash
*
* @param array|string $hash1
* @param array|string $hash2
* @param int $precision
* @return float
*/
private function getSimilarityHamming($hash1, $hash2, int $precision = 1): float
{
@@ -92,6 +96,8 @@ private function getSimilarityHamming($hash1, $hash2, int $precision = 1): float
/**
* @author https://github.com/xwiz/phash
*
* @param string $filepath
* @return array|string
*/
private function getHash(string $filepath)
@@ -120,7 +126,7 @@ private function getHash(string $filepath)
return 'the image format is not supported. supported formats: ' . $supportedFormats;
}
//test image for same size
// test image for same size
$width = imagesx($img);
$height = imagesy($img);
@@ -129,6 +135,8 @@ private function getHash(string $filepath)
}
$averageValue = 0;
$grayscale = [];
for ($y = 0; $y < $scale; $y++) {
for ($x = 0; $x < $scale; $x++) {
// get the rgb value for current pixel
@@ -163,8 +171,10 @@ private function getHash(string $filepath)
/**
* @author https://github.com/xwiz/phash
* @param $hash
*
* @param array $hash
* @param bool $hex
* @return string|null
*/
private function hashAsString(array $hash, $hex = true): ?string
{
@@ -190,6 +200,7 @@ private function hashAsString(array $hash, $hex = true): ?string
/**
* @author https://github.com/xwiz/phash
*
* @param $img
* @param $thumbwidth
* @param $thumbheight
@@ -213,6 +224,7 @@ private function makeThumbnail($img, int $thumbwidth, int $thumbheight, int $wid
/**
* @author https://github.com/xwiz/phash
*
* @param $dst_image
* @param $src_image
* @param $dst_x
@@ -224,6 +236,7 @@ private function makeThumbnail($img, int $thumbwidth, int $thumbheight, int $wid
* @param $src_w
* @param $src_h
* @param int $quality
* @return bool
*/
private function fastimagecopyresampled(
&$dst_image,
@@ -294,6 +307,7 @@ private function fastimagecopyresampled(
* Performs a left shift on the supplied binary array
*
* @author https://github.com/xwiz/phash
*
* @param array binary array to perform shift on
* @param int integer value to shift
* @param int amount of places to left shift
@@ -13,10 +13,13 @@
namespace Phalcon\Test\Unit\Image\Adapter\Gd;
use Phalcon\Image\Adapter\Gd;
use Phalcon\Test\Fixtures\Traits\GdTrait;
use UnitTester;
class GetHeightCest
{
use GdTrait;
/**
* Tests Phalcon\Image\Adapter\Gd :: getHeight()
*
@@ -13,10 +13,13 @@
namespace Phalcon\Test\Unit\Image\Adapter\Gd;
use Phalcon\Image\Adapter\Gd;
use Phalcon\Test\Fixtures\Traits\GdTrait;
use UnitTester;
class GetMimeCest
{
use GdTrait;
/**
* Tests Phalcon\Image\Adapter\Gd :: getMime()
*
@@ -13,10 +13,13 @@
namespace Phalcon\Test\Unit\Image\Adapter\Gd;
use Phalcon\Image\Adapter\Gd;
use Phalcon\Test\Fixtures\Traits\GdTrait;
use UnitTester;
class GetVersionCest
{
use GdTrait;
/**
* Unit Tests Phalcon\Image\Adapter\Gd :: getVersion()
*
@@ -13,10 +13,13 @@
namespace Phalcon\Test\Unit\Image\Adapter\Gd;
use Phalcon\Image\Adapter\Gd;
use Phalcon\Test\Fixtures\Traits\GdTrait;
use UnitTester;
class GetWidthCest
{
use GdTrait;
/**
* Tests Phalcon\Image\Adapter\Gd :: getWidth()
*
@@ -35,7 +38,6 @@ public function imageAdapterGdGetWidthJpg(UnitTester $I)
);
}
/**
* Tests Phalcon\Image\Adapter\Gd :: getWidth()
*

0 comments on commit 8f185e4

Please sign in to comment.
You can’t perform that action at this time.