Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 27th, 2005, 3:02 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Dynamic Pictures?

How do you program a targeted picture on your server to be dynamic to some specified data?

I'm thinking I could do it with Python by automatically reuploading a newly saved picture every 10 minutes, and keep it running in the background. But I know there's an easier way.

I'm talking about those pictures that can keep track of your stats on a certain website, or tell the viewer their IP address.
Sane is offline   Reply With Quote
Old Nov 27th, 2005, 3:15 PM   #2
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 3 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
That would be PHP.

It can create images, so it uses a function to get an IP and them it turns it into an image.

Cool huh?


You could use Python, but your server would need Python and something liek PyGame or PIL installed.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Nov 27th, 2005, 3:22 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
But how does the image target run a php script?

And I could still use Python much more easily the way I mentioned.
Sane is offline   Reply With Quote
Old Nov 27th, 2005, 3:31 PM   #4
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 3 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
usually its not a direct link to an image, but a link to a php script. IIRC.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Jan 1st, 2006, 9:40 PM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Yayzor!

I made a dynamic image in Python for my website. It creates a temporary image with pygame, and that is the return value for the function. If you visit the website with Mozilla you'll see that it's not an actual image, but interpreted as one if you use the img tags.

http://jammersbase.ath.cx/forumimage?userID=1
Sane is offline   Reply With Quote
Old Jan 1st, 2006, 10:41 PM   #6
para
Programmer
 
Join Date: Dec 2005
Posts: 65
Rep Power: 3 para is on a distinguished road
Quote:
Originally Posted by Sane
But how does the image target run a php script?

And I could still use Python much more easily the way I mentioned.
I made one of these in PHP.
http://doommod.sourceforge.net/michael.png

First make the PHP script, start out by explicitly defining the output header:
<?php
header("Content-type: image/png");
Then go on to use ImageCreate() and related functions to generate the image data, and write it with ImagePng() [full docs on php.net].

Once your script is complete (ie, you can go to http://www.blah.com/yourscript.php and have it output the image), you can use Apache's modRewrite to modify incoming HTTP requests to reroute yourscript.png to yourscript.php internally. It will appear to others as if it's a valid static image file, but of course it's not
para is offline   Reply With Quote
Old Jan 22nd, 2006, 9:14 AM   #7
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4 mackenga is on a distinguished road
PHP's support for dynamically creating images is excellent. If you're working in a CGI script in a language that isn't quite so great at this, see if your host has ImageMagick; you can shell out to it for image operations and it rules.
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC