Resizing image using Imagine bundle blurs Image

917 views Asked by At

I have the following code:

        $imagine = new \Imagine\Gd\Imagine();
        $image = $imagine->open($src);
        $image_size = $image->getSize();
        $image_height = $image_size->getHeight();
        $image_width = $image_size->getWidth();
        $ratio = 1;



        $resized_image = $image;

        $ratio = $image_width / $desired_width;

        $this->resizedHeight = $image_height / $ratio;
        $this->resizedWidth = $image_width / $ratio;
            // thumbnailDir doesn t exist
        if(!is_dir(dirname($des)))
                mkdir(dirname($des), 0777, true);

        $resized_image = $image->resize(new Box($this->resizedWidth, $this->resizedHeight));


        $options = array(
            'resolution-units' => ImageInterface::RESOLUTION_PIXELSPERINCH,
            'resolution-x' => 500,
            'resolution-y' => 500,
            'flatten' => false
        );

        $resized_image->save($des, $options);

For some reason the resized image is always a bit blurry, you can see the resized image here and the original image here and here's the resized image. I am running out of ideas why this is. Any idea why?

2

There are 2 answers

0
dazed-and-confused On

I've had extensive experience using Imagemagick and it's an extremely powerful command line graphics editing utility. I'm positive they have resize options that will keep the quality in tact. Most online web hosts provide it free for use. I believe there are PHP wrappers around it but I learned the commands myself and didn't bother with the wrappers.

The documentation and samples provided are very detailed and the forum is very active if you need help.

Check it out at: http://imagemagick.com/script/index.php

0
Prasad Saitwal On

When you re-size an image it will become blur you cant do anything.
Make a copy of original image, use it to display.
OR
Find another code for resize.