By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,871 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,871 IT Pros & Developers. It's quick & easy.

dynamic image loading

P: n/a
Hi All,

Here's what I'm trying to do.

I have a diverse customer base, and as it grows, it's increasingly harder to
figure out what aspect of our web site is selling and what is not. So I've
been trying to use PHP (and/or ASP) to do some research on my customers. So
I nosed around some web sites and found the following piece of code.

<IMG
SRC="http://rs6.net/on.jsp?t=1011274772185.1011242055951.1011200290023 .5850&
o=http://ccprod.roving.com/roving/images/p1x1.gif" WIDTH=1 HEIGHT=1 alt=" ">

Here's what I understand from it ... this image source is actually a JSP
that does some statistics generation after which the actual image is loaded.
I tried doing this with an ASP and PHP page but I don't know what type of
code would go into the proper code to actually return an image to the
calling HTML.

In summary, I e-mail a page to my clients. Their HTML enabled mail software
opens my mailout, and in the process of loading up a key image on the page,
my backend PHP updates my MySQL server about this activity.

So can someone please explain to me how I can achieve this objective?

Thanks so much.

- Z -
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
OneSolution wrote [edited]:
<IMG SRC="--censored--.gif" WIDTH=1 HEIGHT=1 alt=" ">
Shouldn't the alt attribute be "web bug"? :-)
So can someone please explain to me how I can achieve this objective?

You already posted the solution.
Just make a script that saves /whatever/ to the database and outputs an
image.
<?php
save_to_db($whatever);
output_img($webbug);
?>
Easy!

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

P: n/a
> <IMG
SRC="http://rs6.net/on.jsp?t=1011274772185.1011242055951.1011200290023 .5850& o=http://ccprod.roving.com/roving/images/p1x1.gif" WIDTH=1 HEIGHT=1 alt=" ">
Here's what I understand from it ... this image source is actually a JSP
that does some statistics generation after which the actual image is loaded. I tried doing this with an ASP and PHP page but I don't know what type of
code would go into the proper code to actually return an image to the
calling HTML.

In summary, I e-mail a page to my clients. Their HTML enabled mail software opens my mailout, and in the process of loading up a key image on the page, my backend PHP updates my MySQL server about this activity.

So can someone please explain to me how I can achieve this objective?


I'm a member on a photography website and to spice stuff up, I made a php
script that I could call that would output a random file. Here's the code...

<?php
header("Content-type: image/jpeg");

$num = rand(1,3);
$image = imagecreatefromjpeg("nikon_avatar0".$num.".jpg");
imagejpeg($image);
imagedestroy($image);
?>

Within the folder, I have three JPEG images named...
nikon_avatar01.jpg

nikon_avatar02.jpg

nikon_avatar03.jpg

Basic, but easily expandable to check the referer and give an alternate
image if it's requested outside of the website such as a link from another
website.

-William
Jul 17 '05 #3

P: n/a
In article <LZ*****************@newssvr24.news.prodigy.com> , OneSolution wrote:
<IMG
SRC="http://rs6.net/on.jsp?t=1011274772185.1011242055951.1011200290023 .5850&
o=http://ccprod.roving.com/roving/images/p1x1.gif" WIDTH=1 HEIGHT=1 alt=" ">

Here's what I understand from it ... this image source is actually a JSP
that does some statistics generation after which the actual image is loaded.
I tried doing this with an ASP and PHP page but I don't know what type of
code would go into the proper code to actually return an image to the
calling HTML.
I see most people generating some an image in that code.
Instead of doing that my script does the statistics, and then redirects
to the actual image.

Fe:
<?php //banner.php
doOtherStuff($_GET['client_id']); // do bookkeeping for this client
$addr = $_SERVER['REMOTE_ADDRESS'];
$country = findCountry($addr); // using geoip or the like
$url = findURL($country); // lookup the url for the given country in our db
header('Location: $url');
?>
In summary, I e-mail a page to my clients. Their HTML enabled mail software
opens my mailout, and in the process of loading up a key image on the page,
my backend PHP updates my MySQL server about this activity.


I'm happy that every decent mail/news client has the ability to disable
the loading of external images in an e-mail or usenet posting.
--
http://home.mysth.be/~timvw
Jul 17 '05 #4

P: n/a
"William Holroyd" <w.*******@versity-cobalt.com> wrote in news:c7s289$d96$1
@cnn.cns.ksu.edu:
imagejpeg($image);
imagedestroy($image);


I never heard of these functions, being new to PHP, but I did some googling
and an example of its (imagecreatefromjpeg) use reads like it will use a
larger image as a reference, and then make a temp smaller copy of it on the
server (say a thumbnail) for download... intead of having to manually
create and store thumbnails. Does that sound about right?
Jul 17 '05 #5

P: n/a
The use of imagecreatefromjpeg() simply allows you to load an existing JPEG
image file into memory to manipulate. You could also use the ...frompng,
....fromgif, or ...fromwbmp to load the respective file formats as well. It
just allows php to know what file type it is you are loading and how to
organize it in the buffer (thats the way it was explained to me). The
following calls imagejpeg(), ...gif(), ...png(), ...wbmp() simply take the
image in the buffer and "compile" it into a data structure for that image
format. And then finally imagedestroy() dumps the image data in the buffer
to free up memory.

Just remember to output the correct header or you might get a funky image.

You may also use the exif functions with a switch statement to discover what
format it is and use the appropriate image functions.

<?

switch (exif_imagetype($file)) {
case IMAGETYPE_GIF:
$image_type = IMG_GIF;
break;
case IMAGETYPE_JPEG:
$image_type = IMG_JPG;
break;
case IMAGETYPE_PNG:
$image_type = IMG_PNG;
break;
case IMAGETYPE_WBMP:
$image_type = IMG_WBMP;
break;
default:
$image_type = 0;
break;
}

?>

-William

"Theo" <in*****@noemail.com> wrote in message
news:Xn*************************@216.168.3.44...
"William Holroyd" <w.*******@versity-cobalt.com> wrote in news:c7s289$d96$1 @cnn.cns.ksu.edu:
imagejpeg($image);
imagedestroy($image);
I never heard of these functions, being new to PHP, but I did some

googling and an example of its (imagecreatefromjpeg) use reads like it will use a
larger image as a reference, and then make a temp smaller copy of it on the server (say a thumbnail) for download... intead of having to manually
create and store thumbnails. Does that sound about right?

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.