dynamic image loading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • OneSolution

    dynamic image loading

    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=101127 4772185.1011242 055951.10112002 90023.5850&
    o=http://ccprod.roving.c om/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 -


  • Pedro Graca

    #2
    Re: dynamic image loading

    OneSolution wrote [edited]:[color=blue]
    > <IMG SRC="--censored--.gif" WIDTH=1 HEIGHT=1 alt=" ">[/color]

    Shouldn't the alt attribute be "web bug"? :-)


    [color=blue]
    > So can someone please explain to me how I can achieve this objective?[/color]


    You already posted the solution.
    Just make a script that saves /whatever/ to the database and outputs an
    image.


    <?php
    save_to_db($wha tever);
    output_img($web bug);
    ?>


    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 :

    Comment

    • William Holroyd

      #3
      Re: dynamic image loading

      > <IMG[color=blue]
      >[/color]
      SRC="http://rs6.net/on.jsp?t=101127 4772185.1011242 055951.10112002 90023.5850&[color=blue]
      > o=http://ccprod.roving.c om/roving/images/p1x1.gif" WIDTH=1 HEIGHT=1 alt="[/color]
      ">[color=blue]
      >
      > 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[/color]
      loaded.[color=blue]
      > 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[/color]
      software[color=blue]
      > opens my mailout, and in the process of loading up a key image on the[/color]
      page,[color=blue]
      > my backend PHP updates my MySQL server about this activity.
      >
      > So can someone please explain to me how I can achieve this objective?[/color]

      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 = imagecreatefrom jpeg("nikon_ava tar0".$num.".jp g");
      imagejpeg($imag e);
      imagedestroy($i mage);
      ?>

      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


      Comment

      • Tim Van Wassenhove

        #4
        Re: dynamic image loading

        In article <LZboc.7833$0J5 .3429@newssvr24 .news.prodigy.c om>, OneSolution wrote:[color=blue]
        ><IMG
        > SRC="http://rs6.net/on.jsp?t=101127 4772185.1011242 055951.10112002 90023.5850&
        > o=http://ccprod.roving.c om/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.[/color]

        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($ad dr); // using geoip or the like
        $url = findURL($countr y); // lookup the url for the given country in our db
        header('Locatio n: $url');
        ?>
        [color=blue]
        > 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.[/color]

        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.


        --

        Comment

        • Theo

          #5
          Re: dynamic image loading

          "William Holroyd" <w.holroyd@vers ity-cobalt.com> wrote in news:c7s289$d96 $1
          @cnn.cns.ksu.ed u:
          [color=blue]
          > imagejpeg($imag e);
          > imagedestroy($i mage);[/color]

          I never heard of these functions, being new to PHP, but I did some googling
          and an example of its (imagecreatefro mjpeg) 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?

          Comment

          • William Holroyd

            #6
            Re: dynamic image loading

            The use of imagecreatefrom jpeg() 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" <invalid@noemai l.com> wrote in message
            news:Xns94E76FC B84BB7densnews1 23@216.168.3.44 ...[color=blue]
            > "William Holroyd" <w.holroyd@vers ity-cobalt.com> wrote in[/color]
            news:c7s289$d96 $1[color=blue]
            > @cnn.cns.ksu.ed u:
            >[color=green]
            > > imagejpeg($imag e);
            > > imagedestroy($i mage);[/color]
            >
            > I never heard of these functions, being new to PHP, but I did some[/color]
            googling[color=blue]
            > and an example of its (imagecreatefro mjpeg) use reads like it will use a
            > larger image as a reference, and then make a temp smaller copy of it on[/color]
            the[color=blue]
            > server (say a thumbnail) for download... intead of having to manually
            > create and store thumbnails. Does that sound about right?[/color]


            Comment

            Working...