Jump to content


Photo

Image Manipulation Problems


  • Please log in to reply
5 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 11 June 2006 - 02:06 AM

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

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 11 June 2006 - 04:17 AM

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...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 11 June 2006 - 11:04 AM

This is what I have:

<?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);
?>

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?

#4 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 12 June 2006 - 12:39 AM

Is it possible?

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 June 2006 - 12:47 AM

[!--quoteo(post=382696:date=Jun 12 2006, 12:39 AM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Jun 12 2006, 12:39 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Is it possible?
[/quote]

easy way take a snapshot from the page and rename the .format ok.

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 12 June 2006 - 06:35 PM

Take a look at this script and adapt it as needed...
<?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); 
?>

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users