2 years ago

Trouble saving Imagick created file

Posted 2 years ago by cservices

I am using Imagick to create a thumbnail image of a PDF page.

I’m getting everything to work, except I can’t figure out how to save the image.

$file['temp_path'] is the temp location of the PDF file that is being uploaded. I’m telling Imagick to use that version of the file to create the thumbnail image.

From there I’m going to a best fit of 200 x 200, and creating the image as a jpeg.

The raw image is kept in $imagick->getImageBlob() (I think), but I don’t know how to store this to my storage location.

The storage location depends on the type of file being downloaded. In this case “storage/app/public/docs/pdf”.

Can someone please show me the best way to save the thumbnails to the storage location, according to Laravel?


$imagick = new \Imagick($file['temp_path']);
$imagick->resizeImage(200, 200, \Imagick::FILTER_LANCZOS, 1,1);
$file_name = $filename_minus_ext . "-" . time() . "jpg";

Please sign in or create an account to participate in this conversation.