Small question regarding Imagemagick ($im = new Imagick( "strawberry.png" )?
I have a piece of codes that resizes a .png fi开发者_运维问答le 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
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");
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);
精彩评论