Cropping and then resizing images

I tried to crop and then resize images with an if else statement to basically bring them all to 4:3 aspect ratio and width 400, but a concatenation of crop and resize does not work. I don’t get an image. If I only crop or only resize it works …

<?= $image->crop($image->height()*4/3, $image->height())->resize(400) ?>

Any help highly appreciated …
Best
Hagen

So if yourwidth should be 400 and you want an aspect ratio of 4:3, then the height should be 300. So I would assume that

<?= $image->crop(400, 300) ?>

should do the job?

In any case you can only use these methods with a file object, not with the resulting file version object.

Yes this actually works. Although it surprises me, because my understanding of cropping is, that if my image is 1680x1050 and I crop with 400x300 then I’ll get a 400x300 part of the original image. And according to the docs I could specify from where it should be cropped. Apparently kirby cropping works a bit differently, but it does, what I want.

Thanks
Hagen