Intervention does not support SVG files.. http://image.intervention.io/getting_started/formats
NotReadableException when trying to upload svg files. Using Intervention Image for image modifications
Hi,
I'm using the Intervention Image package to make some modifications to images (like resizing) after they've been uploaded. However for svg files this hasn't been possible, getting the following exception:
NotReadableException in Decoder.php line 21: Unable to read image from file (/tmp/phpapVWWg).
I can't really figure out what the problem is. The following is the code used for the transformation using Intervention:
class ImageResizer implements FileTransformation {
private $xSize;
private $ySize;
function __construct($xSize, $ySize)
{
$this->xSize = $xSize;
$this->ySize = $ySize;
}
/**
* @param TransformableFile $transformableFile
* @return mixed image resized
*/
function transform(TransformableFile $transformableFile)
{
$resource = $transformableFile->file();
$xSize = $this->xSize;
$ySize = $this->ySize;
$transformedImage = Image::make($resource->getRealPath())->resize($xSize,$ySize)->encode('png');
$newTransformable = new ImageTransformed($transformedImage);
return $newTransformable;
}
}
TransformableFile is actually the uploaded file. This class implements a FileTransformation interface which lets me choose at any time, which transformation to apply to an uploaded image. That's why it returns another UploadedFile. The problem i think is not in this implementation, but the way Intervention handles svg's. In fact the exception is thrown inside the 'make' call.
I really thank any advice or solution for this.
Please or to participate in this conversation.