We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

GD resize error

Hello,

if I try to resize image with GD extension, it throws me "500 - Internal Server Error". My error log shows:

 2014-12-19 18:40:13: (mod_fastcgi.c.2562) unexpected end-of-file (perhaps the fastcgi process died): pid: 2883 socket: unix:/var/lib/lighttpd/sockets/php-fastcgi-1.socket-1 
2014-12-19 18:40:13: (mod_fastcgi.c.3346) response not received, request sent: 16646 on socket: unix:/var/lib/lighttpd/sockets/php-fastcgi-1.socket-1 for /index.php?, closing connection 

my code:

$this->_instance->resize($this->width, $this->height)->save();

if I try to save without resize or use Imagick, everything works fine. One additional thing - if I try to get image width or height with $this->image->getWidth(), it shows very big integer.


                var_dump($this->_instance->getWidth());
                var_dump(imagesx($this->_instance->getImage()));
                die;

Shows:

int 140623968722816

int 260

Any ideas how to solve this problem without extending GD class?



58.4k

You can checking tip GD here

I have problem with phalcon function, not with code logic.

You can checking tip GD here

I found a problem. In documentation said, I can pass width & height variables:

https://docs.phalcon.io/en/latest/api/Phalcon_Image_Adapter_GD.html
public __construct (string $file, [unknown $width], [unknown $height])

And if I pass these variables, my image becames:

object(Phalcon\Image\Adapter\GD)[113]
  protected '_image' => resource(92, gd)
  protected '_file' => string '/tmp/phpPp4lHI' (length=14)
  protected '_realpath' => string '/tmp/phpPp4lHI' (length=14)
  protected '_width' => int 140623968751320
  protected '_height' => int 140623968750848
  protected '_type' => int 2
  protected '_mime' => string 'image/jpeg' (length=10)

So I remove width & height from constructor. Now everything works fine:

object(Phalcon\Image\Adapter\GD)[113]
  protected '_image' => resource(92, gd)
  protected '_file' => string '/tmp/phpihT1Sf' (length=14)
  protected '_realpath' => string '/tmp/phpihT1Sf' (length=14)
  protected '_width' => int 260
  protected '_height' => int 195
  protected '_type' => int 2
  protected '_mime' => string 'image/jpeg' (length=10)