简体   繁体   中英

Fatal error: Call to undefined function: imagejpeg() on Heroku PHP. Fix?

So, I am getting the following error whilst trying to upload images on my Heroku site (PHP).

 Fatal error: Call to undefined function: imagejpeg() 

It refers to the following line in my AmazonS3Handler.php file.

    //build the jpeg
    imagejpeg($destinationImage);

Any ideas on how I could fix this?

I had GD lib installed and got the same error. The problem was in compiling without jpeg support. Here what you should do to make things work.

1. Install libjpeg

apt-get install libjpeg62-turbo-dev

2. Configure PHP with jpeg support

./configure \
--with-gd
--with-jpeg-dir=/usr/lib64
# other options

3. Build PHP

make clean
make
make install

First stop the local server XAMPP or WAMP

In XAMPP

  1. Goto xampp installed folder and then go to php folder and find php.ini file
  2. and see if your GD library is commented out. If so, remove the comment.
  3. ;extension=gd (this one is commented one)
  4. extension=gd (Remove; to uncomment)

Example path: C:\xampp\php\php.in

In wamp

  1. Go to the wamp installed folder, then to the bin folder, and then go to the php folder.
  2. And then goto php7.0.10, php5.6.25, or something else php version folder and find php.ini file.
  3. ;extension=gd (this one is commented one)
  4. extension=gd (Remove; to uncomment)

Example path: C:\wamp64\bin\php\php7.0.10

If you can't find the extension=gd, add it yourself

Find "extension=" in the php.ini file and place it after any extension.

Then restart your local server, and everything should be fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM