在laravel 4中上传svg图像时出现"无法读取图像"错误

hem*_*iya 3 php svg gd laravel laravel-4

我有代码,可用于jpg,png图像调整图像大小,这里是代码示例.

$image = Image::make("{$filePath}/{$fileName[0]}");
// Get the maximum uploaded image width
$maxWidth = Config::get('constants.max_uploaded_image_width');

// Resize the image
$image->resize($maxWidth, null, function($constraint)
{
    // Set an aspect ratio constraint
    $constraint->aspectRatio();

    // Prevent upsizing
    $constraint->upsize();
});

// Save the image
$image->save("{$filePath}/{$fileName[0]}");
Run Code Online (Sandbox Code Playgroud)

这个jpgpng图像一起工作很好,但是当我使用svg它时会返回错误Unable to read image from file.有解决方案吗

Ale*_*nin 5

SVG不支持Intervention Image:

http://image.intervention.io/getting_started/formats

您可以使用ImageMagick进行操作SVG.