October 12, 2008, 05:49:08 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Check your Page Rank, Backlinks, or Link Popularity in our tools section.
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Check your Page Rank, Backlinks, or Link Popularity in our tools section.
Pages: [1]
  Print  
Author Topic:

Creating images with php

 (Read 876 times)
0 Members and 1 Guest are viewing this topic.
chris3471
Full Member
***

Points: 3
Offline Offline

Posts: 187


WWW
« on: June 16, 2006, 15:49:25 »

Anyone know how to do this? I need graphs for a project I'm planning.
Logged



xulescu
Full Member
***

Points: 8
Offline Offline

Posts: 245


WWW
« Reply #1 on: June 16, 2006, 15:57:04 »

php-gd library. you can create jpeg/png etc. and you can create images on the fly Smiley

Bye
Logged

TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #2 on: June 16, 2006, 15:58:47 »

Yes with gd.
Sample code
Code:
<?php
/* define that the browser should treat
  the output of this file as an image */
  
header("Content-type: image/png");
  
// set the string to the key
  
$string rand();
  
// create an temporary image from a PNG file
  
$im    imagecreatefrompng("images/bg.png");
  
// get a color from the image (in this case, yellow)
  
$orange imagecolorallocate($im20105);
  
/* Now we need to get widh and height of the image, so that we can center the
  key on the image, so that it does not go outside of the borders or look strange */
  
$px    = (imagesx($im) - 7.5 strlen($string)) / 2;
  
$h = (imagesy($im) - 7.5) / 2;
  
// here we write the key (the string)  on the image
  
imagestring($im7$px$h$string$orange);
  
// now create the final image
  
imagepng($im);
  
// to free up results, we need to destroy the temporary image.
  
imagedestroy($im);

?>



Anyway you can draw lines/circles wite with specific fonts etc ...

Regards
Logged

TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #3 on: June 16, 2006, 15:59:48 »

This code is a preliminary code for a image auth system (captcha ?)
Smiley

Regards
Logged

chris3471
Full Member
***

Points: 3
Offline Offline

Posts: 187


WWW
« Reply #4 on: June 16, 2006, 18:02:40 »

Thanks, I'll play about with that.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!