Closed psntr closed 11 months ago
Could you provide the specific code to reproduce the following?
Sure this is the code:
$output = null;
$retval = null;
if(function_exists('exec')) {
echo "exec is enabled<br>";
}
exec('which convert', $output, $retval);
if ($retval === 0) {
echo $binPath = $output[0]; // Path to 'convert'
} else {
echo "'convert' is not found";
}
The code above works on my web server, which output the binary path.
The convert
command is a tool provided by the imagemagick library after compilation. PHP's imagick extension provides the function of calling imagemagick methods within PHP, and does not include imagemagick's own command line tool.
If you are going to use the convert
command, perhaps compiling the imagemagick
project separately is a better option.
I see, that makes sense, however, compelling the imagemagick
requires me to install via pecl
as recommended by the documentation here.
imagemagick
via homebrew
pecl install imagick
extension=/opt/homebrew/lib/php/pecl/20220829/imagick.so
to my current php version's php.ini
.Error finding executable PHP. Quitting for safety.
Provided output from find-usable-php.php:
Warning: Module "imagick" is already loaded in Unknown on line 0 /Users/cb/Library/Application Support/Herd/bin/php82
The imagemagick library and imagick extension can be treated as two completely different things. If you don't need to use the PHP methods mentioned in PHP Imagick Documentation and just want to use convert
command, you can just call imagemagick directly through exec
, and there is no need to install the imagick extension.
I think the CMS I'm using which is Kirby CMS, use the command convert
, so I wanted to make sure that locally I set the convert's path correctly. As seen in their doc
It seems that Kirby CMS only uses the convert
command, and it should be enough to install imagemagick directly using Homebrew.
Thank you, if that's the case, I have it already installed via Homebrew. But still I'm not able to use properly convert, it seems like this path doesn't work.
'bin' => '/opt/homebrew/bin/convert',
do I have to edit my .zhrsc
file to add a specific alias?
Sorry, never mind, it's now properly converting my image. Thanks for your help!
edit: typo
Sorry, never mind, it's not properly converting my image. Thanks for your help!
Did you mean it's now properly converting...
? Did you manage to solve it? As I'm having the same issue with Kirby with Laravel Herd.
Yeah, sorry for the typo, indeed, it's now working on my side, I was also having issue since I have the repo of my app on two separate computers, one running with the Apple Silicon
new chips and one running with the Intel
which used to be here:
/usr/local/bin/convert
.
Now both of my computers run on Apple Silicon, and so the correct path after installing imagemagick
via Homebrew
is:/opt/homebrew/bin/convert
which is a symlink created by Homebrew for the original path which is /opt/homebrew/Cellar/imagemagick/7.1.1-21/bin/convert
.
So make sure that your that you have either one or the other symlinks by running:
ls -l /opt/homebrew/bin/convert
if on Apple Silicon or : ls -l /usr/local/bin/convert
if on Intel.
You can also try to hash -r
to refresh the shell cache.
Ah thanks for the response! Actually it seems one should just define the path to convert
in the config: https://getkirby.com/docs/reference/system/options/thumbs#thumbs-driver__additional-options-for-the-imagemagick-driver
Oh yes! I should have mentioned it earlier, but I was having issue with Kirby not properly using the library despite having the path defined in the config, but turned out I was using the wrong path and was mixing up between legacy path and the new one from the symlink
… Well I hope it's working for you now
Operating system version
macOS Sonoma 14.1
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.3.1
PHP Version
PHP 8.2
Bug description
Despite having imagick extension provided by Herd, I'm not able to use the 'convert' command through php.
I tried to install imagick.so with Pecl, but it's conflicting with the one that is already installed with Herd.
does anyone face the same issues?
Steps to reproduce
No response
Relevant log output
No response