Answer the question
In order to leave comments, you need to log in
PHP Quality preview photos?
Hello.
What can be used to achieve the same quality of creating photo previews as VKontakte?
I am using GD.
Vkontakte photo quality :
Photo quality by my script:
Large photo: habrastorage.org/storage/cc25b25a/d18df0d0/cf683fb...
With all this, a VKontakte photo with the best quality weighs 7kb, and mine is 16kb ...
My script: pastebin.com/YUAYdPCf
There are actually 2 problems to be solved.
Make the quality better and at the same time reduce the size of the preview.
Answer the question
In order to leave comments, you need to log in
[may be wrong]imagecopyresized replace with imagecopyresampled[/may be wrong]
Use GraphicsMagick - and don't forget to use a filter to add sharpness .
The filter gives clarity to the image, (although it is not used in the example on the VKontakte photo)
in the console call add the parameter '-sharpen 1x10'
(you can also ImageMagick there also has this filter)
a fragment for GraphicksMagick of one PHP or (I don’t remember the name, but if you are interested I will find it)
$command = $this->gmPath.' convert'
. ' ' . escapeshellcmd($path) . ' -crop'
. ' ' . $srcWidth . 'x' . $srcHeight . '+' . $srcX . '+' . $srcY
. ' -resize ' . $dstWidth . 'x' . $dstHeight
. ' -sharpen 1x10'
. ' -quality 75'
. ' ' . escapeshellcmd($cacheFile);
exec($command);
I think VKontakte does not use GD. At one time, he himself faced a quality problem. It's better to use imagemagic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question