Jump to content

Archived

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

lpxxfaintxx

Image Manipulation Problems

Recommended Posts

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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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...

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.