May 22, 2012, 10:50:38 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
Pages: [1]
  Print  
Author Topic:

Creating images with php

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

Points: 3
Offline Offline

Posts: 187


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

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



xulescu
Administrator
Sr. Member
*****

Points: 8
Offline Offline

Posts: 259


WWW
« Reply #1 on: June 16, 2006, 05: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, 05: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, 05: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, 08:02:40 »

Thanks, I'll play about with that.
Logged

jonsborn
Newbie
*

Points: 0
Offline Offline

Posts: 2


« Reply #5 on: December 25, 2011, 21:50:58 »

This is a very awesome and easy to create tutorial. As good as it feels to code your own functions, it’s good to know that there’s someone who’s gone to great lengths to code a spectacular class. Also, You can use a quality parameter in the imagejpeg function!
Logged

markosh
Jr. Member
**

Points: 0
Offline Offline

Posts: 8


« Reply #6 on: December 25, 2011, 23:35:48 »

Hi,
   with an emphasis on client service, professionalism, and zealous advocacy.

Thanks.
........................................

Toronto Criminal Lawyer
Logged
ValindaBolton
Newbie
*

Points: 0
Offline Offline

Posts: 1


« Reply #7 on: January 09, 2012, 18:32:33 »

Many people do not realize that PHP can be used to create non-HTML data. This is especially useful for creating images on the fly. It could be simple bar graphs that display data from a database, or even simpler, just a way to create graphic buttons on the fly.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!