lpxxfaintxx Posted June 11, 2006 Share Posted June 11, 2006 Some forums don't accept PHP images (lets say [a href=\"http://bigtalkforums.com/advert/image.php\" target=\"_blank\"]http://bigtalkforums.com/advert/image.php[/a], for an example]. Is there any way to make the extension a .gif, .png, or a .jpeg? Regards Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/ Share on other sites More sharing options...
litebearer Posted June 11, 2006 Share Posted June 11, 2006 Not sure what you mean by "PHP image". Are you alluding to creatring an image via php & gd? If so simply save the image created in the format you desire.might look here as a start [a href=\"http://it2.php.net/manual/en/function.imagejpeg.php\" target=\"_blank\"]http://it2.php.net/manual/en/function.imagejpeg.php[/a]Lite... Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/#findComment-44181 Share on other sites More sharing options...
lpxxfaintxx Posted June 11, 2006 Author Share Posted June 11, 2006 This is what I have:[code]<?php$db_host = "localhost";$db_user = "informed_lpxx";$db_pass = "2647900";$db_name = "informed_bigtalk";$db = mysql_connect($db_host,$db_user,$db_pass);mysql_select_db ($db_name) or die ("Cannot connect to database");// In this section you may need to change the prefix on the start off the db names$query = "SELECT * FROM mybb_threads";$abc = mysql_query($query);$def = mysql_num_rows($abc);$topics = $def;$query = "SELECT * FROM mybb_posts";$abc = mysql_query($query);$def = mysql_num_rows($abc);$posts = $def;$query = "SELECT * FROM mybb_users";$abc = mysql_query($query);$def = mysql_num_rows($abc);$users = $def;header("Content-type: image/png");$calc = $topics;$im = imagecreatefrompng("advert.png");$color = imagecolorallocate($im, 255,255,255);$px = (imagesx($im) - 155 * strlen($calc)) / 2;$px1 = (imagesx($im) - 172 * strlen($calc)) / 2;$px2 = (imagesx($im) - 172 * strlen($calc)) / 2;$forum = (imagesx($im) - 20 * strlen($calc)) / 2;imagestring($im, 9, $px, 83, $topics, $color);imagestring($im, 9, $px1, 103, $posts, $color);imagestring($im, 9, $px2, 59, $users, $color); imagepng($im);imagedestroy($im);?>[/code]The problem is, the extension of the image is ".php" instead of jpg, or gif--so a lot of forums don't allow it. So is it possible to change the extension of the image? Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/#findComment-44236 Share on other sites More sharing options...
lpxxfaintxx Posted June 12, 2006 Author Share Posted June 12, 2006 Is it possible? Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/#findComment-44462 Share on other sites More sharing options...
redarrow Posted June 12, 2006 Share Posted June 12, 2006 [!--quoteo(post=382696:date=Jun 12 2006, 12:39 AM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Jun 12 2006, 12:39 AM) [snapback]382696[/snapback][/div][div class=\'quotemain\'][!--quotec--]Is it possible?[/quote]easy way take a snapshot from the page and rename the .format ok. Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/#findComment-44463 Share on other sites More sharing options...
litebearer Posted June 12, 2006 Share Posted June 12, 2006 Take a look at this script and adapt it as needed...[code]<?php //Name you want to save your file as$save = 'myfile.jpg';$file = 'original.jpg'; echo "Creating file: $save"; $size = 0.45; header('Content-type: image/jpeg'); list($width, $height) = getimagesize($file); $modwidth = $width * $size; $modheight = $height * $size; $tn = imagecreatetruecolor($modwidth, $modheight); $image = imagecreatefromjpeg($file); imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); // Here we are saving the .jpg, you can make this gif or png if you want//the file name is set above, and the quality is set to 100%imagejpeg($tn, $save, 100); ?> [/code]Lite... Link to comment https://forums.phpfreaks.com/topic/11680-image-manipulation-problems/#findComment-44708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.