/** * @param resource $logo * @param string $id * @param int $width * @param int $height * @param Request $request * @param Response $response */ public function resize(Logo $logo, $width, $height, Request $request, Response $response) { $path = $this->getPath('logo_' . $logo->getId(), $width, $height); $response->setPublic(); $response->setContentType($logo->getMimeType()); $response->setLastModified($logo->getCreatedAt()); if ($response->isNotModified($request)) { return; } if (file_exists($path)) { return file_get_contents($path); } $image = $this->factory->createFromResource($logo->getImage()); return $this->getImageContent($image, $path, $width, $height, array($this->resizer, 'scale')); }
/** * @param string $filename * @throws InvalidArgumentException */ protected function validateImage($filename) { $image = $this->imageFactory->createFromFile($filename); if (!$this->imageValidator->isTransparentPng($image)) { throw new InvalidArgumentException('O logotipo deve ser um PNG com fundo transparente'); } }