samedi 28 mars 2015

Intervention Image degrades quality of image on resize

Im using Intervention Image to upload two versions (small and large) of a single image to display on different pages.


The user always uploads the image 1000 x 1000 pixels and the original is used on a single product product page and the smaller version on an 'all products' page.


This works fine except the image that is being downsized has terrible quality. It's pixelated.


I'm using Laravel 4.2. My version of php is 5.5.11. And I'm developing with Xampp on my local host. I've looked at this question and I'm pretty sure GD is installed.


Is it because GD is not as good as imagick? Because I can't for the life of me seem to install that thing...


EDIT: This was the problem! I finally managed to get imagick working and changed it to the driver. Great quality images.


Here's my route, though I don't think this is where the problem is:



$file = Input::file('photo');
$fileName = Input::get('name').'.'.$file->getClientOriginalExtension();
$fileName= str_replace(' ', '_', $fileName);
$destinationPath = 'productphotos/';

// upload new image
Image::make($file->getRealPath())
// original
->save($destinationPath.$fileName)
// resize
->resize(300, 300) // set true if you want proportional image resize
->save($destinationPath.'resize'.$fileName, 100);



$aDetails = Input::all();
$aDetails["photo"] = $fileName;
$aDetails["smallphoto"] = 'resize'.$fileName;
Product::create($aDetails);

return Redirect::to("products/".Input::get("product_id"));


You can see the difference between the stock test (original size 1000x1000) and testresize(300x300). They are being displayed at 218x218. You can see the difference between the stock test (original size 1000x1000) and testresize(300x300). They are both being displayed at 218x218.


Aucun commentaire:

Enregistrer un commentaire