imagecreatefromjpeg, calling a .php file

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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 =

Specifically it cant sopen that file.

DisplayImage.php 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.php.

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?

Re: imagecreatefromjpeg, calling a .php file

Areric wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it

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

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 imagecreatefromjpeg WANTS A PATH, as can be read  
in the documentation at  
NOT a URI, unless:

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.

Erwin Moler

Re: imagecreatefromjpeg, 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.

Re: imagecreatefromjpeg, calling a .php file

Areric wrote:
Quoted text here. Click to load it

Why don't you just read from the database directly and use

Re: imagecreatefromjpeg, calling a .php file


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.php script is dependant on the DB but not my
imagemanipulation script.

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

Re: imagecreatefromjpeg, calling a .php file

Areric wrote:
Quoted text here. Click to load it

In that case a slicker approach is to define a stream wrapper that
reads from the database. See /.

Site Timeline