imagecreatefromjpeg, calling a .php file

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

    imagecreatefromjpeg, calling a .php file

    Ok all. I have a series of images stored in a db. Im trying to work on
    a script that will let me scale them based on user input. Ive hit a bit
    of a roadblock on this line.

    $orig =
    imagecreatefrom jpeg("DisplayIm age.php?imageId =".$this->mImage->GetImageId() );

    Specifically it cant sopen that file.

    DisplayImage.ph p is pretty simple, it just displays an image from the
    db without writing to a file.

    Im thinking the problem is in how im pathing to DisplayImage.ph p.

    This file sits one level lower than most things so it should be
    .../displayImage, but i tried that and no luck.

    Any ideas whats wrong with that line?

  • Erwin Moller

    #2
    Re: imagecreatefrom jpeg, calling a .php file

    Areric wrote:
    [color=blue]
    > Ok all. I have a series of images stored in a db. Im trying to work on
    > a script that will let me scale them based on user input. Ive hit a bit
    > of a roadblock on this line.
    >
    > $orig =
    >[/color]
    imagecreatefrom jpeg("DisplayIm age.php?imageId =".$this->mImage->GetImageId() );[color=blue]
    >
    > Specifically it cant sopen that file.
    >
    > DisplayImage.ph p is pretty simple, it just displays an image from the
    > db without writing to a file.
    >
    > Im thinking the problem is in how im pathing to DisplayImage.ph p.
    >
    > This file sits one level lower than most things so it should be
    > ../displayImage, but i tried that and no luck.
    >
    > Any ideas whats wrong with that line?[/color]

    There is nothing wrong with that line except that it is NOT the path to your
    image.

    You are confusing:
    - the path to your image (nonexistent)
    - with a php-script delivering the image.

    Here is the difference: The is no such thing as the path to your image. Only
    a URI (http) that points to your image.
    The difference is that in the URI situation you invoke a script that
    produces the image, while imagecreatefrom jpeg WANTS A PATH, as can be read
    in the documentation at www.php.net.
    NOT a URI, unless:

    from http://nl2.php.net/manual/en/functio...tefromjpeg.php
    --------------
    Tip: You can use a URL as a filename with this function if the fopen
    wrappers have been enabled. See fopen() for more details on how to specify
    the filename and Appendix M for a list of supported URL protocols.
    -----------------

    So check that. :-)

    And also remember that ../bla.php is NOT a good URI, it is just a part.
    If you use URI, make sure they are full/well formed, like:


    If you cannot make it work with fopenwrappers, just safe them from your
    script in a directory, named after their ID's or something like that.

    Regards,
    Erwin Moler

    Comment

    • Areric

      #3
      Re: imagecreatefrom jpeg, calling a .php file

      Hey thanks Erwin. I actually checked the box and that config option was
      already enabled so all i had to do was give it a fully qualified url.

      Comment

      • Chung Leong

        #4
        Re: imagecreatefrom jpeg, calling a .php file


        Areric wrote:[color=blue]
        > Ok all. I have a series of images stored in a db. Im trying to work on
        > a script that will let me scale them based on user input. Ive hit a bit
        > of a roadblock on this line.
        >
        > $orig =
        > imagecreatefrom jpeg("DisplayIm age.php?imageId =".$this->mImage->GetImageId() );
        >
        > Specifically it cant sopen that file.
        >
        > DisplayImage.ph p is pretty simple, it just displays an image from the
        > db without writing to a file.
        >
        > Im thinking the problem is in how im pathing to DisplayImage.ph p.
        >
        > This file sits one level lower than most things so it should be
        > ../displayImage, but i tried that and no luck.
        >
        > Any ideas whats wrong with that line?[/color]

        Why don't you just read from the database directly and use
        imagecreatefrom string()?

        Comment

        • Areric

          #5
          Re: imagecreatefrom jpeg, calling a .php file

          Chung,

          Im trying to break up as much as possible. This particular library I
          really dont want to be dependant on any specific database
          implementation. Im trying to abstract that out so i can reuse this
          stuff independanly.

          My DisplayImage.ph p script is dependant on the DB but not my
          imagemanipulati on script.

          Good idea though, im wondering if instead of returning an image object
          i could just return the string itself.

          Comment

          • Chung Leong

            #6
            Re: imagecreatefrom jpeg, calling a .php file


            Areric wrote:[color=blue]
            > Chung,
            >
            > Im trying to break up as much as possible. This particular library I
            > really dont want to be dependant on any specific database
            > implementation. Im trying to abstract that out so i can reuse this
            > stuff independanly.
            >
            > My DisplayImage.ph p script is dependant on the DB but not my
            > imagemanipulati on script.
            >
            > Good idea though, im wondering if instead of returning an image object
            > i could just return the string itself.[/color]

            In that case a slicker approach is to define a stream wrapper that
            reads from the database. See
            http://fi.php.net/stream-wrapper-register/.

            Comment

            Working...