Answer the question
In order to leave comments, you need to log in
How to improve crop quality in PHP?
Tell me, what can cause the loss of detail in photos after processing?
imagecreatefromjpeg
method
imagecreatetruecolor
imagecopyresampled
imagejpeg($img, $name, 100)
You need to crop the photo and add it. Everything works fine until I did the same with Photoshop. I did not touch the settings in Photoshop, the quality is also maximum. At the same time, the sharpness is much greater in FS and the weight of the photo is 15-20%.
Really PHP is not able to do high-quality resize? Like mathematics and in Africa - mathematics))
Answer the question
In order to leave comments, you need to log in
You need php.net/manual/en/book.imagick.php
There are various methods, some are medium quality incrustation and reduction and some are like PS.
But you must understand that with good quality there will be a good load.
$i = new \Imagick($target);
// По сути сначала вы делаете кроп
$i->cropImage(...);
// Затем уменьшаете без потери качества
$i->ThumbnailImage($width, $height, true);
imagejpeg() - don't specify the quality? the default is about 75.
imagecopyresampled - if you resize, this can also break the image.
In Photoshop, the choice of compression algorithms is much wider, GD is not even close. Better in imagemagick, but far from photoshop.
https://foliovision.com/2010/03/imagemagick-vs-gd
Strictly personal opinion - the algorithm is different for the algorithm, for example, I once tested several different approaches, libraries, pushed GD with Imagick, etc. - the difference was felt.
As for Photoshop - I think that just ADOBE, being cool developers and working on their product for a long time, finalized or reworked the jpeg compression algorithms.
I can be wrong.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question