views:

211

answers:

2

Hi all,

I have a piece of codes that resizes a .png file in php. It start with:

$im = new Imagick( "strawberry.png" );

I have a .png file in www.mydomain.com\test\strawberry.png. How can I correct the code above for this address?

Thanks

A: 

Try to figure out the path from where your script runs. From there, you can use a relative path to the test directory.

E.g.

If your script is located in the root directory for the www.mydomain.com site, then you can use this:

$im = new Imagick("./test/strawberry.png");
TheGrandWazoo
Thanks, i put the image in folder that test.php is but when the codes reach to this part, it stop.testfolder test.php--> $im = new Imagick( "strawberry.png" ); strawberry.png
Kaveh
Hummm ... could it be because of lacking (read, write) rights to the file and/or folder?
Sigersted
And i don't see the part regarding Imagemagick in phpinfo().
Kaveh
A: 

I've run into issues sometimes with PHP not getting the correct path. Try getting your current working directory, then appending a relative path:

$im_path = dirname(__FILENAME__).'/test/strawberry.png';
$im = new imagick($im_path);
Should that be `__FILE__` and not `__FILENAME__` ?
alex
Thanks, it doesn't work ,instead of image it show a lot of non-specific caracter , does it need that i put .dll file in window folder ,what is that .dll?
Kaveh