# Problem with image cropping

**URL:** <https://forum.getkirby.com/t/problem-with-image-cropping/14913>\
**Category:** Questions\
**Tags:** v3\
**Created:** [July 12, 2019, 6:17pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913 "2019-07-12T18:17:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:17pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/1 "2019-07-12T18:17:09Z")

</div>

I’m following along with the tutorial but I’ve hit a snag. When I try to crop the project images using

`<?= $project->image()->crop(500) ?>`

I get an error message saying:

> This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.

Everything displays fine before I add `->crop(500)`

I’m on OSX and running a local server using MAMP. PHP ver 7.3.1

Any ideas?

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [July 11, 2019, 7:30pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/2 "2019-07-11T19:30:02Z")

</div>

I think you should check first like that

```
<?php if($image = $page->image()): ?>
<img src="<?= $image->crop(500)->url() ?>" alt="">
<?php endif ?>
```

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:03pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/3 "2019-07-12T18:03:34Z")

</div>

Thanks byybora, unfortunately your code didn’t work for me.

I’ve tried uploading my test site to a live server and my code works fine there, cropping the images as intended. So I’m thinking it must a problem with the way MAMP is running? Or the version of PHP on my local server?

Any ideas?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:05pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/4 "2019-07-12T18:05:21Z")

</div>

Do you get an error message or is the file just not cropped? Which thumbs driver have you set in your config?

If you are using a wrong PHP version, you would get an error message, because Kirby checks for the PHP version on installation.

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:06pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/5 "2019-07-12T18:06:19Z")

</div>

I just get this error

> [@](#):
>
> This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.

I haven’t set any thumbs driver in config, how do I do that?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:07pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/6 "2019-07-12T18:07:09Z")

</div>

Ok, an error, then please enable debugging in your `config.php` as a first step.

```auto
'debug' => true

```

within the return array, so that it tells us what the error is.

The full code should look like this if the file is currently empty:

```auto
return [
    'debug' => true
];

```

> **[debug](https://getkirby.com/docs/reference/system/options/debug)**
>
> Enables/disables PHP errors

If there is no config.php file yet, create one in `/site/config/config.php` (the Starterkit comes with a config file, the Plainkit doesn’t).

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:12pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/7 "2019-07-12T18:12:43Z")

</div>

Thanks texnixe! I think I’ve done it. Did I need to put the code in php tags like this?

```
return [
'debug' => true
];
```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:13pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/8 "2019-07-12T18:13:27Z")

</div>

Php code has to start with a php tag, yes

```auto
<?php

return [
    'debug' => true
];

```

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:14pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/9 "2019-07-12T18:14:19Z")

</div>

(the php tag didn’t copy in my post for some reason)

Well I think it’s working, I get a debug window now when I refresh my page!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:14pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/10 "2019-07-12T18:14:37Z")

</div>

Ok, what does it say now?

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:17pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/11 "2019-07-12T18:17:15Z")

</div>

lots of stuff! Not sure what’s what. Trying to attach a screen grab…

 ![Window_and_Kirby_CMS_Debugger](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/3/3f013c3532cb28d77c7da8be160f9aaf7c8bd6d3.jpeg)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:21pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/12 "2019-07-12T18:21:23Z")

</div>

What is your PHP version? I’ve only seen this problem once here: [Installing K3 testing with MAMP Whoops \ Exception \ ErrorException (E\_ERROR)](https://forum.getkirby.com/t/installing-k3-testing-with-mamp-whoops-exception-errorexception-e-error/13760/6)

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:23pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/13 "2019-07-12T18:23:07Z")

</div>

Looks like PHP Version 7.3.1

I did try to install Valet last night via homebrew etc and something didn’t work with the installation so I wonder if it’s conflicting with MAMP somehow? Is that a possibility?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 12, 2019, 6:25pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/14 "2019-07-12T18:25:24Z")

</div>

Which version of Mamp are you using? Changing the PHP version is usually just a click (at least with MAMP Pro).

Also, you can try the solution proposed in the thread I mentioned, after all it seemed to do the trick.

You have to stop the MAMP server before you can use Valet (but both can be installed, I got them both on my system and that works well, I can switch between them if I make sure to stop the one before running the other).

---

<div class="post-metadata">

**Author:** ![spanrucker](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/spanrucker/32/7057_2.png) [@spanrucker](https://forum.getkirby.com/u/spanrucker)\
**Post date:** [July 12, 2019, 6:37pm UTC](https://forum.getkirby.com/t/problem-with-image-cropping/14913/15 "2019-07-12T18:37:24Z")

</div>

Aha! I changed the PHP version in MAMP to 7.2.14 and it’s working now! Thanks so much @texnixe Amazing support here, def purchasing a license when I get this all up and running, I’m enjoying myself 😄
