473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

dynamic image and area creation

Hi- I want to create a dynamic image with areas so that when the user
clicks different areas, the user jumps to those pages. The problem
is, I can't seem to figure out how to do this efficiently.

Suppose I have a table,items in a database:

itemid description count

So, basically, I want to create an image that has 3 ovals,
representing the top 3 occurring items (with the highest count) in
this table. So, first, I create the image html:

echo "<image src=genimage.php?items=$itemstring...

So, here, I pass genimage a string that encodes the keys for the top 3
occurring items. And in genimage, a query is created and called to
get the descriptions and counts, and then displays those descriptions
and counts in the ovals.

The problem is, now I have to do this all over again to generate the
area tags and corresponding jump URLs. Why? because I can only send
the data in a GET string, since the image source has to be a url. So,
I'm calling the identical query twice-once inside the image
generation, and once in the area generation.

I suppose I *could* get all the data once (the item descriptions and
counts) and encode all of that and send that as a data string, but
there has to be an easier way.

Another suboptimal solution is to generate a temporary image and
create img link to that image, but I'd rather keep these dynamic.

So, is there a way create and then embed an image directly into a
page? Or must I use a URL reference?

In other words, what I'd like to do is something like:
echo "<img src= THIS IMAGE STREAM I'M GENERATING RIGHT NOW...

Any ideas on if this can be accomplished?

Thanks,
Dino

Oct 1 '07 #1
7 2358

"dino d." <di*********@yahoo.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
Hi- I want to create a dynamic image with areas so that when the user
clicks different areas, the user jumps to those pages. The problem
is, I can't seem to figure out how to do this efficiently.

Suppose I have a table,items in a database:

itemid description count

So, basically, I want to create an image that has 3 ovals,
representing the top 3 occurring items (with the highest count) in
this table. So, first, I create the image html:

echo "<image src=genimage.php?items=$itemstring...

So, here, I pass genimage a string that encodes the keys for the top 3
occurring items. And in genimage, a query is created and called to
get the descriptions and counts, and then displays those descriptions
and counts in the ovals.

The problem is, now I have to do this all over again to generate the
area tags and corresponding jump URLs. Why? because I can only send
the data in a GET string, since the image source has to be a url. So,
I'm calling the identical query twice-once inside the image
generation, and once in the area generation.

I suppose I *could* get all the data once (the item descriptions and
counts) and encode all of that and send that as a data string, but
there has to be an easier way.

Another suboptimal solution is to generate a temporary image and
create img link to that image, but I'd rather keep these dynamic.

So, is there a way create and then embed an image directly into a
page? Or must I use a URL reference?

In other words, what I'd like to do is something like:
echo "<img src= THIS IMAGE STREAM I'M GENERATING RIGHT NOW...

Any ideas on if this can be accomplished?

Thanks,
Dino
I have read this three times and
(a) I still can't figure out what you are trying to do and
(b) what problems your are having.

Shelly
Oct 1 '07 #2
<comp.lang.php>
<dino d.>
<Mon, 01 Oct 2007 12:13:43 -0700>
<11**********************@19g2000hsx.googlegroups. com>
Hi- I want to create a dynamic image with areas so that when the user
clicks different areas, the user jumps to those pages. The problem
is, I can't seem to figure out how to do this efficiently.
Easy using GD .

- grab the images and calculate the total width and/or height
- paste the images onto a newly created blank image
- create 'image map' co-ordinates and associate urls with the areas

If you have never used a 'image map' before - then create some image map
areas in a web authoring app and then have a look at the html code .
--
www.vhit.co.uk
Oct 1 '07 #3


I have read this three times and
(a) I still can't figure out what you are trying to do and
(b) what problems your are having.

Shelly
Thanks for the reply Shelly. I apologize for the confusing wording of
the problem.

Here's what the problem is in a simpler form.

If you want to create an image dynamically, and then create the
corresponding map and area tags, is there a way to somehow save the
spatial calculations that you did to create the image for use in
creating the area tags.

Let's just assume you have a page that you pass 3 strings to via GET,
and all the page does is generate three ovals containing those
strings.

That image generation page has to calculate the width of the strings,
etc. and then the size of the ovals so that the strings fit nicely
into the ovals.

Now, you want to go back and create the map to that image so when the
user clicks on the ovals, he is taken to a new page. It seems to me,
that you now have to do this spatial calculation all over again,
because there's no way to return the locations of the ovals.

Is this clearer?

Thanks again for the response.

