• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

imagecopyresampled not working?

Hi,

I am trying to implement the sample code found here:

http://us2.php.net/manual/en/function.imagecopyresampled.php


but it is not working properly.  If I navigate directly to the script page (resizer.php) i see the image.

But when I try to include it into a page like this:
<img scr="scripts/resizer.php">


I am not seeing anything.

thoughts??


thanks,

bruno
0
bruno
Asked:
bruno
  • 5
  • 4
1 Solution
 
Diablo84Commented:
bruno,

Have you modified the script at all?

I have just tested both example scripts from the manual with direct access to the file and access via <img... and they both work ok.

The other thing to check is the path in your img tag, is it correct? It's a relative location so it would be:

- php file with img tag
- /scripts/
  |_ resizer.php

It's usually easier to stick with absolute paths with PHP.

Diablo84
0
 
Diablo84Commented:
Just thought of another problem, where you have:

$filename = 'image.jpg';

in resizer.php

make sure that it is an absolute path, eg:

$filename = $_SERVER['DOCUMENT_ROOT'].'/path/to/image.jpg';

Otherwise it will not work if you call the script outside of the /scripts/ directory (as it will be looking for the image relative to where the script is).

Diablo84
0
 
brunoAuthor Commented:
i'm using example 1 from that page, and only thing i've changed the is file name.



all files are in a folder called /4.0/

my file has these two lines

<img src="scripts/text_gif.php?msg=welcome&rot=0&pad=3&size=30&font=../fonts/scribble.ttf&blu=255">
<br />
<img scr="scripts/resizer.php">

first is that text to gif file iw as working on yesterday...that is working just fine.

resizer.php and text_gif.php both live in /4.0/scripts/


at the top of resizer.php i called the image this way:

$filename = '../car.jpg';

the image lives in the /4.0/ folder.


as i stated, when i navigate right to 4.0/scripts/resizer.php i DO see the image...

when i call it from the <img> tag i see nothing...


bruno
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
brunoAuthor Commented:
>>Otherwise it will not work if you call the script outside of the /scripts/ directory (as it will be looking for the image relative to where the script is).


that's what i assumed, which is why i have it:

$filename = '../car.jpg';


and again, it does work when i navigate right to the resizer.php file itself...just not when it is being called through the <img> tag...

just in case calling it from the <img> tag made the script look relative to where it was being called, i tried

$filename = 'car.jpg';

but that didn't work either.
0
 
brunoAuthor Commented:
lol i'm a jackass sorry for wasting your time.
0
 
brunoAuthor Commented:
you get the points just for me wasting your time with a typo...

src vs scr

woops!

*embarrassed *


i am attempting to create a dynamic photo gallery so i will likely be back with more questions though!
0
 
Diablo84Commented:
../ is parent directory (if my memory serves me correctly), you really need it as /path/from/root/theimage.jpg

Otherwise for example, if you had this dir structure:

/
- myfile.php (with the img tag)
- /mydir/
  |_ resizer.php
- theimage.jpg

and the variable as:

$filename = '../theimage.jpg';

When you access the file resizer.php directly it will look for the image in the root folder, however when you call resizer.php via the img tag in myfile.php it is looking for it in the parent diretory of your web root... and thus wont find it.

Diablo84
0
 
Diablo84Commented:
oh ok :)

I am quite happy to refund the points if you like.

Diablo84
0
 
brunoAuthor Commented:
and i am quite happy to give you the points for wasting your time.  :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now