Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

php - imageantialias call to undefined function error with GD installed

I need help with a php script. It is a CMS that has been implemented into a website. When trying to add a new product IMAGE or trying to edit current images, I am getting the following error:

Fatal error: Call to undefined function imageantialias() in /home/mounts/home/m/mclh/web/admin/library/functions.php on line 233

This is my code for that area:

   if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
    {
       $destFile  = substr_replace($destFile, 'jpg', -3);
       $dest      = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } elseif ($tmpDest['extension'] == "png") {
       $dest = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } else {
      return false;
    }

Line 233 is the 5th line down.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

UPDATE: It seems the function imageantialias() is only available if PHP is compiled with GD, so it is not enough to have the extension included via extension file.

From the PHP manual:

Note: This function is only available if PHP is compiled with the bundled version of the GD library.

Please check your phpinfo() and see, if you find the flag --with-gd=shared (or a similar flag, maybe just --with-gd) in there. If you can't find it, your PHP has to be recompiled with this flag.

In more details: PHP extensions can either be loaded by including a .dll (Windows) or .so (Unix) file via php.ini or they can be compiled with PHP. Compiling sounds scary and crazy but it is actually really easy. All you need to do (Unix) is:

  1. copy the compile string which is shown in your phpinfo()
  2. add the required new flag
  3. run
    • ./configure ... all the stuff from your phpinfo plus the new flag
    • make clean
    • make
    • make install
  4. look at your phpinfo() and smile :)

First answer (didn't turn out to be correct):

imageantialias() is a function of the PHP GD extension. Is GD installed and properly configured?

From your code it seems that GD is installed because imagecreatetruecolor() is also a GD function and seems to work. This leads to the conclusion that you're using a PHP version prior to 4.3.2, which doesn't support imageantialias().

Please look at your phpinfo() to see if my conclusions are correct. There you will see what version of PHP your are using and you will also see if GD is installed and working!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...