Open AntumDeluge opened 1 year ago
Can you clarify, is this a one-off error, or is it all images?
I prefer to be able to use versions for PHP 7
It won't be anything to do with PHP itself.....it will probably be one of:
Can you try in order:
convert test.png -resize 50% output.png
and see if that works at all for it.
<?php
$image = new Imagick(__DIR__ . "/test.png");
$image->cropImage(48, 64, 20, 64);
$image->writeImage(__DIR__ . "/output.png")
And seeing if that works.
Can you clarify, is this a one-off error, or is it all images?
All images.
converting that file using the command line tools
>convert 000-nonude.png -resize 50% test.png
Scaled the image down to half size.
Opening it with a really simple PHP script...
This works from both a PHP script & the interactive shell:
php > echo file_exists("000-nonude.png");
1
php > $img = new Imagick("000-nonude.png");
php > $img->cropImage(48, 64, 0, 0);
php > $img->writeImage("test.png");
$img = new Imagick("000-nonude.png");
$img->cropImage(48, 64, 48, 0);
$img->writeImage("test.png");
Checking the machine isn't really low on diskspace.
>dir C:\
Volume in drive C is Windows
Volume Serial Number is EF62-FCC0
Directory of C:\
...
0 File(s) 0 bytes
17 Dir(s) 483,371,753,472 bytes free
From all this I gather my PHP configuration is fine. Perhaps the issue is my apache configurations.
Edit: I should add that opening images with the gd/gd2 extension works:
imagepng("path/to/image.png");
Using an absolute path to the image fixes the error. So that is a hint at what is wrong. Likely it is an issue with Apache. But it seems odd that relative paths work with other PHP functions.
I believe the problem is with the path that is being sent to ImageMagick. If I start my Apache server daemon from the virtual host directory, it can find the images. It appears that the current working directory is being passed to ImageMagick instead of the directory of my virtual host.
But I'm still not sure if Apache, ImageMagick, or Imagick is the source of the problem. As I said in my original post, it works fine on my Ubuntu/Linux machine. I don't know what the difference is on my Windows server.
I'm having trouble opening images with Imagick on my Apache server on Windows. The error trace is as follows:
The line of code in question is here. The image file does exist & is accessible. The
data
folder normally a symbolic link to another directory. But to make sure it wasn't an issue with Apache following symbolic links, I copied the folder directly into the virtual host root. ImageMagick & Imagick are both installed from the pre-built packages provided by PECL.It has not problem on my server running on Ubuntu with ImageMagick 6.9.11 & Imagick 3.6.0. So I tried downgrading to older packages with similar results. I don't remember the error messages from the older versions, but I can look into it again if need be.
I prefer to be able to use versions for PHP 7 as that is the version our remote server I am developing for uses.
Please let me know if there is any other information needed.
Update: I just tried using PHP 8.1 with php_imagick-3.7.0-8.1-ts-vs16-x64 package with the same result.