L
L
lemonlimelike2018-08-05 00:13:55
PHP
lemonlimelike, 2018-08-05 00:13:55

How to change the Intervention Image format?

Hello. Installed the "Intervention Image" plugin. I just can’t figure out how to change the image format, let’s say an image in jpg format comes from the client, how can I change the image format in gif?
Here's what my code looks like:

$input = $request->all();
    $image = $input['image'];

    $filename  = time() . '.' . $image->getClientOriginalExtension();
    $path = public_path('img/' . $filename);

    $img = Image::make($image);
    $img->save($path);

    $add = new Content();
    $add->name = $input['name'];
    $add->title = $input['name'];
    $add->keywords = $input['keywords'];
    $add->url = 'img/'.$filename;
    $add->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2018-08-05
@lemonlimelike

$add->->encode('gif');
$add->save();

Don't forget to change the PS file extension
: converting jpg to gif is pretty pointless

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question