To the left is an image created by Phalcon, to the right - by using PHP directly.
As you see, quality loss and difference when using Phalcon is significant. What could be the problem?
Here's Phalcon code:
$newWidth = 160;
$image = new \Phalcon\Image\Adapter\GD($filename);
$width = $image->getWidth();
$height = $image->getHeight();
$newHeight = floor($height * $newWidth / $width);
$image->resize($newWidth, $newHeight);
$explode = explode('.', $filename);
$ext = array_pop($explode);
$path = new Path();
$postfix = ($newWidth == $this->config->media->thumb) ? 'tn' : $newWidth;
$image->save($path->buildUploadDir($id, $ext, $postfix));
Here's PHP directly:
$w = 160;
$file = APP_PATH . 'public/tmp/test.jpg';
list($width, $height) = getimagesize($file);
$r = $width / $height;
$h = floor($r*$height);
$newwidth = $h*$r;
$newheight = $h;
$src = imagecreatefromjpeg($file);
$dst = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($dst, APP_PATH . 'public/tmp/tn.jpg');
What could be the issue? Is this a Phalcon bug which should be reported?