RADaugherty Posted August 24, 2022 Share Posted August 24, 2022 (edited) So I've worked with PNG/JPG's before with overlaying text onto an image and then displaying said image. Now I want to use a Gif and do the same thing, but the image loses its animation. Is there a way to do this? Specifically, I use these in signatures on forums and as such I have the file name like this; Website.png.php so that the forum sees the extension and allows an image to be shown. Is there anything out that where I can accomplish this using a Gif? Note: I would be content without the ability of overlaying text onto the Gif so long as I can display them using this address type that the forum allows in signatures. Here's the image I can work with https://www.radproducts.me/LSSigs/tizzoe.png[/IMG] And here's the code behind it. <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); Header('Pragma: no-cache'); /****************************************************** * BASICS * ******************************************************/ // set some dimensions for future use $expbar_width = 100; $expbar_height = 25; // set the background colour // number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y // set the font and print text $namefont = '../Fonts/Squared Display.ttf'; $font = '../Fonts/AldotheApache.ttf'; $hpfont = '../Fonts/AldotheApache.ttf'; $guildfont = '../Fonts/Fragment.otf'; /****************************************************** * LOAD DATA * ******************************************************/ // Create an array for determining the class you play. // In the XML this is saved as an int number, the conversion is shown below. $class_name = array( -1 => 'None', 0 => 'Fighter', 1 => 'Barbarian', 2 => 'Rogue', 3 => 'Magician', 4 => 'Guardian', 5 => 'Samurai', 6 => 'Paladin', 7 => 'Monk', 8 => 'Ninja', 9 => 'Warlock', 10 => 'Headhunter', 11=> 'Alchemist'); // load xml data in vars // This is where you load your own info from the xml d2jsp gives. This is a PHP5 only command! $data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=135032'); $guild = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlGuild.php?i=2280'); $name = $data->name; $kills = $data->kills; $class = $class_name[(int)$data->classid]; $exp = $data->exp; $level = $data->level; $gps = getMemberGps($guild, 'tizzoe')['gps']; $hpmax = $data->hpmax; $mpmax = $data->mpmax; $str = $data->strength; $dex = $data->dexterity; $vit = $data->vitality; $int = $data->intelligence; $mqpasses = $data->mqpasses; $mqattempts = $data->mqattempts; $exp = (int)$exp; $temp = explode(";",$data->cprof); foreach ((array) $temp as $value) { $temp2 = explode(",",$value); $cprof[(int)$temp2[0]] = (int)$temp2[1]; } $temp3 = explode(";",$data->wprof); foreach ((array) $temp3 as $value) { $temp4 = explode(",",$value); $wprof[(int)$temp4[0]] = (int)$temp4[1]; } $temp5 = explode(";",$data->sprof); foreach ((array) $temp5 as $value) { $temp6 = explode(",",$value); $sprof[(int)$temp6[0]] = (int)$temp6[1]; } $sword = $wprof[0]; $club = $wprof[1]; $axe = $wprof[2]; $dagger = $wprof[3]; $staff = $wprof[4]; $longsword = $wprof[5]; $warhammer = $wprof[6]; $battleaxe = $wprof[7]; $spear = $wprof[8]; $polearm = $wprof[9]; $ice = $cprof[0]; $fire = $cprof[1]; $lightning = $cprof[2]; $wind = $cprof[3]; $earth = $cprof[4]; $wheal = $cprof[5]; $heal = $cprof[6]; $focus = $cprof[7]; $fishing = $sprof[0]; $cooking = $sprof[1]; $glyphing = $sprof[2]; $transmuting = $sprof[3]; $suffusencing = $sprof[4]; //$percent = calcExpPercent($exp); //$brpixelX = calcBrPixelX($exp,$expbar_width); // Create an expbar with bg 'cool' color and the cover of your level in red. //imagefilledrectangle($image, 80, 27, 160, 37, $cool); //imagefilledrectangle($image, 80, 27, $brpixelX, 37, $barb); //imagefilledrectangle($image, 80, 27, 100, 37, $cool); //imagefilledrectangle($image, 80, 37, $brpixelX, 27, $red); /****************************************************** * TEXT PART * ******************************************************/ //Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color, font, "text"); $random = rand(0, 1); if ($random === 0) { $image = imagecreatefromjpeg('../LSImages/ElephantB.jpg'); // set some colours for future use $cool = imagecolorallocate($image, 255, 255, 102); $red = imagecolorallocate($image, 255, 255, 255); $yellow = imagecolorallocate($image, 235, 141, 54); if ($class === 'None') { $image = imagecreatefromjpeg('../LSImages/None.jpg'); } if ($class != 'None') { //show name ImageTTFText ($image, 20, 0, 255, 33, $red, $guildfont, $name); //show class ImageTTFText ($image, 12, 0, 275, 50, $red, $font, "Class: "); ImageTTFText ($image, 12, 0, 315, 50, $cool, $font, $class); // show lvl ImageTTFText ($image, 12, 0, 295, 64, $red, $font, "Level: "); ImageTTFText ($image, 12, 0, 335, 64, $cool, $font, $level); // show Str ImageTTFText ($image, 10, 0, 260, 80, $red, $font, "Str: "); ImageTTFText ($image, 10, 0, 290, 80, $cool, $font, $str); // show Dex ImageTTFText ($image, 10, 0, 340, 80, $red, $font, "Dex: "); ImageTTFText ($image, 10, 0, 370, 80, $cool, $font, $dex); // show Vit ImageTTFText ($image, 10, 0, 260, 95, $red, $font, "Vit: "); ImageTTFText ($image, 10, 0, 290, 95, $cool, $font, $vit); // show Int ImageTTFText ($image, 10, 0, 340, 95, $red, $font, "Int: "); ImageTTFText ($image, 10, 0, 370, 95, $cool, $font, $int); // show kills ImageTTFText ($image, 12, 0, 280, 119, $red, $font, "Kills: "); ImageTTFText ($image, 12, 0, 322, 119, $cool, $font, $kills); //show experience ImageTTFText ($image, 12, 0, 285, 132, $red, $font, "Exp: "); ImageTTFText ($image, 12, 0, 310, 132, $cool, $font, $exp); // SHow MQ passen and attempts ImageTTFText ($image, 10, 0, 260, 146, $red, $font, "MQs: "); ImageTTFText ($image, 10, 0, 290, 146, $cool, $font, $mqpasses." / ".$mqattempts); // Show guild points ImageTTFText ($image, 10, 0, 355, 146, $red, $font, "GPs: "); ImageTTFText ($image, 10, 0, 385, 146, $cool, $font, $gps); } } if ($random === 1) { $image = imagecreatefromjpeg('../LSImages/tizzoeC.jpg'); // set some colours for future use $cool = imagecolorallocate($image, 153, 51, 255); $red = imagecolorallocate($image, 51, 51, 255); $yellow = imagecolorallocate($image, 255,255,255); if ($class === 'None') { $image = imagecreatefromjpeg('../LSImages/None.jpg'); } if ($class != 'None') { //show name ImageTTFText ($image, 20, 0, 240, 33, $yellow, $guildfont, $name); //show class ImageTTFText ($image, 12, 0, 260, 50, $red, $font, "Class: "); ImageTTFText ($image, 12, 0, 300, 50, $cool, $font, $class); // show lvl ImageTTFText ($image, 12, 0, 280, 64, $red, $font, "Level: "); ImageTTFText ($image, 12, 0, 320, 64, $cool, $font, $level); // show Str ImageTTFText ($image, 10, 0, 245, 80, $red, $font, "Str: "); ImageTTFText ($image, 10, 0, 275, 80, $cool, $font, $str); // show Dex ImageTTFText ($image, 10, 0, 325, 80, $red, $font, "Dex: "); ImageTTFText ($image, 10, 0, 355, 80, $cool, $font, $dex); // show Vit ImageTTFText ($image, 10, 0, 245, 95, $red, $font, "Vit: "); ImageTTFText ($image, 10, 0, 275, 95, $cool, $font, $vit); // show Int ImageTTFText ($image, 10, 0, 325, 95, $red, $font, "Int: "); ImageTTFText ($image, 10, 0, 355, 95, $cool, $font, $int); // show kills ImageTTFText ($image, 12, 0, 265, 119, $red, $font, "Kills: "); ImageTTFText ($image, 12, 0, 307, 119, $cool, $font, $kills); //show experience ImageTTFText ($image, 12, 0, 260, 132, $red, $font, "Exp: "); ImageTTFText ($image, 12, 0, 295, 132, $cool, $font, $exp); // SHow MQ passen and attempts ImageTTFText ($image, 10, 0, 245, 146, $red, $font, "MQs: "); ImageTTFText ($image, 10, 0, 275, 146, $cool, $font, $mqpasses." / ".$mqattempts); // Show guild points ImageTTFText ($image, 10, 0, 340, 146, $red, $font, "GPs: "); ImageTTFText ($image, 10, 0, 370, 146, $cool, $font, $gps); } } // output and destroy imagejpeg($image, null, 100); imagedestroy($image); /****************************************************** * FUNCTIONS * ******************************************************/ /*** * calculate the exp bar width. ***/ function calcBrPixelX($input,$xpbar_width) { $temp1 = fmod($input,1000000); $temp1 = ($temp1/1000000); $temp1 = $temp1 * $xpbar_width; $temp1 = $temp1 + 80; return (int)$temp1; } /*** * Calculate the percentage of level done ***/ function calcExpPercent($input) { $temp1 = fmod($input,1000000); $temp1 = ($temp1/1000000); $temp1 = $temp1 * 100; return (int)$temp1; } function getMemberGps($guild, $name) { foreach ($guild as $member) { if (reset($member['name']) === $name) { return reset($member); } } return false; } ?> Edited August 24, 2022 by RADaugherty Quote Link to comment https://forums.phpfreaks.com/topic/315231-gd-imagecreatefrom-using-a-gif/ Share on other sites More sharing options...
requinix Posted August 24, 2022 Share Posted August 24, 2022 PHP's gd extension doesn't support editing or outputting animated GIFs. Use something like Imagick/ImageMagick instead - which, honestly, will probably give you better quality results anyway. Quote Link to comment https://forums.phpfreaks.com/topic/315231-gd-imagecreatefrom-using-a-gif/#findComment-1599780 Share on other sites More sharing options...
RADaugherty Posted August 25, 2022 Author Share Posted August 25, 2022 12 hours ago, requinix said: PHP's gd extension doesn't support editing or outputting animated GIFs. Use something like Imagick/ImageMagick instead - which, honestly, will probably give you better quality results anyway. I did look at ImageMagick a little but I didn't see a way of presenting the webpage as just an image like I do with GD (as opposed to showing the image on a webpage) if that makes sense. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/315231-gd-imagecreatefrom-using-a-gif/#findComment-1599804 Share on other sites More sharing options...
Barand Posted August 25, 2022 Share Posted August 25, 2022 Why don't you just create a webpage with a background image? Quote Link to comment https://forums.phpfreaks.com/topic/315231-gd-imagecreatefrom-using-a-gif/#findComment-1599814 Share on other sites More sharing options...
RADaugherty Posted August 25, 2022 Author Share Posted August 25, 2022 10 hours ago, Barand said: Why don't you just create a webpage with a background image? Hmm, I'm fairly newb with PHP as I'm just using it for this type of service I provide for people on another forum but I don't think that would accomplish the same thing I need. If you check my About Me section ( didn't see a section for signature ) you'll see it shows the image there Quote Link to comment https://forums.phpfreaks.com/topic/315231-gd-imagecreatefrom-using-a-gif/#findComment-1599845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.