Dino


Oct 1 '07 #4
- grab the images and calculate the total width and/or height
- paste the images onto a newly created blank image
- create 'image map' co-ordinates and associate urls with the areas
Thanks for the post. The problem is not how to do it, the problem is
how to do it efficiently? Calculating the individual image
coordinates takes n steps, and then you have to re-calculate the exact
same coordinates for the map because there is no way to get them out
of the image, short of saving them to some temp file. I am looking for
a workaround that lets me do the calculations once, render the image,
and somehow pass the calculations back to the calling script.

Dino

Oct 1 '07 #5
The 'stream' is where your going wrong .

The end result your looking for is just a normal .jpg image with a
suitable image map matched to it .

The end result .jpg and image map being generated via your genimage.php
script .
so you're suggesting saving this to a file, then referencing the file,
rather than referencing a script?

Oct 1 '07 #6
<comp.lang.php>
<dino d.>
<Mon, 01 Oct 2007 13:50:54 -0700>
<11**********************@57g2000hsv.googlegroups. com>
The 'stream' is where your going wrong .

The end result your looking for is just a normal .jpg image with a
suitable image map matched to it .

The end result .jpg and image map being generated via your genimage.php
script .

so you're suggesting saving this to a file, then referencing the file,
rather than referencing a script?
Only if you intend to reuse the generated image , A image generated by
GD doesnt need to be saved to a file .

Either way , You need to process and create everything before using the
<imgtag to display the .jpg image .

You also need to do everything in a logical step by step fashion .

Step one in your learning curve is how to find out the (width) of the
text thats passed via GET .

Step two is generating the oval images from the above widths .

Step three is putting the text into the center of the oval .

Step four is counting up the 3 widths to create blank image .

Step five is pasting the 3 oval image onto the blank image .

No point going any further until you can do all the above .

Typing the following string into google would be aq good start .

php tutorial find the text width of a string
--
www.vhit.co.uk
Oct 1 '07 #7
dino d. wrote:
Hi- I want to create a dynamic image with areas so that when the user
clicks different areas, the user jumps to those pages. The problem
is, I can't seem to figure out how to do this efficiently.

Suppose I have a table,items in a database:

itemid description count

So, basically, I want to create an image that has 3 ovals,
representing the top 3 occurring items (with the highest count) in
this table. So, first, I create the image html:

echo "<image src=genimage.php?items=$itemstring...

So, here, I pass genimage a string that encodes the keys for the top 3
occurring items. And in genimage, a query is created and called to
get the descriptions and counts, and then displays those descriptions
and counts in the ovals.

The problem is, now I have to do this all over again to generate the
area tags and corresponding jump URLs. Why? because I can only send
the data in a GET string, since the image source has to be a url. So,
I'm calling the identical query twice-once inside the image
generation, and once in the area generation.

I suppose I *could* get all the data once (the item descriptions and
counts) and encode all of that and send that as a data string, but
there has to be an easier way.

Another suboptimal solution is to generate a temporary image and
create img link to that image, but I'd rather keep these dynamic.

So, is there a way create and then embed an image directly into a
page? Or must I use a URL reference?

In other words, what I'd like to do is something like:
echo "<img src= THIS IMAGE STREAM I'M GENERATING RIGHT NOW...

Any ideas on if this can be accomplished?

Thanks,
Dino
Hi, Dino,

Yes, this is a problem.

You can do it, but it's not easy.

First of all, remember that your main page (the one containing the <img>
statement) is processed first. Once it has been processed and sent to
the browser, the browser will request the file referenced in the <img>
statement.

With this information, you could do the processing in your main file,
then save the data in a file or database, then pass the information on
to the image through a query parameter.

Another option could be to store the info in the $_SESSION array, as
long as you close the session before the image is requested. Normally
this wouldn't be until after your page is completed, but for safety you
might want to close the session before you issue the <imgstatement.

Hope this gives you a couple of ideas.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 2 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dickseacup | last post by:
Is there a way to generate a dynamic image, passing an array (of arrays) to the image creation script, such that it displays along with text on a php generated HTML page? I either get header...
7
by: Craig Storey | last post by:
I have a little php application to store day hiking trips and to keep a running total of their yearly trips for a few users. Currently they select their hiking routes using drop lists or...
5
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK'...
0
by: Hemanth | last post by:
Hello, I'm generating a dynamic image on a website (using php.net/image library) and I want add hyperlinks to certain locations on the image - similar to HTML image map. Could someone pls...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.