Skip to content
Advertisement

How to set Image Resolution in uploaded Image in Laravel Intervention

Please, anyone, help me I want to set the Image Resolution to 300dpi for the uploaded image using Image Intervention.

Any alternate solution is also welcome.

What I want:

Upload Image -> Resize image to (100 X 100) -> Set image size to less than 30KB -> and set image resolution to 300dpi -> auto download

I have done everything else the resolution to my project… Here I’m sending the code and link …

$width = 400;
$height = 200;

$file = $request->file('upload');
$image = Image::make($file)->resize($width, $height)->encode('jpg');

$headers = [
    'Content-Type' => 'image/jpeg',
    'Content-Disposition' => 'attachment; filename=utipanpsa_'.$request->type.'.jpg',
];

return response()->stream(function() use ($image) {
    echo $image;
}, 200, $headers);

https://www.utipanpsa.com/cropping-tools

Advertisement

Answer

acording to document you can use imageresolution() if you have php >= 7.2 like this:

//sets the image resolution to 200
imageresolution($imageRecource, 200);
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement