Fifiasco
1 month ago

Resizing images with Intervention / Imagick

Posted 1 month ago by Fifiasco

Hello all, I am just looking for some advice on resizing images using intervention/imagick. My case is unique but not obscure. I have a system that builds labels from parameters. These parameters include images, text and lines. The entirety of which is created using Intervention. I have no trouble with intervention, I have used it for a while however I am now running into a road bump. These labels I am creating should be W 184px x H 269px, so they are relatively small. If I create them at this size they are extremely pixelated and can not be used for print. If I create them 4x the size, they look perfect, crisp, clean exactly how I want them to look. This dramatic change is down to nothing but changing the dimensions. Just to be clear when I say the smaller image is pixelated I am viewing at the size I create it , I am not zooming right in and expecting it to look clean. It is pixelated at it's exported size.

The work around I had in mind was to create the image 4* the size then save it. Take that saved image and then resize it /4. The result however is the exact same, pixelated and not useable. If I take the large image, the one that is 4* larger and resize it in illustrator the quality is great, exactly how I would expect it to be. I am unsure why so much quality is being lossed a) when the label (image) is created at its intended size b) when I resize the large image. As I said before I am using Intervention with Imagick as the driver, I am now trying to use Imagick on its own, which I am again fairly comfortable with but I am still getting the same issue. I feel I have exhausted all options with this, Please see the current code block I am using to resize it with Imagick.

    $img = new \Imagick($path);

        $img->resizeImage($width/4,$height/4,\Imagick::FILTER_LANCZOS,1);
        $img->writeImage($pathFinal);

        $img->destroy();

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