| Conditions | 3 |
| Paths | 3 |
| Total Lines | 31 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function render() |
||
| 11 | { |
||
| 12 | $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath(); |
||
| 13 | if ($pathThumbnail) { |
||
| 14 | // Size : 128x128 pixel |
||
| 15 | // PNG : 8bit, non-interlaced with full alpha transparency |
||
| 16 | $gdImage = imagecreatefromstring(file_get_contents($pathThumbnail)); |
||
| 17 | if ($gdImage) { |
||
| 18 | list($width, $height) = getimagesize($pathThumbnail); |
||
| 19 | |||
| 20 | $gdRender = imagecreatetruecolor(128, 128); |
||
| 21 | $colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127); |
||
| 22 | imagecolortransparent($gdRender, $colorBgAlpha); |
||
| 23 | imagefill($gdRender, 0, 0, $colorBgAlpha); |
||
| 24 | imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height); |
||
| 25 | imagetruecolortopalette($gdRender, false, 255); |
||
| 26 | imagesavealpha($gdRender, true); |
||
| 27 | |||
| 28 | ob_start(); |
||
| 29 | imagepng($gdRender); |
||
| 30 | $imageContents = ob_get_contents(); |
||
| 31 | ob_end_clean(); |
||
| 32 | |||
| 33 | imagedestroy($gdRender); |
||
| 34 | imagedestroy($gdImage); |
||
| 35 | |||
| 36 | $this->getZip()->addFromString('Thumbnails/thumbnail.png', $imageContents); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | return $this->getZip(); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |