I'm working on the company website, and since we're a financial institution we have a listing of all the ATMs our members can use without surcharge. The previous webdesigner just threw the information up and it looked like crap. The first thing I did was to organize the information in an XML file, similar to this:

I've then created PHP scripts to parse the data and create a nicely formatted table for the results. I've even set up a mechanism where the area names are read and displayed as a drop box, allowing the viewer to see the locations of ATMs for a specific area.

I'm pelase (and so is my supervisor!), but I want to put it "over the top" by displaying a map of the area with the ATM locations starred. But that's where I'm stuck.

I could generate twenty or so maps (one for each area), and each map would have the ATM locations already highlighted. But, if we had an ATM to the network or loose one, then I have to go back, edit the XML data file accordingly, and then modify the map image. Now granted that only having to modify two items as opposed to all 4 or 5 doesn't seem that bad, but I'd like the maps to update themselves, too.

I've checked into SVG but our current server doesn't send them out with the correct MIME-type. And I can't control that because it's hosted by an outside company (I'm working on getting our own server and hosting it inhouse; I think it'll be cheaper and more secure, but that's still at least a year away by the time I clear through proposals and budget setbacks).

So how can I dynamicly generate, modify, or overlay an image over an existing image before serving it to the viewer using PHP?

To see my work so far, http://www.acmgfcu.org/temp/findatm.php It doesn't format the results "all pretty and stuff," I just ran out of time and I'll get to that tomorrow afternoon. But the scripts are functioning properly, and that's the important thing!

Thanks in advance,

-Tim

Íkii

02-26-2003, 10:39 AM

First things first, what version of GD does your build support?

Second note: dynamically generating an image at every page view is resource hungry and unneccessary when your image only needs changing when you add/delete an ATM. I'd suggest something whereby your admin interface creates and saves the image.

3rd: If you are running GD2+, I've a lil class that handles overlaying easily...
$a->merge('overlay.png',123,234,75,'FF0000')
image - xpos - ypos - opacity - transparent colour
though I wasn't really thinking of releasing it for commercial use, I could be persuaded. Would also be possible just to pull out the function merge and configure it for GD1.6.4 - 2, if needed.

You could also - if you decide to only construct through an admin interface, imagemap the graphic and alt-text or dhtml reference the hotspots.

Anyway, answer the above questions first if you could.

-------------------
subnote:
temp/php/page.php - you might want to assure you have write permissions to the xml file AND maybe combine all your fputs() into one call by constructing a string and then just appending that the once.

Darknight

02-27-2003, 07:54 PM

I'm glad you started this thread. I have been trying to do the same kinda thing.

I was able to get this to work!
make sure 1.jpg and 2.jpg are in the same folder.

there is an example in the "imageCopyMerge" user comments.
<?php
//$sourcefile = Filename of the picture into that $insertfile will be inserted.
//$insertfile = Filename of the picture that is to be inserted into $sourcefile.
//$targetfile = Filename of the modified picture.
//$transition = Intensity of the transition (in percent)
//$pos = Position where $insertfile will be inserted in $sourcefile
// 0 = middle
// 1 = top left
// 2 = top right
// 3 = bottom right
// 4 = bottom left
// 5 = top middle
// 6 = middle right
// 7 = bottom middle
// 8 = middle left
//
//
function mergePix($sourcefile,$insertfile, $targetfile, $pos=0,$transition=50)
{

//The main thing : merge the two pix
imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition);
//Create a jpeg out of the modified picture
imagejpeg ($sourcefile_id,"$targetfile");

}

mergePix("1.jpg","2.jpg","3.jpg", 0,50);
?>

<img src="3.jpg" border="0" alt="alt text">

Íkii

02-28-2003, 11:54 AM

I approached the overlay/merge from a different direction as I wanted to define one colour as transparent.

Basically, I just iterated through the merge image a pixel at a time, tested whether the colour was what I set as transparent and, if not, I merged the pixel to a relative point on the background image