I want to encode image from png to jpg but for some reason it doesn’t work. Although judging by the examples it should, what can be a problem? It does the resize part, but when it comes to changing the extension, it does nothing
$image_destination_path = 'images/';
$employee_image = date('YmdHis') . '.png';
$image->move($image_destination_path, $employee_image);
$img = Image::make('images/' . $employee_image)->resize(300, 300);
// save file as jpg with medium quality
$img->encode('jpg', 80)->save('images/'. $employee_image);
One person here had the same problem and he solved it by changing this line:
$employee_image = date('YmdHis') . "." . $image->getClientOriginalExtension();
Like this:
$employee_image = date('YmdHis') . '.png';
But it did nothing for me.
3
Answers
I achieved it using this code:
This can be done easily using the PHP GDImage class functions:
Using pure intervention methods: