translator = $translator; $this->imageManager = $imageManager; } /** * {@inheritdoc} */ protected function makeImage(UploadedFileInterface $file): Image { $this->fileExtension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION); if ($this->fileExtension === 'ico') { // @todo remove in 2.0 throw new ValidationException([ 'message' => strtr($this->translator->trans('validation.mimes'), [ ':attribute' => 'favicon', ':values' => 'jpeg,png,gif,webp', ]) ]); } $encodedImage = $this->imageManager->make($file->getStream())->resize(64, 64, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('png'); $this->fileExtension = 'png'; return $encodedImage; } }