Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

test if gd working need help

Recommended Posts

Has anyone got a test gd snippet to see if the gd libarry working please thanks.

Share this post


Link to post
Share on other sites
Check what's installed:
[code]<?php
gd_info();
?> [/code]
Check the operation - there's a simple tutorial here on GD. That should do.

Share this post


Link to post
Share on other sites
[!--quoteo(post=353773:date=Mar 11 2006, 12:14 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 11 2006, 12:14 AM) [snapback]353773[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Check what's installed:
[code]<?php
gd_info();
?> [/code]
Check the operation - there's a simple tutorial here on GD. That should do.
[/quote]

from the phpinfo.php

Looks ok to me can you spot the problam please thank you.

[code]
GD Support  enabled  
GD Version  bundled (2.0.28 compatible)  
FreeType Support  enabled  
FreeType Linkage  with freetype  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  
XBM Support  enabled  
[/code]


my test code but the success stops on type1 and type2 i think the types are for the pics.
[code]

<?php

function test ($string, $test)
{
    echo $string . '... ';

    if ($test)
        echo "success.\n";
    else
        echo "fail.\n";
}

$token = "Testing GD!";

// Create image

$pic = ImageCreate (300, 300);

test ('Creating image', $pic);

$col2 = ImageColorAllocate ($pic, 0, 0, 100);
$col1 = ImageColorAllocate ($pic, 200, 200, 200);

// Test PNG/JPG functionality

ob_start();
$res1 = @ImagePNG ($pic);
$res2 = @ImageJPEG ($pic);
ob_clean();

test ('Testing PNG output', $res1);
test ('Testing JPEG output', $res2);

// Test TrueType functionality

$ttfont = trim (`locate -n 1 .ttf`);

test ('Testing FreeType', @ImageTTFText
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token));
test ('Testing FreeType2', @ImageFTText
    ($pic, 30, 0, 10, 40, $col1, $ttfont, $token, array()));

// Test Type1 functionality

$font = @ImagePsLoadFont (trim (`locate -n 1 .pfb`));

if ($font)
    $res = @ImagePsText ($pic, $token, $font, 10, $col1, $col2, 0, 0);

test ('Testing the Type1 library', ($font && $res));

test ('Destroying image', ImageDestroy($pic));

?>
[/code]

Share this post


Link to post
Share on other sites
[quote]Is it possible to apply alt attribute in gd ??

<?php

echo "<img src=".crImage()." alt='testing alt'>";

function crImage()
{
header("Content-type: image/gif");
$im  = imagecreatefrompng("new.gif");
imagepng($im);
imagedestroy($im);
}
?>

The above code creates an image is it possible to add an alt attribute to it ?[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.