This is my controller:
public function heic_to_jpg_convert(Request $request)
{
try {
$file = $request->file('file');
$outputJpgPath = time() . '.jpg';
HeicToJpg::convert($file->getRealPath())->saveAs(public_path('uploads/' . $outputJpgPath));
return response()->json(['message' => 'Conversion complete', 'jpg_path' => asset('uploads/' . $outputJpgPath)]);
} catch (\Exception $e) {
return response()->json(['error' => 'Conversion failed', 'message' => $e->getMessage()], 500);
}
}
The problem is some HEIC images successfully convert to JPG but mostly HEIC images not convert I got an error.
"Couldn't convert HEIC to JPG: '2024/01/02 13:14:58 error reading \"meta\" box: got box type \"mdat\" instead\\nError while converting /tmp/php2ZXnUA: error reading \"meta\" box: got box type \"mdat\" instead\\nCreated by MaestroError' | Bin used: 'heicToJpg' HEIC: '/tmp/php2ZXnUA' Full Command: '/var/www/html/image_convert/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg \"/tmp/php2ZXnUA\" \"/tmp/php2ZXnUA-7245407236593befad79509.30882965\" 2>&1' Output from heif-converter-image exe: "
how to fix this error to convert HEIC image to JPG in laravel 9 using "maestroerror/php-heic-to-jpg": "^1.0"