K
K
Kirill Firsov2011-03-08 16:32:28
PHP
Kirill Firsov, 2011-03-08 16:32:28

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 :
ff90d871.jpg
Photo quality by my script:
75c6265b.jpg
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

4 answer(s)
H
HnH, 2011-03-08
@Isis

[may be wrong]imagecopyresized replace with imagecopyresampled[/may be wrong]

N
niko83, 2011-03-08
@niko83

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
Ivan Klimchuk, 2011-03-08
@Alroniks

I think VKontakte does not use GD. At one time, he himself faced a quality problem. It's better to use imagemagic.

J
Jazzist, 2011-03-08
@Jazzist

Use imagemagick
convert FROM -resize WxH -quality 90 TO
PHP example:
$original
exec('convert '.$original.' -resize '.$size.' -quality 90 '.$to);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question