From 8e67be01f5d9dba04e819a470ee455abe1a8e06f Mon Sep 17 00:00:00 2001 From: WuChienKun Date: Tue, 17 Dec 2019 23:16:28 +0800 Subject: [PATCH] 1)complete issue #9 2)Modified the algorithm of GdGenerator and ImageMagickGenerator to generate images. Because I found that only the images generated by vgGenerator are correct when the pixels are particularly small. --- README.md | 22 ++- README.zh_cn.md | 144 ++++++++++++++++++ doc/8.8.4.4_with_margin.png | Bin 0 -> 255 bytes doc/8.8.8.8_with_margin.png | Bin 0 -> 261 bytes doc/Benjamin_with_margin.png | Bin 0 -> 277 bytes doc/benjaminAtYzalisDotCom_with_margin.png | Bin 0 -> 271 bytes doc/yzalis_with_margin.png | Bin 0 -> 275 bytes src/Identicon/Generator/BaseGenerator.php | 33 ++++ src/Identicon/Generator/GdGenerator.php | 20 ++- .../Generator/GeneratorInterface.php | 10 +- .../Generator/ImageMagickGenerator.php | 17 ++- src/Identicon/Generator/SvgGenerator.php | 19 +-- src/Identicon/Identicon.php | 20 ++- tests/Identicon/Tests/IdenticonTest.php | 34 ++--- 14 files changed, 266 insertions(+), 53 deletions(-) create mode 100644 README.zh_cn.md create mode 100644 doc/8.8.4.4_with_margin.png create mode 100644 doc/8.8.8.8_with_margin.png create mode 100644 doc/Benjamin_with_margin.png create mode 100644 doc/benjaminAtYzalisDotCom_with_margin.png create mode 100644 doc/yzalis_with_margin.png diff --git a/README.md b/README.md index f898fbb..7818cff 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ or generate and get the base 64 image uri ready for integrate into an HTML img t ``` php $imageDataUri = $identicon->getImageDataUri('bar'); ``` -``` html +``` php bar Identicon ``` @@ -75,6 +75,8 @@ Color can be an hexadecimal with 6 characters ``` php $identicon->displayImage('bar', 64, 'A87EDF'); + +$identicon->displayImage('bar', 64, '#A87EDF'); ``` or an array with red, green, blue value @@ -88,12 +90,30 @@ That's it! ### Generate an identicon on SVG format The only thing you need to change it this one: + ``` php $identicon = new \Identicon\Identicon(new SvgGenerator()); $imageDataUri = $identicon->getImageDataUri('bar'); +``` +``` php bar Identicon ``` +### Margin + +There is no magin by default. If you need an image with margin, you can add a fifth parameter. One-tenth of the size is recommended. + +In this example, we set a gray background, and you can clearly see the margins: + +![Identicon example #6](doc/benjaminAtYzalisDotCom_with_margin.png)   +![Identicon example #7](doc/Benjamin_with_margin.png)   +![Identicon example #8](doc/8.8.8.8_with_margin.png)   +![Identicon example #9](doc/8.8.4.4_with_margin.png)   +![Identicon example #10](doc/yzalis_with_margin.png) + +```php +$identicon->displayImage('foo', 100, null, '#f0f0f0', 10); +``` ## Unit Tests diff --git a/README.zh_cn.md b/README.zh_cn.md new file mode 100644 index 0000000..7f4d8bd --- /dev/null +++ b/README.zh_cn.md @@ -0,0 +1,144 @@ +# Identicon 生成器 PHP 版 + +[![Build Status](https://secure.travis-ci.org/yzalis/Identicon.png)](http://travis-ci.org/yzalis/Identicon) +[![codecov.io](https://codecov.io/github/yzalis/Identicon/coverage.svg?branch=master)](https://codecov.io/github/yzalis/Identicon?branch=master) + +**Identicon** 是一个基于字符串生成一个 [identicon](http://en.wikipedia.org/wiki/Identicon) 图像的库。 + +以下是一些精彩的输出例子! + +![Identicon example #1](doc/benjaminAtYzalisDotCom.png)   +![Identicon example #2](doc/Benjamin.png)   +![Identicon example #3](doc/8.8.8.8.png)   +![Identicon example #4](doc/8.8.4.4.png)   +![Identicon example #5](doc/yzalis.png) + +## 安装 + +推荐通过 composer 安装 Identicon。 + +只需要在你的项目中引入本库: + +``` bash +composer require yzalis/identicon +``` + +## 使用 + +生成的图像都是透明背景的 PNG 格式。 + +字符串可以是邮箱,IP 地址,用户名,ID 或者其他的东西。 + +### 生成一个 identicon + +创建一个 ```Identicon``` 对象。 + +``` php +$identicon = new \Identicon\Identicon(); +``` + +然后你可以生成或者显示一张图像 + +``` php +$identicon->displayImage('foo'); +``` + +或者生成并获取图像的信息 + +``` php +$imageData = $identicon->getImageData('bar'); +``` + +或者生成并获取 base 64 图片的 uri 以便整合到 HTML 的 img 标签中。 + +``` php +$imageDataUri = $identicon->getImageDataUri('bar'); +``` +``` php +bar Identicon +``` + + +### 修改图像大小 + +默认的大小是 64 像素。如果你想改变图像大小,只需要添加第二个参数。在这个例子中是 512 x 512px。 + +``` php +$identicon->displayImage('foo', 512); +``` + +### 颜色 + +图像颜色是由字符串的哈希值自动生成的,但是你可以添加第三个参数指定一个颜色。 + +颜色值可以使用一个 6 字符的十六进制字符串 + +``` php +$identicon->displayImage('bar', 64, 'A87EDF'); + +$identicon->displayImage('bar', 64, '#A87EDF'); +``` + +也可以使用由红(R)、绿(G)、蓝(B)数值组成的数组 + +``` php +$identicon->displayImage('foo', 64, array(200, 100, 150)); +``` + +就是这样! + +### 生成一个 SVG 格式的 identicon + +你只需要修改一个地方: +``` php +$identicon = new \Identicon\Identicon(new SvgGenerator()); +$imageDataUri = $identicon->getImageDataUri('bar'); +``` +``` php +bar Identicon +``` + +### 边距 + +默认是没有边距的,如果你想要带边距的图像,你可以添加第五个参数。推荐使用图像的大小的十分之一。 + +在这个例子中,我们设置了灰色的背景,这样你可以很明显的看到边距: + +![Identicon example #6](doc/benjaminAtYzalisDotCom_with_margin.png)   +![Identicon example #7](doc/Benjamin_with_margin.png)   +![Identicon example #8](doc/8.8.8.8_with_margin.png)   +![Identicon example #9](doc/8.8.4.4_with_margin.png)   +![Identicon example #10](doc/yzalis_with_margin.png) + +```php +$identicon->displayImage('foo', 100, null, '#f0f0f0', 10); +``` + +## 单元测试 + +为了运行单元测试,你需要一组依赖,它们可以通过 Composer 安装: + +``` +php composer.phar install +``` + +一旦安装,就可以使用下面的命令: + +``` +./vendor/bin/phpunit +``` + +应该一切都好了。 + + +## 贡献者名单 + +* Benjamin Laugueux +* [所有贡献者](https://github.com/yzalis/Identicon/graphs/contributors) + +灵感来自于一篇关于 Identicon 的 Github [博客](https://github.com/blog/1586-identicons)。 + + +## 证书 + +Identicon 是根据 MIT 许可证发布的。详细信息请参见附带的 LICENSE 文件。 diff --git a/doc/8.8.4.4_with_margin.png b/doc/8.8.4.4_with_margin.png new file mode 100644 index 0000000000000000000000000000000000000000..42b3f48c81374915472796d4d283e37287c90098 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^z97uO1SE5^>z)HC&H|6fVg?4jBOuH;Rhv&5D7ewn z#WAE}&f8n3IU5W_STDNh90<}q8Wh~bsv*&2|Lk1kt_eK+DmH7@ZWT)S^@~A&z)HC&H|6fVg?4jBOuH;Rhv&5D7f9z z#WAE}&f7Z&IU5WF7#x+ar3#8A6pAGXicOKyIneM>j`PjiJ)tq5EI(|x5;dLW+D(0f zj=4Hzn{pmn&wu@5XO8{*kN&?;70oN#bmL@_dN)Wa#9k8_p3iaac|KV5kXCJdK{ zGmd=ETBdWRWxr^OrN4FLo0N@{kNSyOM{X)Hd-mf4-!F!D$Nz7D2!Z5Oz0*JLXVL&! b^oeQ1d&&CtlX`qWFEDtz`njxgN@xNAZ_I9y literal 0 HcmV?d00001 diff --git a/doc/Benjamin_with_margin.png b/doc/Benjamin_with_margin.png new file mode 100644 index 0000000000000000000000000000000000000000..13f09a134c31004dffafeee74039541c4672ef21 GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^z97uO1SE5^>z)HC&H|6fVg?4jBOuH;Rhv&5D0tk{ z#WAE}&f8lDd7BLcSOXnIW&~-p1_jOX_F#OL5Xsj5^K)MZi(7SMz)HC&H|6fVg?4jBOuH;Rhv&5D0tA* z#WAE}&f8lXd0PwwSOXoz;|oQ+GWk|K;4-)rDV;FGUZ3qqhVbU3+_k!l+ivO?2wO+K zN%=YD{hjl*Pc}WSzVm-e+$o#4DH|sr^%Db0dA^MKz4zpUiN8+%dR&Jlv*!KdiPvq~P_V=E-e6CK}rW+@d)Vt^EXwLmw h`)Bu(GnYX&*7b9$9lhqDxfSRc22WQ%mvv4FO#r^(c8mZ3 literal 0 HcmV?d00001 diff --git a/doc/yzalis_with_margin.png b/doc/yzalis_with_margin.png new file mode 100644 index 0000000000000000000000000000000000000000..67c3d91e8f74e722782ed6d79ecd534defca437b GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0vp^z97uO1SE5^>z)HC&H|6fVg?4jBOuH;Rhv&5D0tM< z#WAE}&f8lDd7BLcST70`E}JrC$|H?Vrfe?32c3Z)V(@hJb6Mw<&;$TAOL+SL literal 0 HcmV?d00001 diff --git a/src/Identicon/Generator/BaseGenerator.php b/src/Identicon/Generator/BaseGenerator.php index fa280eb..366de4a 100644 --- a/src/Identicon/Generator/BaseGenerator.php +++ b/src/Identicon/Generator/BaseGenerator.php @@ -29,6 +29,11 @@ class BaseGenerator */ protected $size; + /** + * @var int + */ + protected $maigin; + /** * @var int */ @@ -247,4 +252,32 @@ public function getPixelRatio() { return $this->pixelRatio; } + + /** + * Set the image margin. + * + * @param int $margin + * + * @return $this + */ + public function setMargin($margin) + { + if (null === $margin) { + return $this; + } + + $this->margin = $margin; + + return $this; + } + + /** + * Get the image margin. + * + * @return int + */ + public function getMargin() + { + return $this->margin; + } } diff --git a/src/Identicon/Generator/GdGenerator.php b/src/Identicon/Generator/GdGenerator.php index 21ea922..7039f68 100644 --- a/src/Identicon/Generator/GdGenerator.php +++ b/src/Identicon/Generator/GdGenerator.php @@ -33,7 +33,7 @@ public function getMimeType() private function generateImage() { // prepare image - $this->generatedImage = imagecreatetruecolor($this->getPixelRatio() * 5, $this->getPixelRatio() * 5); + $this->generatedImage = imagecreatetruecolor($this->getPixelRatio() * 5 + $this->getMargin() * 2, $this->getPixelRatio() * 5 + $this->getMargin() * 2); $rgbBackgroundColor = $this->getBackgroundColor(); if (null === $rgbBackgroundColor) { @@ -51,8 +51,15 @@ private function generateImage() // draw content foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) { foreach ($lineValue as $colKey => $colValue) { - if (true === $colValue) { - imagefilledrectangle($this->generatedImage, $colKey * $this->getPixelRatio(), $lineKey * $this->getPixelRatio(), ($colKey + 1) * $this->getPixelRatio(), ($lineKey + 1) * $this->getPixelRatio(), $gdColor); + if (true === $colValue && 5 > $lineKey) { + imagefilledrectangle( + $this->generatedImage, + $this->getMargin() + $colKey * $this->getPixelRatio(), + $this->getMargin() + $lineKey * $this->getPixelRatio(), + $this->getMargin() + ($colKey + 1) * $this->getPixelRatio() -1, + $this->getMargin() + ($lineKey + 1) * $this->getPixelRatio() -1, + $gdColor + ); } } } @@ -63,10 +70,10 @@ private function generateImage() /** * {@inheritdoc} */ - public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null) + public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { ob_start(); - imagepng($this->getImageResource($string, $size, $color, $backgroundColor)); + imagepng($this->getImageResource($string, $size, $color, $backgroundColor, $margin)); $imageData = ob_get_contents(); ob_end_clean(); @@ -76,13 +83,14 @@ public function getImageBinaryData($string, $size = null, $color = null, $backgr /** * {@inheritdoc} */ - public function getImageResource($string, $size = null, $color = null, $backgroundColor = null) + public function getImageResource($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { $this ->setString($string) ->setSize($size) ->setColor($color) ->setBackgroundColor($backgroundColor) + ->setMargin($margin) ->generateImage(); return $this->generatedImage; diff --git a/src/Identicon/Generator/GeneratorInterface.php b/src/Identicon/Generator/GeneratorInterface.php index c6e8e0e..4ab8ef9 100644 --- a/src/Identicon/Generator/GeneratorInterface.php +++ b/src/Identicon/Generator/GeneratorInterface.php @@ -12,20 +12,22 @@ interface GeneratorInterface * @param int $size * @param array|string $color * @param array|string $backgroundColor + * @param int $margin * * @return mixed */ - public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null); + public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null, $margin = null); /** * @param string $string * @param int $size * @param array|string $color * @param array|string $backgroundColor + * @param int $margin * * @return string */ - public function getImageResource($string, $size = null, $color = null, $backgroundColor = null); + public function getImageResource($string, $size = null, $color = null, $backgroundColor = null, $margin = null); /** * Return the mime-type of this identicon. @@ -33,10 +35,10 @@ public function getImageResource($string, $size = null, $color = null, $backgrou * @return string */ public function getMimeType(); - + /** * Return the color of the created identicon. - * + * * @return array */ public function getColor(); diff --git a/src/Identicon/Generator/ImageMagickGenerator.php b/src/Identicon/Generator/ImageMagickGenerator.php index 0bcd349..09e9467 100644 --- a/src/Identicon/Generator/ImageMagickGenerator.php +++ b/src/Identicon/Generator/ImageMagickGenerator.php @@ -45,7 +45,7 @@ private function generateImage() $background = new ImagickPixel("rgb($rgbBackgroundColor[0],$rgbBackgroundColor[1],$rgbBackgroundColor[2])"); } - $this->generatedImage->newImage($this->pixelRatio * 5, $this->pixelRatio * 5, $background, 'png'); + $this->generatedImage->newImage($this->pixelRatio * 5 + $this->getMargin() * 2, $this->pixelRatio * 5 + $this->getMargin() * 2, $background, 'png'); // prepare color $rgbColor = $this->getColor(); @@ -57,8 +57,12 @@ private function generateImage() // draw the content foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) { foreach ($lineValue as $colKey => $colValue) { - if (true === $colValue) { - $draw->rectangle($colKey * $this->pixelRatio, $lineKey * $this->pixelRatio, ($colKey + 1) * $this->pixelRatio, ($lineKey + 1) * $this->pixelRatio); + if (true === $colValue && 5 > $lineKey) { + $draw->rectangle( + $this->getMargin() + $colKey * $this->pixelRatio, + $this->getMargin() + $lineKey * $this->pixelRatio, + $this->getMargin() + ($colKey + 1) * $this->pixelRatio - 1, + $this->getMargin() + ($lineKey + 1) * $this->pixelRatio) - 1; } } } @@ -71,10 +75,10 @@ private function generateImage() /** * {@inheritdoc} */ - public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null) + public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { ob_start(); - echo $this->getImageResource($string, $size, $color, $backgroundColor); + echo $this->getImageResource($string, $size, $color, $backgroundColor, $margin); $imageData = ob_get_contents(); ob_end_clean(); @@ -84,13 +88,14 @@ public function getImageBinaryData($string, $size = null, $color = null, $backgr /** * {@inheritdoc} */ - public function getImageResource($string, $size = null, $color = null, $backgroundColor = null) + public function getImageResource($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { $this ->setString($string) ->setSize($size) ->setColor($color) ->setBackgroundColor($backgroundColor) + ->setMargin($margin) ->generateImage(); return $this->generatedImage; diff --git a/src/Identicon/Generator/SvgGenerator.php b/src/Identicon/Generator/SvgGenerator.php index 7e753e8..b619984 100644 --- a/src/Identicon/Generator/SvgGenerator.php +++ b/src/Identicon/Generator/SvgGenerator.php @@ -18,21 +18,22 @@ public function getMimeType() /** * {@inheritdoc} */ - public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null) + public function getImageBinaryData($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { - return $this->getImageResource($string, $size, $color, $backgroundColor); + return $this->getImageResource($string, $size, $color, $backgroundColor, $margin); } /** * {@inheritdoc} */ - public function getImageResource($string, $size = null, $color = null, $backgroundColor = null) + public function getImageResource($string, $size = null, $color = null, $backgroundColor = null, $margin = null) { $this ->setString($string) ->setSize($size) ->setColor($color) ->setBackgroundColor($backgroundColor) + ->setMargin($margin) ->_generateImage(); return $this->generatedImage; @@ -44,9 +45,9 @@ public function getImageResource($string, $size = null, $color = null, $backgrou protected function _generateImage() { // prepare image - $w = $this->getPixelRatio() * 5; - $h = $this->getPixelRatio() * 5; - $svg = ''; + $w = $this->getPixelRatio() * 5 + $this->getMargin() * 2; + $h = $this->getPixelRatio() * 5 + $this->getMargin() * 2; + $svg = ''; $backgroundColor = '#FFF'; $rgbBackgroundColor = $this->getBackgroundColor(); @@ -54,14 +55,14 @@ protected function _generateImage() $backgroundColor = $this->_toUnderstandableColor($rgbBackgroundColor); } - $svg .= ''; + $svg .= ''; $rects = []; // draw content foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) { foreach ($lineValue as $colKey => $colValue) { - if (true === $colValue) { - $rects[] = 'M'.$colKey.','.$lineKey.'h1v1h-1v-1'; + if (true === $colValue && 5 > $lineKey) { + $rects[] = 'M'.($colKey*$this->getPixelRatio()+$this->getMargin()).','.($lineKey*$this->getPixelRatio()+$this->getMargin()).'h'.$this->getPixelRatio().'v'.$this->getPixelRatio().'h-'.$this->getPixelRatio().'v-'.$this->getPixelRatio(); } } } diff --git a/src/Identicon/Identicon.php b/src/Identicon/Identicon.php index 7a8e088..742ca8f 100644 --- a/src/Identicon/Identicon.php +++ b/src/Identicon/Identicon.php @@ -50,11 +50,12 @@ public function setGenerator(GeneratorInterface $generator) * @param int $size * @param string|array $color * @param string $backgroundColor + * @param int $margin */ - public function displayImage($string, $size = 64, $color = null, $backgroundColor = null) + public function displayImage($string, $size = 64, $color = null, $backgroundColor = null, $margin = 0) { header('Content-Type: '.$this->generator->getMimeType()); - echo $this->getImageData($string, $size, $color, $backgroundColor); + echo $this->getImageData($string, $size, $color, $backgroundColor, $margin); } /** @@ -64,12 +65,13 @@ public function displayImage($string, $size = 64, $color = null, $backgroundColo * @param int $size * @param string|array $color * @param string $backgroundColor + * @param int $margin * * @return string */ - public function getImageData($string, $size = 64, $color = null, $backgroundColor = null) + public function getImageData($string, $size = 64, $color = null, $backgroundColor = null, $margin = 0) { - return $this->generator->getImageBinaryData($string, $size, $color, $backgroundColor); + return $this->generator->getImageBinaryData($string, $size, $color, $backgroundColor, $margin); } /** @@ -79,12 +81,13 @@ public function getImageData($string, $size = 64, $color = null, $backgroundColo * @param int $size * @param string|array $color * @param string $backgroundColor + * @param int $margin * * @return string */ - public function getImageResource($string, $size = 64, $color = null, $backgroundColor = null) + public function getImageResource($string, $size = 64, $color = null, $backgroundColor = null, $margin = 0) { - return $this->generator->getImageResource($string, $size, $color, $backgroundColor); + return $this->generator->getImageResource($string, $size, $color, $backgroundColor, $margin); } /** @@ -94,12 +97,13 @@ public function getImageResource($string, $size = 64, $color = null, $background * @param int $size * @param string|array $color * @param string $backgroundColor + * @param int $margin * * @return string */ - public function getImageDataUri($string, $size = 64, $color = null, $backgroundColor = null) + public function getImageDataUri($string, $size = 64, $color = null, $backgroundColor = null, $margin = 0) { - return sprintf('data:%s;base64,%s', $this->generator->getMimeType(), base64_encode($this->getImageData($string, $size, $color, $backgroundColor))); + return sprintf('data:%s;base64,%s', $this->generator->getMimeType(), base64_encode($this->getImageData($string, $size, $color, $backgroundColor, $margin))); } /** diff --git a/tests/Identicon/Tests/IdenticonTest.php b/tests/Identicon/Tests/IdenticonTest.php index 85c6f39..5a91d81 100644 --- a/tests/Identicon/Tests/IdenticonTest.php +++ b/tests/Identicon/Tests/IdenticonTest.php @@ -31,11 +31,11 @@ public function testGdResult($string, $imageData) public function gdResultDataProvider() { return [ - ['Benjamin', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAAkklEQVRoge3YwQnAIBAF0WxIYSltS0tplpB/EByWeWdRBj0sVr99Zfr7X3lktzs8kswGBhsYbGCwgcEGhgkNlU9pWBWuO5WajLcT3pINDDYw2MBgA4MNDBNmvmf7jnu/NBMT3pINDDYw2MBgA4MNDBNmvgn3YAODDQw2MNjAYAODDQz+8zHYwGADgw0MNjDYwLAAnSEUgrvPyzUAAAAASUVORK5CYII='], - ['8.8.8.8', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAAmklEQVRoge3ZwQ2AIBAFUddQmCVYiqVYiiVYmi38A8HJZt6ZbJzAgUhtmec+wpXn9S6etoezyGxgsIHBBgYbGGxg6NAw8uvXL5LP67APNjDYwGADgw0MNjDYwGADgw0MNjDYwGADgw0MBf/Plxj50vUPz+G0DmfJBgYbGGxgsIHBBoYODTV33Nw7X6jDPtjAYAODDQw2MNjA8AG7FBQE2EpVGwAAAABJRU5ErkJggg=='], - ['8.8.4.4', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAAjUlEQVRoge3Y0QmAMAwAUSMO4AiO5miO5giO4AoRYj3Dve9SerQfobFf55RzrFtyZZXk2eaXjzGCDQw2MNjAYAODDQw2SJIk6Q+i9p/vk906zK02MNjAYAODDQw2MHRoeDDzYUVyHXm87fCWbGCwgcEGBhsYbGBYynccP0R2uAcbGGxgsIHBBgYbGDo03F0LGCmCZDLpAAAAAElFTkSuQmCC'], - ['yzalis', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAApklEQVRoge3Y0QmFMBAF0ZeHhViKJVmKJVmKpViCV1h1WOZ8h5AxfiwZv8yxb+HKWvOyXq75v3COp9nAYAODDQw2MNjAYAPDqN0uH2+TgTTU4R5sYLCBwQYGGxhsYBhfPeAVmsp3TIa52g/X4V+ygcEGBhsYbGCwgaFDw425tfBlLhSercM92MBgA4MNDDYw2MDQ4Z2vwz3YwGADgw0MNjDYwNCh4QQmpBMQ2jP6OQAAAABJRU5ErkJggg=='], - ['benjaminAtYzalisDotCom', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAAm0lEQVRoge3ZwQmAQAwFUSMWZCmWYGmWYCmWZAv/IOsY551DYGAPga0ps59rOHls1+Btc7iLzAYGGxhsYLCBwQaGDg2Vn19YSz46/iANt3V4SzYw2MBgA4MNDDYw/OzmCz17GiY6vCUbGGxgsIHBBgYbGDrcfBXOvZXq//R32MBgA4MNDDYwdGjocPP5t8tgA4MNDDYw2MBgA8MNwagdgwLhJLwAAAAASUVORK5CYII='], + ['Benjamin', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAlUlEQVRoge3YwQmAQAwFUVcszNK2NEuzhY8EHD7zzmFhyCXs2vc+AvvJxv547UyG4GxgsIHBBgYbGGxgaGhY4Vx4fs0KT8OGPdjAYAODDQw2MNjA0NCwZo+52Q+8UMMebGCwgcEGBhsYbGBoaBi++X7RsAcbGGxgsIHBBgYbGBoartnn/Of7yAYGGxhsYLCBwQaGhoYXxcATQQHji8YAAAAASUVORK5CYII='], + ['8.8.8.8', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAlElEQVRoge3ZwQ2AIBAFUTEUZgmWYimUYgmWZgv/QGTczDtvCBMuBNqWuceRjJ3X8/1qezIEZwODDQw2MNjAYANDhYYeXr+WCPdW4RxsYLCBwQYGGxhsYLCBwQYGGxhsYLCBwQYGGxh6OLfk09Z3vl+xgcEGBhsYbGCwgaHNXW7unS9U4RxsYLCBwQYGGxhsYKjQ8ALz9xKFMt4jEAAAAABJRU5ErkJggg=='], + ['8.8.4.4', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAjElEQVRoge3YQQ2AMBAFUUoQgASkIa3SkIAELOxhgcnPvHPT7KSXTcd5X0vB3I/KsV7F2daXx/iCDQw2MNjAYAODDQwJDZIkSco3ev/5frktYfe2gcEGBhsYbGCwgSGhYRTPkVfDhHewgcEGBhsYbGCwgSGhYeu9rrjM9Up4BxsYbGCwgcEGBhsYEhoeQmYV+Lw+DlQAAAAASUVORK5CYII='], + ['yzalis', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAApElEQVRoge3YwQ2DMBAFUUwllEJJKYWSUkpKoYV/WMLoa97ZAo/2svLaMr/vFZ4cdJyf5Nj+9D3+wAYGGxhsYLCBwQaGhoY1+7lwNQyXuVDDHGxgsIHBBgYbGGxgaGhYsw944TI3+9OGOdjAYAODDQw2MNjA0NCQ7nyzL3Oh8G4Nc7CBwQYGGxhsYLCBoaFh+J3vFQ1zsIHBBgYbGGxgsIGhoeEGheQTDhfmg8cAAAAASUVORK5CYII='], + ['benjaminAtYzalisDotCom', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAIAAAABlV4SAAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAlUlEQVRoge3ZwQmAMBAFUWNFlmIJlmYJKcWSbOEfgoyfeeclMOxlIWPLXPNIxu7z+f61PRmCs4HBBgYbGGxgsIGhoWGQj7nwtYY92MBgA4MNDDYw2MDQ0JDefKG1x1yoYQ82MNjAYAODDQw2MDQ0jHBu7ZUW8m/3V2xgsIHBBgYbGGxg8G+XwQYGGxhsYLCBwQaGhoYXS88cPpLHUdMAAAAASUVORK5CYII='], ]; } @@ -51,11 +51,11 @@ public function testImageMagickResult($string, $imageData) public function imageMagickResultDataProvider() { return [ - ['Benjamin', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAQMAAAC0OVsGAAAABlBMVEUAAACAQIBZk25qAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAASAAAAEgARslrPgAAADJJREFUKM9j+P+Hwf4/A///BoYBY0FBAwMDO4j+wcBAZxbCBUDiAePAsBAuGHjWQIQBAEylsffAMPtMAAAAAElFTkSuQmCC'], - ['8.8.8.8', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAQMAAAC0OVsGAAAABlBMVEUAAACwkEBnpIxVAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAASAAAAEgARslrPgAAADJJREFUKM9jYGD//4Dx/w8GIBgg1v//INb//w0jmwUGQNYfBvv/DPwDyAICIAsK6McCAHgaRw8ODosjAAAAAElFTkSuQmCC'], - ['8.8.4.4', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAQMAAAC0OVsGAAAABlBMVEUAAABg8OBZBnEqAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAASAAAAEgARslrPgAAADJJREFUKM9j+P+HAQj4/zcwDDxroADQBfb/YW4ZGBYUAMOA/f8Dxv8/QM6iNwsIBpAFAJTD5znOXx4GAAAAAElFTkSuQmCC'], - ['yzalis', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAQMAAAC0OVsGAAAABlBMVEUAAADgwJA3cC1lAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAASAAAAEgARslrPgAAADFJREFUKM9jYGD/DwQ/GIBg4FkMDPb/GRjozvoPBQ0g1gPGgWX9AbmIn/4s5DAYCBYAaeRVTUt0KIYAAAAASUVORK5CYII='], - ['benjaminAtYzalisDotCom', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAQMAAAC0OVsGAAAABlBMVEUAAABgsDAvrOz7AAAAAXRSTlMAQObYZgAAAAlwSFlzAAAASAAAAEgARslrPgAAADlJREFUKM9jYGD//4Dx/w8GIBgg1n8oaGD4/4fB/j8DP/1ZCBf8B7lqQFhQFwDDBQigIURH1oDHAgCNSlrmMVCO8AAAAABJRU5ErkJggg=='], + ['Benjamin', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAgMAAADzmSHWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEUAAACAQID///8oxzV4AAAAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAA8SURBVDjLYwgNDXVgYGANDQ1hYGAAc4axCAoASjMwiMK5DFAwDEQwfQqhAxgYGIejCKZPR47IYIsLikUAXrQYrSbv5GcAAAAASUVORK5CYII='], + ['8.8.8.8', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAgMAAADzmSHWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEUAAACwkED////TBaOKAAAAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAA9SURBVDjLY2BgYBANDQ1gYGAMDQ1lgIJhKRIKBlARIHAYFRkmIggAFnFgYGANDQ2BRPnwFYEAqAgSGOIiAB3H0FdakQbSAAAAAElFTkSuQmCC'], + ['8.8.4.4', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAgMAAADzmSHWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEUAAABg8OD///8VYtHtAAAAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAA3SURBVDjLYwgNDXVggAEwZ+SIDFcA8RxraGgIqt+HpQgKAMepaGhoAAMDI5ALC5BhIwIFw1kEAMDHlqDrjun5AAAAAElFTkSuQmCC'], + ['yzalis', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAgMAAADzmSHWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEUAAADgwJD////BzN0vAAAAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAA4SURBVDjLY2BgYBANhQEGKBg5IkDAGhoawoAChrpIKBpwgIoEMDAwjgARBwakgBhGIljjdNiJAAAFB94SnyJ2kgAAAABJRU5ErkJggg=='], + ['benjaminAtYzalisDotCom', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBAgMAAADzmSHWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEUAAACQoHD///+Fo+abAAAAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAApSURBVDjLYwhFAw4MI00kgIGBcVRkKIsgxykQiMK5DFAwDEQwfTpMRQAjXjJt/R2NWQAAAABJRU5ErkJggg=='], ]; } @@ -71,15 +71,11 @@ public function testSvgResult($string, $imageData) public function svgResultDataProvider() { return [ - ['Benjamin', ''], - - ['8.8.8.8', ''], - - ['8.8.4.4', ''], - - ['yzalis', ''], - - ['benjaminAtYzalisDotCom', ''], + ['Benjamin', ''], + ['8.8.8.8', ''], + ['8.8.4.4', ''], + ['yzalis', ''], + ['benjaminAtYzalisDotCom', ''], ]; } }