Jump to content

GD Error. Simple fix?


Blaine0002

Recommended Posts

So im working on a dynamic signature script, by pulling halo 3 stats off bungie.net and applying them to an image and cacheing the image.

 

<?php
$url = 'http://www.bungie.net/Stats/Halo3/Default.aspx?player=lazydonkey2';
$page = file_get_contents($url);<?php
$url = 'http://www.bungie.net/Stats/Halo3/Default.aspx?player=lazydonkey2';
$page = file_get_contents($url);

preg_match('/<li><h3>(.*?)     - /', $page, $name);
preg_match('/id="ctl00_mainContent_identityStrip_lblRank">(.*?)<\/span>/', $page, $rank);
preg_match('/id="ctl00_mainContent_identityStrip_lblSkill">(.*?)<\/span>/', $page, $level);
preg_match('/id="ctl00_mainContent_identityStrip_EmblemCtrl_imgEmblem" src="([^\"]+)/', $page, $icon);

$url = "http://www.bungie.net" . $icon[1];
$url = str_replace("&","&",$url); 
$img = getimagesize($url) or die();
    if ( $img[2] == 1 ) {
        $icon = imagecreatefromgif( $url ) or die();
    } elseif ( $img[2] == 2 ) {
        $icon = imagecreatefromjpeg( $url ) or die();
    } elseif ( $img[2] == 3 ) {
        $icon = imagecreatefrompng( $url ) or die();
    } else {exit();}

$image = imagecreatefrompng("sigs/1.png");
$x = imagesx($icon);
$y = imagesy($icon);
$px = ((200-$x)/2);
$py = 15; 
        $font = 4;
$black = imagecolorallocate($image, 0, 0, 0);
imagestring($image, $font, 165, 15, $name[1], $black);
imagestring($image, $font, 165, 35, $rank[1], $black);
imagestring($image, $font, 165, 55, "Highest Level: " . $level[1], $black);
imagecopymerge($image, $pic, $px, $py, 0, 0, $x, $y, 100);


header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

 

i think there could be 2 things wrong with this..

Im not sure if gd is recognising the image im telling them, as it does not have a file extension. Does this mater? you can save it as a .jpg file tho so thats what i think it would pick it up as.

 

Second thing i think could be wrong is i was told i might need to use fopen() to open remote urls... i do have that remote fopen thing activated in my php.ini

 

Thanks for your help as im new to gd :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.