/** * {@inheritdoc} */ public function createThumbnail($imagePath, $destination, $maxWidth, $maxHeight, $keepProportions = false, $quality = 90) { if (!$this->mediaService->has($imagePath)) { throw new \Exception("File not found: " . $imagePath); } $content = $this->mediaService->read($imagePath); $image = $this->createImageResource($content, $imagePath); // Determines the width and height of the original image $originalSize = $this->getOriginalImageSize($image); if (empty($maxHeight)) { $maxHeight = $maxWidth; } $newSize = array('width' => $maxWidth, 'height' => $maxHeight); if ($keepProportions) { $newSize = $this->calculateProportionalThumbnailSize($originalSize, $maxWidth, $maxHeight); } $newImage = $this->createNewImage($image, $originalSize, $newSize, $this->getImageExtension($destination)); if ($this->fixGdImageBlur) { $this->fixGdImageBlur($newSize, $newImage); } $this->saveImage($destination, $newImage, $quality); // Removes both the original and the new created image from memory imagedestroy($newImage); imagedestroy($image); }
/** * @param string $path */ private function _testRead($path) { $content = $this->mediaService->read($path); $this->assertJsonStringEqualsJsonString($content, json_encode($this->testData)); }