Crop() does show correct image-url, but the image didn't crop

I implemented a crop() function.

 <?php if ($image = $angebot->image()):
          ?>
            <img alt="<?= $image->alttext() ?>" src="<?= $image->crop(200, 100, 'center')->url() ?>">
          <?php endif ?>

Am I right when I suggest, that these function crops my image to the wanted ratio? The code seems to work because I found a new image url pointing to the media directory. There is a new directory inside with a cryptic number code but no image inside these directory. As you can see in the screenshot, the image is still portrait-modus although the the image-name changed due to the crop-function. Any ideas?


Just a hunch but it looks like its just passing through without getting manipulated. Which image drver are you using in the config? Do you actually have it installed on your system. You can install easily via Homebrew.

If you have set it to use IM but dont actually have it installed, the image with just pass through but gets the filename it would have got had the crop actually worked.

thanks - didn’t know that I had to install an image driver … I set up the config like in yout link – but that did not have any effect so I think I have to install these image driver … is there any docu for this? I coudn’t find something in the cropping image docu …

Would recommend IM over GD. Assuming you have Homebrew installed (instructions here https://brew.sh/)

Its just a matter of running brew install imagemagick and your all set.

thanks again :wink: seems that imagemagic is already installed … hmm

Thats just the Kirby code that uses ImageMagik. Its not imagemagic itself. Its useless without ImageMagick being installed on the server or local machine.

If you run the following on the command line…

convert -version

if IM is installed you will see something like:

Version: ImageMagick 7.1.0-30 Q16-HDRI arm 19924 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(5.0) 
Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib
Compiler: gcc (4.2)

If it isnt it will say something like command not found. In which case you need install it via home brew.

ok thank you – that was the missing part! I installed imagemagick and now it works. It’s a bit irritating that it is not mentioned anywhere in the docs that you need to install an imagedriver on your system first. Think I also have to install it on the live server as well?

99.9% of webservers have GD installed by default and IM is optional but usually available. The issue here is that you are running the site locally which is a different ball game. MacOs Used to have GD preloaded, but i think they dropped it from Big Sur onwards (not certain on that). If you were running a LInux distro you would probably have GD available out the box. Windows not so much on with GD or IM.

Its not really a thing for the docs as its general server / os setup. If your running Plesk or cPanel on your actual server you might need to tick a box in the control panel to make IM available, but i doubt you would actually need to install it. GD is often the default.

I had the same issue. But it was not imagemagick itself but this plugin which caused this problem on my local enviroment.