Marcel Niehüsener Marcel Niehüsener - 1 month ago 17
PHP Question

imagescale does not work correctly

I'm copying a part of an image using

imagescale
:

$img = imagecreatefromjpeg('before.jpg');
$img = imagescale($img, 660, 384);


Before:
Before imagescale

After:
After imagescale

Using images with less colors works.

Answer

Comments in the PHP documentation propose a solution.

http://php.net/manual/en/function.imagescale.php

imageScale has got troubles with scaling images... It can output Segmentation Fault when you want to provide custom $mode argument. How to scale image with interpolation in php gd? Use imagecopyresampled() instead of imagescale().