Jump to content

PHP to JPG?


kjtocool

Recommended Posts

I am building a program that utilizes a MySQL database.  It will track all the widgets you have used, with a date, name, and various other information about the widget.

 

I would like to be able to have it so that each distinct user has the ability to have an associated image which will be generated using SQL calls to show the last 5 widgets he utilized.  Similar to a gamer tag for various

 

Can anyone help guide me toward this? 

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/
Share on other sites

Doing a little research, it looks like using GD I can do something like this:

 

http://www.developertutorials.com/tutorials/php/creating-dynamic-text-images-050623/page1.html

 

It's telling me to use the functions:

 

$size = imagettfbbox(12,0,"Fonts/comic.ttf","image string");

$im = imagecreate(abs($size[4]-$size[0]),$size[1]+abs($size[5]));

imagettftext($im,12,0,0,abs($size[5]),$black,"/Fonts/arial.ttf","image string");

 

etc, etc.  Can anyone explain this process to me a little better?

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/#findComment-524285
Share on other sites

Doing a little research, it looks like using GD I can do something like this:

 

http://www.developertutorials.com/tutorials/php/creating-dynamic-text-images-050623/page1.html

 

It's telling me to use the functions:

 

$size = imagettfbbox(12,0,"Fonts/comic.ttf","image string");

$im = imagecreate(abs($size[4]-$size[0]),$size[1]+abs($size[5]));

imagettftext($im,12,0,0,abs($size[5]),$black,"/Fonts/arial.ttf","image string");

 

etc, etc.  Can anyone explain this process to me a little better?

 

That's way too complicated to be practical.  Just associate an image with each widget and call each image from the results of the query.

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/#findComment-524286
Share on other sites

But wouldn't you need to do something like:

 

<img src=<?php echo $widget_image; ?>><?php echo $widget_info; ?></img>

 

Because I just want someone to be able to put:

 

[img=www.linktoimage.com]

 

in their signature, and I want that image to auto generate, or be previously auto generated.

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/#findComment-524312
Share on other sites

But wouldn't you need to do something like:

 

<img src=<?php echo $widget_image; ?>><?php echo $widget_info; ?></img>

 

Because I just want someone to be able to put:

 

[img=www.linktoimage.com]

 

in their signature, and I want that image to auto generate, or be previously auto generated.

 

Oh.  Then you'd need to use GD library and have the headers sent out as an image.  I know how to do that part.  I can give you those lines if you want, but I don't feel like coding all the image creation code.

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/#findComment-524314
Share on other sites

Here's how you do it:

 

1) You make a standalone PHP script that generates the images.  You need to have the user's ID stored in a session variables OR have it passed on the image tag: i.e:

[img]http://yoursite.com/widgetsig?id=1

and have them put that in their sig.

 

2)Generate the image as $image.  You'll figure it out when you learn how to use GD.

 

3) Add these lines to the end of your script:

<?php
	header('Content-Type: image/jpeg');

	imagejpeg($image);

	imagedestroy($image);
?>

 

4) In your signature script or w/e, they can reference the page, and it basically shows itself to the web browser as an image file.

Link to comment
https://forums.phpfreaks.com/topic/102373-php-to-jpg/#findComment-524361
Share on other sites

Archived

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

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