[n/a] Dynamic graphics on web servers - Nerd Alert!

gibbons

En-Route
Joined
Feb 12, 2005
Messages
3,385
Location
Rogers, Arkansas
Display Name

Display name:
iRide
I'm working on a web site for a new subdivision. I'd like to be able to show a plat map with a red "S" over the lots which are under contract, and want to build this dynamically based on the contents of a database. I suppose this would involve developing a server side application that can produce a dynamic gif image. Any of you nerds have a line on how this can be done? I can't find anything via Google.
 
gibbons said:
I'm working on a web site for a new subdivision. I'd like to be able to show a plat map with a red "S" over the lots which are under contract, and want to build this dynamically based on the contents of a database. I suppose this would involve developing a server side application that can produce a dynamic gif image. Any of you nerds have a line on how this can be done? I can't find anything via Google.
You need a perl application which can dynamically MODIFY a GIF image and I'm sure there are many.

http://www.webreference.com/programming/perl/graphics/

Got it! You want a "watermark"
http://search.cpan.org/~tonyc/Imager-0.45/lib/Imager/Filters.pod
 
Chip. This is an easy to use php script that will watermark any image for you dynamically. if you have any questions, give me a shout.

Code:
[color=#000000][color=#0000bb]<?php 
[/color][color=#ff8000]// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file 
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory as this script 
// where this script is named watermark.php 
// call this script with an image tag 
// <img src="watermark.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg 
[/color][color=#0000bb]$imagesource [/color][color=#007700]=  [/color][color=#0000bb]$_GET[/color][color=#007700][[/color][color=#dd0000]'path'[/color][color=#007700]]; 
[/color][color=#0000bb]$filetype [/color][color=#007700]= [/color][color=#0000bb]substr[/color][color=#007700]([/color][color=#0000bb]$imagesource[/color][color=#007700],[/color][color=#0000bb]strlen[/color][color=#007700]([/color][color=#0000bb]$imagesource[/color][color=#007700])-[/color][color=#0000bb]4[/color][color=#007700],[/color][color=#0000bb]4[/color][color=#007700]); 
[/color][color=#0000bb]$filetype [/color][color=#007700]= [/color][color=#0000bb]strtolower[/color][color=#007700]([/color][color=#0000bb]$filetype[/color][color=#007700]); 
if([/color][color=#0000bb]$filetype [/color][color=#007700]== [/color][color=#dd0000]".gif"[/color][color=#007700])  [/color][color=#0000bb]$image [/color][color=#007700]= @[/color][color=#0000bb]imagecreatefromgif[/color][color=#007700]([/color][color=#0000bb]$imagesource[/color][color=#007700]);  
if([/color][color=#0000bb]$filetype [/color][color=#007700]== [/color][color=#dd0000]".jpg"[/color][color=#007700])  [/color][color=#0000bb]$image [/color][color=#007700]= @[/color][color=#0000bb]imagecreatefromjpeg[/color][color=#007700]([/color][color=#0000bb]$imagesource[/color][color=#007700]);  
if([/color][color=#0000bb]$filetype [/color][color=#007700]== [/color][color=#dd0000]".png"[/color][color=#007700])  [/color][color=#0000bb]$image [/color][color=#007700]= @[/color][color=#0000bb]imagecreatefrompng[/color][color=#007700]([/color][color=#0000bb]$imagesource[/color][color=#007700]);  
if (![/color][color=#0000bb]$image[/color][color=#007700]) die(); 
[/color][color=#0000bb]$watermark [/color][color=#007700]= @[/color][color=#0000bb]imagecreatefromgif[/color][color=#007700]([/color][color=#dd0000]'watermark.gif'[/color][color=#007700]); 
[/color][color=#0000bb]$imagewidth [/color][color=#007700]= [/color][color=#0000bb]imagesx[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]); 
[/color][color=#0000bb]$imageheight [/color][color=#007700]= [/color][color=#0000bb]imagesy[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]);  
[/color][color=#0000bb]$watermarkwidth [/color][color=#007700]=  [/color][color=#0000bb]imagesx[/color][color=#007700]([/color][color=#0000bb]$watermark[/color][color=#007700]); 
[/color][color=#0000bb]$watermarkheight [/color][color=#007700]=  [/color][color=#0000bb]imagesy[/color][color=#007700]([/color][color=#0000bb]$watermark[/color][color=#007700]); 
[/color][color=#0000bb]$startwidth [/color][color=#007700]= (([/color][color=#0000bb]$imagewidth [/color][color=#007700]- [/color][color=#0000bb]$watermarkwidth[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]); 
[/color][color=#0000bb]$startheight [/color][color=#007700]= (([/color][color=#0000bb]$imageheight [/color][color=#007700]- [/color][color=#0000bb]$watermarkheight[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]); 
[/color][color=#0000bb]imagecopy[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700], [/color][color=#0000bb]$watermark[/color][color=#007700],  [/color][color=#0000bb]$startwidth[/color][color=#007700], [/color][color=#0000bb]$startheight[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]$watermarkwidth[/color][color=#007700], [/color][color=#0000bb]$watermarkheight[/color][color=#007700]); 
[/color][color=#0000bb]imagejpeg[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]); 
[/color][color=#0000bb]imagedestroy[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]); 
[/color][color=#0000bb]imagedestroy[/color][color=#007700]([/color][color=#0000bb]$watermark[/color][color=#007700]); 
[/color][color=#0000bb]?>[/color] [/color]
 
the other option, is have two images, and call them depending on the circumstances.
Code:
if ($lot == "sold") {
<img src="pic1">;
} 
elseif ($lot == "available") {
<img src="pic2">;
}

$lot can be defined from a database query or from a web based form that you update.
 
Michael said:
Chip. This is an easy to use php script that will watermark any image for you dynamically. if you have any questions, give me a shout.

Code:
[color=#0000bb]$watermark[/color][color=#007700],  [/color][color=#0000bb]$startwidth[/color][color=#007700], [/color][color=#0000bb]$startheight[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]$watermarkwidth[/color][color=#007700], [/color][color=#0000bb]$watermarkheight[/color][color=#007700]); 
[/color][color=#0000bb]imagejpeg[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]); 
[/color][color=#0000bb]imagedestroy[/color][color=#007700]([/color][color=#0000bb]$image[/color][color=#007700]); 
[/color][color=#0000bb]imagedestroy[/color][color=#007700]([/color][color=#0000bb]$watermark[/color][color=#007700]); 
[/color][color=#0000bb]?>[/color]
Wow, Michael! Are those image functions built-in to the standard PHP packages? I gotta read up on those.
 
Back
Top