Dynamic images

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

    Dynamic images

    Ok, I just wrote some functions last night for a few people, I posted them
    up for whom ever wants it (free)



    It is simple a way to spit out thumbs, or resized images, and to cache the
    image so it doesnt have to be rebuilt.

    Nothing fancy, but it could help a few people out.

    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools


  • Chung Leong

    #2
    Re: Dynamic images

    Nice. I think we make better use of the client cache though, by redirecting
    to the generated image. As it is, the browser has to refetch the image
    everytime.

    Uzytkownik "CountScubu la" <me@scantek.hot mail.com> napisal w wiadomosci
    news:5F7Qb.1487 2$Lm7.4174@news svr25.news.prod igy.com...[color=blue]
    > Ok, I just wrote some functions last night for a few people, I posted them
    > up for whom ever wants it (free)
    >
    > http://www.gzentools.com/gzimg.php
    >
    > It is simple a way to spit out thumbs, or resized images, and to cache the
    > image so it doesnt have to be rebuilt.
    >
    > Nothing fancy, but it could help a few people out.
    >
    > --
    > Mike Bradley
    > http://www.gzentools.com -- free online php tools
    >
    >[/color]


    Comment

    • CountScubula

      #3
      Re: Dynamic images

      "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
      news:iIydnbKaXI qAXIzd4p2dnA@co mcast.com...[color=blue]
      > Nice. I think we make better use of the client cache though, by[/color]
      redirecting[color=blue]
      > to the generated image. As it is, the browser has to refetch the image
      > everytime.[/color]

      Thank you,

      Hmm, sounds interesting, you mean have a cache dir that is in the web server
      view, and do a Location: bla.... to point to the image?

      Hmm I will have to play and see, becouse as it is, if there is any change
      int he source image, there is a new image generated.

      also, I just added a few more functions:

      title - add a caption
      pan - show part of image
      zoom - show a zoomed from middle portion
      tile - tile the image



      --
      Mike Bradley
      http://www.gzentools.com -- free online php tools


      Comment

      • FLEB

        #4
        Re: Dynamic images

        Regarding this well-known quote, often attributed to CountScubula's famous
        "Sat, 24 Jan 2004 01:48:37 GMT" speech:
        [color=blue]
        > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
        > news:iIydnbKaXI qAXIzd4p2dnA@co mcast.com...[color=green]
        >> Nice. I think we make better use of the client cache though, by[/color]
        > redirecting[color=green]
        >> to the generated image. As it is, the browser has to refetch the image
        >> everytime.[/color]
        >
        > Thank you,
        >
        > Hmm, sounds interesting, you mean have a cache dir that is in the web server
        > view, and do a Location: bla.... to point to the image?
        >
        > Hmm I will have to play and see, becouse as it is, if there is any change
        > int he source image, there is a new image generated.
        >
        > also, I just added a few more functions:
        >
        > title - add a caption
        > pan - show part of image
        > zoom - show a zoomed from middle portion
        > tile - tile the image[/color]

        Just title the cached image uniquely --

        something like:
        [PATH-HASH]_[MOD-DATE].ext

        where [PATH-HASH] is the full original path, run through something (md5 or
        a search-replace) to purge evil chars, and [MOD-DATE] is the file's
        last-modified date. When the code is run, do something like:

        1.) Get all filenames containing [PATH-HASH] in the cache directory
        2.) Is the latest [MOD-DATE] the same as the real file's modified-stamp?

        3. Yes) Do not recreate the thumbnail. Redirect to the cached version.

        3. No) Delete (unlink) all files with [PATH-HASH]_*
        4. No) Create a new thumbnail, and redirect to it.

        --
        -- Rudy Fleminger
        -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
        (put "Hey!" in the Subject line for priority processing!)
        -- http://www.pixelsaredead.com

        Comment

        • CountScubula

          #5
          Re: Dynamic images

          "FLEB" <soon.the.sp@mm ers.and.evil.on es.will.bow-down-to.us> wrote in
          message news:1pbg7eno9k a0z.1rltln0ileg gu$.dlg@40tude. net...[color=blue]
          > Regarding this well-known quote, often attributed to CountScubula's famous
          > "Sat, 24 Jan 2004 01:48:37 GMT" speech:
          >
          > 1.) Get all filenames containing [PATH-HASH] in the cache directory
          > 2.) Is the latest [MOD-DATE] the same as the real file's modified-stamp?
          >
          > 3. Yes) Do not recreate the thumbnail. Redirect to the cached version.
          >
          > 3. No) Delete (unlink) all files with [PATH-HASH]_*
          > 4. No) Create a new thumbnail, and redirect to it.
          >
          > --
          > -- Rudy Fleminger
          > -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
          > (put "Hey!" in the Subject line for priority processing!)
          > -- http://www.pixelsaredead.com[/color]


          the images are already cached and uniq named, Leong was talking about
          redirecting rather than readfile. look at the script and you will
          understand.

          --
          Mike Bradley
          http://www.gzentools.com -- free online php tools


          Comment

          • Chung Leong

            #6
            Re: Dynamic images

            Yup, let Apache send the image, since it's pretty good at dealing with the
            nitty gritty of HTTP transport (caching, validation, partial retrieval,
            etc.). Also saves a trip into the PHP output buffer.

            I guess you can implement it in a different set of functions, so that you
            would retain the ability to send the file via PHP, in cases where you want
            to control access to the images.

            One more suggestion: before calling readfile(), do a session_write_c lose()
            to remove the session lock if a session is opened.

            Uzytkownik "CountScubu la" <me@scantek.hot mail.com> napisal w wiadomosci
            news:V9kQb.1649 1$aJ4.6243@news svr25.news.prod igy.com...[color=blue]
            > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
            > news:iIydnbKaXI qAXIzd4p2dnA@co mcast.com...
            > Hmm, sounds interesting, you mean have a cache dir that is in the web[/color]
            server[color=blue]
            > view, and do a Location: bla.... to point to the image?
            >
            > Hmm I will have to play and see, becouse as it is, if there is any change
            > int he source image, there is a new image generated.
            >
            > also, I just added a few more functions:
            >
            > title - add a caption
            > pan - show part of image
            > zoom - show a zoomed from middle portion
            > tile - tile the image
            >
            >
            >
            > --
            > Mike Bradley
            > http://www.gzentools.com -- free online php tools
            >
            >[/color]


            Comment

            • CountScubula

              #7
              Re: Dynamic images

              "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
              news:7o6dncz6w7-thY7dRVn-iQ@comcast.com. ..[color=blue]
              > Yup, let Apache send the image, since it's pretty good at dealing with the
              > nitty gritty of HTTP transport (caching, validation, partial retrieval,
              > etc.). Also saves a trip into the PHP output buffer.
              >[/color]

              Working on it as we converse, will be in ver 1.5, I added a few things check
              it out.
              [color=blue]
              > One more suggestion: before calling readfile(), do a session_write_c lose()
              > to remove the session lock if a session is opened.[/color]

              Please explain, can you elaborate?

              --
              Mike Bradley
              http://www.gzentools.com -- free online php tools


              Comment

              • Dan Tripp

                #8
                Re: Dynamic images

                CountScubula wrote:[color=blue]
                > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                > news:7o6dncz6w7-thY7dRVn-iQ@comcast.com. ..
                >[color=green]
                >>Yup, let Apache send the image, since it's pretty good at dealing with the
                >>nitty gritty of HTTP transport (caching, validation, partial retrieval,
                >>etc.). Also saves a trip into the PHP output buffer.
                >>[/color]
                >
                >
                > Working on it as we converse, will be in ver 1.5, I added a few things check
                > it out.
                >
                >[color=green]
                >>One more suggestion: before calling readfile(), do a session_write_c lose()
                >>to remove the session lock if a session is opened.[/color]
                >
                >
                > Please explain, can you elaborate?
                >
                > --
                > Mike Bradley
                > http://www.gzentools.com -- free online php tools
                >
                >[/color]

                I dig this:
                gzImageSetCache Dir(dir[,url]);
                That's hot.

                - Dan

                Comment

                • Chung Leong

                  #9
                  Re: Dynamic images

                  Two PHP scripts cannot access the same session simultaneously. If the
                  browser tries to download two images concurrently, and a session is opened
                  (say, if auto session is used), one of them will stall until the other is
                  done, unless you release the session with a call to session_write_c lose().

                  Uzytkownik "CountScubu la" <me@scantek.hot mail.com> napisal w wiadomosci
                  news:LAGQb.5688 $F84.5372@newss vr29.news.prodi gy.com...[color=blue]
                  > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                  > news:7o6dncz6w7-thY7dRVn-iQ@comcast.com. ..[color=green]
                  > > Yup, let Apache send the image, since it's pretty good at dealing with[/color][/color]
                  the[color=blue][color=green]
                  > > nitty gritty of HTTP transport (caching, validation, partial retrieval,
                  > > etc.). Also saves a trip into the PHP output buffer.
                  > >[/color]
                  >
                  > Working on it as we converse, will be in ver 1.5, I added a few things[/color]
                  check[color=blue]
                  > it out.
                  >[color=green]
                  > > One more suggestion: before calling readfile(), do a[/color][/color]
                  session_write_c lose()[color=blue][color=green]
                  > > to remove the session lock if a session is opened.[/color]
                  >
                  > Please explain, can you elaborate?
                  >
                  > --
                  > Mike Bradley
                  > http://www.gzentools.com -- free online php tools
                  >
                  >[/color]


                  Comment

                  Working...