I am trying to integrate «pChart» with my PHP code. When I am trying to run the samples it gives me an error stating call to undefined function imagecreatetruecolor. The suggestion solution was to load this dll «php_gd2.dll» so I have uncommented extension=php_gd2.dll in php.ini file.
Even after that I get the same error. I have tried restarting the server & machine too.
hakre
189k51 gold badges426 silver badges824 bronze badges
asked Dec 30, 2010 at 8:03
3
Use the following code to test if you have GD extension:
<?php
$testGD = get_extension_funcs("gd"); // Grab function list
if (!$testGD){ echo "GD not even installed."; exit; }
echo"<pre>".print_r($testGD,true)."</pre>";
If you get the message that it’s not installed, then check the following steps:
phpinfo()and look up php.ini path- edit
php.ini: extension_dir=<path to your extensions> - edit
php.ini: extension=php_gd2.dll //uncomment or add - Restart web server
- Run the test script again
answered Dec 30, 2010 at 8:39
St.WolandSt.Woland
5,33730 silver badges30 bronze badges
1
In Ubuntu/Linux Mint Platform (under root), use the following command:
apt-get update && apt-get -y install php5-gd
Arbab Nazar
21.6k10 gold badges74 silver badges79 bronze badges
answered May 24, 2014 at 3:03
RanitoRanito
3313 silver badges2 bronze badges
2
For PHP 7.2
sudo apt-get install php7.2-gd
answered Aug 19, 2019 at 14:26
3
I met this problem just now.
You should exec sudo apt install php7.0-gd or vim your php.ini
reopen extension=php_gd2.dll
answered Oct 25, 2017 at 10:05
This answer is an update 9 years later, but PHP has changed a lot. Please upvote the St. Woland from which this is derived…
Use the following code on your web server to test if you have GD extension:
<?php
$testGD = get_extension_funcs("gd"); // Grab function list
if (!$testGD){
echo "GD not even installed.";
phpinfo(); // Display the php configuration for the web server
exit;
}
echo"<pre>".print_r($testGD,true)."</pre>"; //display GD function list
If you get the message that it’s not installed, then check the following steps:
- Look at the output of phpinfo() to identify your php.ini
- Edit
php.iniand enable the GD extension:- Newer PHP (7.3, fg):
- extension=gd2 //uncomment
- Older PHP (5.x, 7.0, you should upgrade):
- extension_dir=<path to your extensions> //uncomment or add
- extension=php_gd2.dll //uncomment or add
- Newer PHP (7.3, fg):
- GD for 7.x may not be installed
- (for Ubuntu like OS’es)
sudo apt install php7.3-gd# replace version to yours
- (for Ubuntu like OS’es)
- Restart web server
- Run the test script again
- (Remove test script when all is working, it can be a security hole)
As you can see the exact method is very version dependent. I hope this additional information can help others sort out the exact steps they might need.
answered Mar 13, 2019 at 11:59
LesLes
10.2k4 gold badges40 silver badges58 bronze badges
i have many version of php and i use the php-fpm. for me for php 8.0 helped is uncomment ;extension=gd in /etc/php/8.0/cli/php.ini and uncomment ;extension=gd2 in /etc/php/8.0/fpm/php.ini then install gd library as sudo apt-get install php8.0-gd.
answered May 15, 2021 at 21:21
romanownromanown
2952 silver badges9 bronze badges
I have same error:
PHP Fatal error: Call to undefined function imagecreatetruecolor() in /var/www/webphp/php/captcha.php on line 251
and my solution was this:
$ locate php.ini
/etc/php56/php.ini
edit file php.ini and uncomment line content «extension=gd.so«, save and try again
answered Sep 27, 2017 at 16:23
Update for 2022:
If you run into this problem with PHP 8.0.0 or more recent versions, then check out the Image Installation page at PHP’s website.
In Windows, you’ll include the GD DLL php_gd.dll as an extension in php.ini. Prior to PHP 8.0.0, the DLL was named php_gd2.dll.
Edit your php.ini file & make sure that this line exists. If not, add it. If it has a ; before it, remove the semi-colon.
PHP 8.0.0 or NEWER If you use XAMPP, then this file WILL exist on your file system:
extension=php_gd.dll
Older PHP versions will use this. If you use XAMPP 8.0.0+, then this file WON’T exist on your file system:
extension=php_gd2.dll
That’s how you can fix this again. Enjoy!
answered Jul 21, 2022 at 3:29
ClompClomp
2,9882 gold badges22 silver badges35 bronze badges
Содержание
- Проблема с imagecreatetruecolor
- Cramac
- Фанат
- Sapfir
- Cramac
- Фанат
- Cramac
- Проблема с imagecreatetruecolor
- c0dex
- Фанат
- Ulibka
- c0dex
- c0dex
- Ulibka
- Ulibka
- «вызов функции undefined function imagecreatetruecolor» в PHP и pChart
- ОТВЕТЫ
- Ответ 1
- Ответ 2
- Ответ 3
- Ответ 4
- Ответ 5
- Ответ 6
- imagecreatetruecolor
- Описание
- Список параметров
- Возвращаемые значения
- Список изменений
- Примеры
- Смотрите также
- User Contributed Notes 37 notes
Проблема с imagecreatetruecolor
Cramac
Новичок
Проблема с imagecreatetruecolor
Не работает функция imagecreatetruecolor. В чем дело?
Возможно надо ГД2, если да, то где скачать под винды?
Стоит ВинХП, ГД1.6.2.
Фанат
oncle terrible
Sapfir
Guest
Повторяй за мной:
1). Иди в папку где у тебя распакован php.
2). Там открой папку extensions. В ней найди файл php_gd2.dll. Копируй его
3). Иди в папку где УСТАНОВЛЕН РНР (предположительно C:php3 или С:php4) и вставляй туда файл.
4). Открой свой php.ini (в папке Windows) найди строчку ;extension=php_gd2.dll и убери знак «;» в начале.
5). Улыбайся, радуйся.
Cramac
Новичок
Фанат
oncle terrible
Cramac
Новичок
Одну проблему решил, теперь другая, перестал работать вот такой скриптик:
header («Content-type: image/JPEG»);
$org_h = imagesy($src );
$org_w = imagesx($src );
if($org_h > $org_w ) <
$x_img=»800″;
$x_k= ($x_img * 100) / $org_h;
> else <
$y_img=»800″;
$y_k= ($y_img * 100) / $org_w;
>
if ($x_img==»»)<$x_img= ($org_h * $y_k)/100;>
else <$y_img=($org_w * $x_k)/100;>
// height is bigger than width
$cfg[height] = $x_img;
$cfg[width]= floor($cfg[height] * $org_w / $org_h );
$cfg[dstX]= ($y_img — $cfg[width]) / 2;
$cfg[dstY]= 0;
> else <
// width is bigger than height
$cfg[width]= $y_img;
$cfg[height] = floor($cfg[width] * $org_h / $org_w );
$cfg[dstX]= 0;
$cfg[dstY]= ($x_img — $cfg[height]) / 2;
>
ImageCopyResized($img, $src, $cfg[dstX], $cfg[dstY], 0, 0, $cfg[width], $cfg[height], $org_w, $org_h );
##################
Imagejpeg($img);
##################
ImageDestroy($img );
при передаче всех данных ничего не происходит, а у хостера работает.
пытаюсь вот так открыть resize.php?name=selk001.jpg
а наме не передается.
Что не так?
ПС. Обновил то быстро, главное чтоб теперь не зря 6.5 мегов скачал.
Источник
Проблема с imagecreatetruecolor
c0dex
web.dev 2002-.
@Ulibka, Call to undefined function imagecreatetruecolor() дальше в гугол
PS: надо убедиться в том, что ты верную строчку нашел и раскомментил и в НУЖНОМ файле. Нету у тебя библиотеки GD
Фанат
oncle terrible
Ulibka
Новичок
Нашел еще параметр , установил
extension_dir = «C:xamppphpext»
Если extension_dir не выставить, то возникает ошибка
PHP Startup: Unable to load dynamic library ‘C:phpextphp_gd2.dll’
стоит строка
extension=php_gd2.dll
Ошибки пропали, но картинка все равно не появляется.
Может быть проблема в Xampp ?
P.S. apache я конечно перезагружал
c0dex
web.dev 2002-.
@Ulibka, тебя не смущает:
c0dex
web.dev 2002-.
Ulibka
Новичок
Смущает 
Xampp поставил на SSD (диск F)
PHP стоит на F:xamppphp
В директории F:xamppphp лежит php.ini
Пробовал ставить
extension_dir = F:/xampp/php/ext
Программа не работает (картинки не видно)
Снес xampp, поставил на C: Apache (httpd-2.4.29-Win64-VC15 from Apache lounge)
Поставил на C: в директорию PHP сам php 7 (php-7.2.1-Win32-VC15-x64 thread safe.zip)
Выставил
extension_dir = c:/php/ext
та же фигня — не работает
Ulibka
Новичок
Может быть я все таки в пяти строках программы ошибся ?
Но ведь это я тупо записал пример (наверно даже из документации)
Источник
«вызов функции undefined function imagecreatetruecolor» в PHP и pChart
Я пытаюсь интегрировать «pChart» с моим PHP-кодом. Когда я пытаюсь запустить образцы, он дает мне сообщение об ошибке call to undefined function imagecreatetruecolor . Рекомендованным решением было загрузить эту dll «php_gd2.dll», поэтому я раскомментировал extension=php_gd2.dll в файле php.ini.
Даже после этого я получаю ту же ошибку. Я попытался перезапустить сервер и машину.
ОТВЕТЫ
Ответ 1
Используйте следующий код, чтобы проверить, есть ли расширение GD:
Если вы получили сообщение, которое оно не установлено, проверьте следующие шаги:
- phpinfo() и найдите путь php.ini
- edit php.ini : extension_dir =
- изменить php.ini : extension = php_gd2.dll//раскомментировать или добавить
- Перезапустить веб-сервер
- Запустите тест script снова
Ответ 2
В Ubuntu/Linux Mint Platform (под root) используйте следующую команду:
Ответ 3
Я встретил эту проблему только сейчас. Вы должны выполнить sudo apt install php7.0-gd или vim свой php.ini открыть расширение = php_gd2.dll
Ответ 4
У меня такая же ошибка:
и мое решение было следующим:
отредактировать файл php.ini и раскомментировать содержимое строки extension = gd.so «, сохранить и повторить попытку
Ответ 5
Ответ 6
Этот ответ является обновлением 9 лет спустя, но PHP сильно изменился. Пожалуйста, проголосуйте за Святой Воланд, из которого это происходит.
Используйте следующий код на своем веб-сервере, чтобы проверить, есть ли у вас расширение GD:
«; //display GD function list
Если вы получили сообщение о том, что оно не установлено, выполните следующие действия:
- Посмотрите на вывод phpinfo(), чтобы определить ваш php.ini
- Отредактируйте php.ini и включите расширение GD:
- Более новый PHP (7.3, fg):
- extension = gd2//раскомментируем
- Более старый PHP (5.x, 7.0, вы должны обновить):
- extension_dir = & lt; путь к вашим расширениям & gt;//раскомментируем или добавляем
- extension = php_gd2.dll//раскомментируем или добавляем
- Более новый PHP (7.3, fg):
- GD для 7.x не может быть установлен
- (для Ubuntu, таких как OS) sudo apt install php7.3-gd # заменить версию своей
- Перезапустите веб-сервер
- Запустите тестовый скрипт еще раз
- (Удалите тестовый скрипт, когда все работает, это может быть дыра в безопасности)
Как видите, точный метод очень зависит от версии. Я надеюсь, что эта дополнительная информация поможет другим разобраться, какие именно шаги им могут понадобиться.
Источник
imagecreatetruecolor
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 
imagecreatetruecolor — Создание нового полноцветного изображения
Описание
imagecreatetruecolor() возвращает объект, представляющий чёрное изображение заданного размера.
Список параметров
Возвращаемые значения
Возвращает объект изображения в случае успешного выполнения или false в случае возникновения ошибки.
Список изменений
| Версия | Описание |
|---|---|
| 8.0.0 | В случае успешного выполнения функция теперь возвращает экземпляр GDImage ; ранее возвращался ресурс ( resource ). |
Примеры
Пример #1 Создание нового потока GD изображения и вывод картинки.
Результатом выполнения данного примера будет что-то подобное:
Смотрите также
- imagedestroy() — Уничтожение изображения
- imagecreate() — Создание нового палитрового изображения
User Contributed Notes 37 notes
If you want to create a *transparent* PNG image, where the background is fully transparent, and all draw operations happen on-top of this, then do the following:
= imagecreatetruecolor ( 800 , 600 );
imagesavealpha ( $png , true );
$trans_colour = imagecolorallocatealpha ( $png , 0 , 0 , 0 , 127 );
imagefill ( $png , 0 , 0 , $trans_colour );
$red = imagecolorallocate ( $png , 255 , 0 , 0 );
imagefilledellipse ( $png , 400 , 300 , 400 , 300 , $red );
header ( «Content-type: image/png» );
imagepng ( $png );
?>
What you do is create a true colour image, make sure that the alpha save-state is on, then fill the image with a colour that has had its alpha level set to fully transparent (127).
The resulting PNG from the code above will have a red circle on a fully transparent background (drag the image into Photoshop to see for yourself)
HOW THE CHECK THE MEMORY BEFORE CREATING AN IMAGE?
I worked on a script where I delt with large images. Very often the error «out of memory» occured. So I had to figure out, how to check the memory BEFORE creating an image. I didn’t find a solution on the web, so I ran my own test script. It built lots of images to compute the needed memory. I found out, that the formula mem = x * y * channel was not enough. There was an additional multiplier that varied. As a result 1.7 worked best. So the formula is: mem = x * y * channel * 1.7.
I post this script here hoping it is useful to someone who will run into the same problems.
//————————————————— ENOUGH MEMORY ?
function enoughmem ( $x , $y , $rgb = 3 ) <
return ( $x * $y * $rgb * 1.7 MAXMEM — memory_get_usage () );
>
//————————————————— SIMPLE EXAMPLE
list ( $x , $y ) = @ getimagesize ( ‘your_img.jpg’ ); //— get size of img —
if ( enoughmem ( $x , $y )) <
$img = @ imagecreatefromjpeg ( ‘your_img.jpg’ ); //— open img file —
$thumb = 200 ; //— max. size of thumb —
if ( $x > $y ) <
$tx = $thumb ; //— landscape —
$ty = round ( $thumb / $x * $y );
> else <
$tx = round ( $thumb / $y * $x ); //— portrait —
$ty = $thumb ;
>
if ( enoughmem ( $tx , $ty )) <
$thb = imagecreatetruecolor ( $tx , $ty ); //— create thumbnail —
imagecopyresampled ( $thb , $img , 0 , 0 , 0 , 0 , $tx , $ty , $x , $y );
imagejpeg ( $thb , ‘your_thumbnail.jpg’ , 80 );
imagedestroy ( $thb );
>
imagedestroy ( $img );
>
//—————————————————
//— to check the memory working with —
//— b/w-image or gif use: —
//—————————————————
$check = enoughmem ( $x , $y , 1 );
?>
Taking the opportunity, I thank everyone here at php.net for the great manual and the useful user scripts.
There is no need to allocate colors with imagecreatetruecolor. All [256 x 256 x 256 x 128] true colors are already allocated, and you can use the color indexes directly.
Examples :
Blue => color index 255.
White => color index 16777215 (= 255*256² + 255*256+255).
Full transparent => color index 2130706432 (= 127*256^3).
using imagecolorallocate to specify the image’s background color does not work with truecolor-image.
instead you have to use imagefill to force flood-filling the image with the backgorund-color previously allocated:
$bgColor = imagecolorallocate($img, 255,255,255);
imagefill($img , 0,0 , $bgColor);
If you want to place an image on a larger canvas you’ve previously created with imagecreatetruecolor(), but you don’t want the default black background to surround it: use imagefill() AFTER imagecopyresampled().
I have no idea why this should be the case, but it works!
A note to post by Justin Greer @ 18-Nov-2003 10:40:
While this information has already been posted by php at REMOVEreallynicejerk dot com @ 16-Sep-2002 12:01, I feel it neccesary to notice ’cause Justin’s post is in the top and it can make people go the wrong way: Justin’s way of detecting which imagecreate function to use is too complicated, while there’s an easy standard way:
if ( function_exists ( ‘imagecreatetruecolor’ ) <
// use imagecreatetruecolor
> else <
// use imagecreate
>
If you want a simple way to mirror images, use the function I’ve included below.
function image_mirror ( $input_image_resource )
<
$width = imagesx ( $input_image_resource );
$height = imagesy ( $input_image_resource );
$output_image_resource = imagecreatetruecolor ( $width , $height );
$y = 1 ;
while ( $y $height )
<
for ( $i = 1 ; $i $width ; $i ++ )
imagesetpixel ( $output_image_resource , $i , $y , imagecolorat ( $input_image_resource , ( $i ), ( $height — $y ) ) );
$y = $y + 1 ;
>
return $output_image_resource ;
>
?>
Example Usage:
// A good use of this is when a user uploads a TGA file,
// on the completion screen show the image and have a link
// that asks if the image appears mirrored, and if so
// that link will execute these commands below.
// I suggest checking $HTTP_REFERER for security.
// $_GET[‘file’] in this case would be something along the lines
// of johndoe-img0001 (Basename is necessary to prevent
// abuse of this script!)
if ( isset( $_GET [ ‘file’ ] ) )
<
$filename = «./» . basename ( $_GET [ ‘file’ ] ) . «.jpg» ;
// Making the image resource that needs to be mirrored
// Taking it from a previously exported to JPEG file.
$output_resource_image = image_mirror ( imagecreatefromjpeg ( $filename ) );
if ( imagejpeg ( $output_resource_image , $filename , 75 ) )
echo «Image resaved successfully» ;
else
echo «Image couldn’t be written over (Check permissions)!» ;
>
?>
A very simple and efficient way to create RGB color from hexadecimal (HTML) notation:
function color_hex2dec ( $color ) <
return array ( hexdec ( substr ( $color , 0 , 2 )), hexdec ( substr ( $color , 2 , 2 )), hexdec ( substr ( $color , 4 , 2 )));
>
list ( $r , $g , $b ) = color_hex2dec ( ‘FFEECC’ );
I had a strange bug occurring under Debian Linux with PHP5.
In file B (where I create the image) I included a file (file A). The image that was produced was always corrupt. When I did not include file A, everything was fine.
After 2 hours of searching I found that there were some extra spaces and linefeeds after the PHP closing tag ?> in file A. After removing those chars, everything works fine again.
Obviously those extra bytes of file A were added to the image and corrupted it.
I know it’s not a discussion board, but when incorrect info is posted, it should be corrected.
The function_exists() check does not work correctly because if PHP is compiled with an older GD library, the imagecreatetruecolor() function still exists — it just gives a fatal error when called, stating that GD2 is required. Therefore, the function_exists() method will fail on any new-ish copy of PHP that only has GD 1.x. (That includes most of the 4.1.x and 4.2.x installs I’ve seen.)
Unfortunately the @imagecreatetruecolor() method doesn’t even work because php dies with a fatal error noting that GD 2 is required. You can’t even capture this error with a custom error handler.
I have come up with a function to get the GD version number that seems to work pretty well on every version of PHP and GD I’ve thrown at it (even CLI versions.) It’s obviously not the most efficient thing in the world, but it does cache the result in a static variable so calling it multiple times doesn’t slow down further.
function gd_version() <
static $gd_version_number = null;
if ($gd_version_number === null) <
// Use output buffering to get results from phpinfo()
// without disturbing the page we’re in. Output
// buffering is «stackable» so we don’t even have to
// worry about previous or encompassing buffering.
ob_start();
phpinfo(8);
$module_info = ob_get_contents();
ob_end_clean();
if (preg_match(«/bgds+versionb[^dnr]+?([d.]+)/i»,
$module_info,$matches)) <
$gd_version_number = $matches[1];
> else <
$gd_version_number = 0;
>
>
return $gd_version_number;
>
Then you can simply use it something like this:
if (gd_version() >= 2) <
$image = ImageCreateTrueColor($width, $height);
> else <
$image = ImageCreate($width, $height);
>
Regarding choosing the TrueColor or the plain version of imagecreate automatically, I’ve found that the following works for me:
=@ ImageCreateTrueColor ( $width , $height )
or $newImg = ImageCreate ( $width , $height );
I just fiddled around with Phpix, which had some problems using the GD lib
(washed out colours).
I changed the lines, which did the trick.
Just in case some of you are still having problems and
you can’t change the PHP-install
on the hosting side:
$im = ImageCreateFromJPEG($source);
$new_im = ImageCreate($new_width,$new_height);
$im = ImageCreateFromJPEG($source);
$new_im = ImageCreateTrueColor($new_width,$new_height);
Here is my solution for creating images with the same code for both GD 2:
$dst_img = @imageCreateTrueColor($width, $height);
if (!$dst_img)
Because imagecreatetruecolor exist both in gd and gd2,
you can’t use function_exists or get_extension_funcs to check for gd2 !
But . there is a difference in imagettfbbox between gd and gd2:
gd use pixels and gd2 use points.
Then you can check gd2 with this function:
$rep=false;
if(isset($GLOBALS[«gBGDVersion»]))
<
$rep=$GLOBALS[«gBGDVersion»];
>
else
<
if(function_exists(«gd_info»))
<
$gdver=gd_info();
if(strstr($gdver[«GD Version»],»1.»)!=false)
<
$rep=false;
>
else
<
$rep=true;
>
>
else
<
$size=40;
$font= your font file path here;
$b=imagettfbbox ($size,0,$font,»abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ»);
Why not just use function_exists?
Just because they have version 2.0 GD doesn’t mean that they haven’t disabled that function.
Also instead of determining which one you have on your machine and then writing setup specific code, you can write a universal code usable on either setups.
if (function_exists(imagecreatetruecolor))<
use imagecreatetruecolor()
>else<
use imagecreate()
>
Here is answer for first question ‘why do I need true color images’.
True color images you need when you want to work with images such as photos (snapshots), video frames and so on.
When you need to combine some these images for user, or to send him only small part of your image, and you try to use 256 colors, image will be ugly (try it if you want). Some colors will change dramatically.
«Antialias» lines which you may see are probably the result of using JPEG compression. JPEG is not looseless compression so «small image details may be changed» in order to reduce image size dramatically. On really true-color images such as your snapshots of landscape and so on and using small compression level you will hardly see differences. But on exact objects, such as lines, circles, which you draw on solid background using single color, you can see that if you save and load this image that some details are changed.
This little function does it for you:
The .299 , .578 , .114 values are estimations, and add a gamma correction to the colors. For more or less luminace in the result, you can change these values.
Goodluck,
Eric Mulders, Netherlands
Thanks to OverFlow636 at gmail dot com and kuya1284 at techie dot com for their original coding which this function is based upon.
PHP lacks an imagecreatefromtga function, so I have prepared a simple function to include in your library if you deal with TGA images. In addition to creating an image from TGA, it also, optionally, will output an array with the dimensions of the image because getimagesize() does not function with TGA files.
Hopefully this function will eventually be unneeded if GD is ever updated to support the TGA format.
Please keep in mind that TGA’s come in many different compressions, color settings, and as a result this function will not work 100% of the time. Resulting images will fit the symptoms kuya1284 at techie dot com mentioned, and as a result you may need to create a second function. Keep in mind that using her code causes the «mirror» effect on images that load properly with the following function.
function imagecreatefromtga ( $filename , $return_array = 0 )
<
$handle = fopen ( $filename , ‘rb’ );
$data = fread ( $handle , filesize ( $filename ) );
fclose ( $handle );
$pointer = 18 ;
$x = 0 ;
$y = 0 ;
$w = base_convert ( bin2hex ( strrev ( substr ( $data , 12 , 2 ) ) ), 16 , 10 );
$h = base_convert ( bin2hex ( strrev ( substr ( $data , 14 , 2 ) ) ), 16 , 10 );
$img = imagecreatetruecolor ( $w , $h );
while ( $pointer strlen ( $data ) )
<
imagesetpixel ( $img , $x , $y , base_convert ( bin2hex ( strrev ( substr ( $data , $pointer , 3 ) ) ), 16 , 10 ) );
$x ++;
if ( $return_array )
return array ( $img , $w , $h );
else
return $img ;
>
?>
Example Usage
// the image ( resource image )
$image = $array [ 0 ];
// its dimensions ( integers )
$dimensions [ ‘width’ ] = $array [ 1 ];
$dimensions [ ‘height’ ] = $array [ 2 ];
// Delete the image resource array entry to free memory
imagedestroy ( $array [ 0 ]);
?>
The second variable, $return_array is optional. If you simply want to load a TGA, leave the variable off the function’s call as such:
imagecreatetruecolor() returns not only image identifier representing a black image of size x_size by y_size.
imagecreatetruecolor() is called to create truecolor images, with an essentially unlimited number of colors (also not only 256 colors).
kai wrote:
//using imagecolorallocate to specify the image’s background
//color does not work with truecolor-image.
//
//instead you have to use imagefill to force flood-filling the
//image with the backgorund-color previously allocated:
//
//$bgColor = imagecolorallocate($img, 255,255,255);
//imagefill($img , 0,0 , $bgColor);
even this doesn’t work for my configuration — fedora core2, php 4.3.8 + gd bundled (2.0.23 compatible) and I have to do this:
$img = imagecreatetruecolor($x, $y);
$bgColor = imagecolorallocate($img, 255,255,255);
imagefilledrectangle($img, 0, 0, $x-1, $y-1, $bgColor);
I put this together — combining two of the examples and then generated the text dynamically. but, with this set up, i was able to get the transparent background working as well.
// Set the content-type
header ( ‘Content-type: image/png’ );
// Create the image
$im = imagecreatetruecolor ( 175 , 15 );
imagesavealpha ( $im , true );
// Create some colors
$white = imagecolorallocate ( $im , 255 , 255 , 255 );
$grey = imagecolorallocate ( $im , 128 , 128 , 128 );
$black = imagecolorallocate ( $im , 0 , 0 , 0 );
imagefilledrectangle ( $im , 0 , 0 , 150 , 25 , $black );
$trans_colour = imagecolorallocatealpha ( $im , 0 , 0 , 0 , 127 );
imagefill ( $im , 0 , 0 , $trans_colour );
// The text to draw
$text = $_GET [ ‘text’ ];
// Replace path by your own font path
$font = ‘catriel regular.ttf’ ;
// Add some shadow to the text
imagettftext ( $im , 9 , 0 , 13 , 16 , $black , $font , $text );
// Add the text
imagettftext ( $im , 9 , 0 , 12 , 15 , $white , $font , $text );
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng ( $im );
imagedestroy ( $im );
?>
Источник
Would you be referring to below error?
Warning: getimagesize(/home/content/a/r/i/user/html/images/stories/Bars/etdcrt003.jpg): failed to open stream: No such file or directory in /home/content/a/r/i/user/html/plugins/content/jwsigpro/sigpro_engine.php on line 86
Image type not supported
This is what I got as a fatal error, other than a webpage. 
I changed the permissions on the php file and temp folder, no change in response, I had tried all the different versions for compatibility with no luck.
My config is Joomla 1.5.6, php v5, I am checking on the GD library with my provider.
I appreciate any thoughts and help, I am in the process of updating my site, I am currently running the 1.2 version with no problems on Joomla 1.0.11.
Now I get the following error:
Warning: getimagesize(/home/content/a/r/i/user9/html/images/stories/bars/etdpbr007.gif) [function.getimagesize]: failed to open stream: No such file or directory in /home/content/a/r/i/user9/html/plugins/content/jwsigpro/sigpro_engine.php on line 86
Image type not supported
[function.getimagesize] is linked to category/function.getimagesize vs. category/article (just thought I would mention this)
I using a Rockettheme Chromatophore template , I check with my provider, using the help button on Joomla 1.5.6 I see that I am using php 5.2.5, GD is bundled (2.0.34 compatible), it also says gif, jpg and png are enabled.
I have uploaded my pictures to stories/bars/ and renamed them in lowercase as seen in this latest fatal error above, even the picture directory I renamed in a lower case.
On the page I am trying to get this work I have {gallery}bars{/gallery}
I revalidated my permissions, but still no love. Any thoughts, this is now holding up my transition to my new site.
SOLVED My Problem:
No kidding you have to have EVERYTHING in lowercase, folder, file name and extension in my case for the second error shown above it was the extension. I had the picture saved as etdpbr007.GIF, didn’t work. As soon as I changed it to etdpbr007.gif, WOW it worked!!! Yeah, I am very happy once again. Now I have a lot of pictures to edit, ugghhh 
За последние 24 часа нас посетили 11496 программистов и 1170 роботов. Сейчас ищут 293 программиста …
Fatal error: Call to undefined function imagecreatetruecolor
Тема в разделе «Установка PHP», создана пользователем wollf, 7 сен 2008.
-
wollf
Активный пользователь- С нами с:
- 4 сен 2008
- Сообщения:
- 4
- Симпатии:
- 0
Fatal error: Call to undefined function imagecreatetruecolor()
Возникает вот такая ошибка при добавлении фоток в чат.Знаю что не установлена библиотека gb.
Может у кого есть эта библиотека,поделитесь и желательно инфо по установке.Спасибо!
О.С linux Fedora-7
apach 2
php 5#1
wollf,7 сен 2008
-
Dagdamor
Активный пользователь- С нами с:
- 4 фев 2006
- Сообщения:
- 2.095
- Симпатии:
- 1
- Адрес:
- Барнаул
wollf
Она входит в состав PHP (кроме 5.3, где ее почему-то нет).
Надо просто раскомментировать в php.ini строку «extension=php_gd2.dll» и перезапустить Опачь.#2
Dagdamor,7 сен 2008
-
wollf
Активный пользователь- С нами с:
- 4 сен 2008
- Сообщения:
- 4
- Симпатии:
- 0
Спасибо добрый человек)!
#3
wollf,7 сен 2008
(Вы должны войти или зарегистрироваться, чтобы разместить сообщение.)
- Ваше имя или e-mail:
- У Вас уже есть учётная запись?
-
- Нет, зарегистрироваться сейчас.
- Да, мой пароль:
-
Забыли пароль?
-
Запомнить меня


).