Jump to content

Image Manipulation Problems


lpxxfaintxx

Recommended Posts

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
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?
Link to comment
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.
Link to comment
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...
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.