# Focus // Define an image focus point

**URL:** <https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249>\
**Category:** Plugins\
**Created:** [May 28, 2016, 6:59am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249 "2016-05-28T06:59:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 28, 2016, 6:59am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/1 "2016-05-28T06:59:47Z")

</div>

With this plugin editors can set an individual focus point to any image, which can be considered when the image is cropped.

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/0/0995bfc56a964fa1d57fe5797dfe5e16566e0e90.png)

See github page for more information …

> **[flokosiol/kirby-focus](https://github.com/flokosiol/kirby-focus)**
>
> Better image cropping for Kirby CMS. Contribute to flokosiol/kirby-focus development by creating an account on GitHub.

Any testing and feedback appreciated 🙂

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [May 28, 2016, 7:20am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/2 "2016-05-28T07:20:49Z")

</div>

Love it! Great job on this plugin.

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [May 28, 2016, 9:16am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/3 "2016-05-28T09:16:14Z")

</div>

Wow, this looks really good and incredibly useful!

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [May 28, 2016, 10:47am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/4 "2016-05-28T10:47:19Z")

</div>

That’s a great plug-in!

Just an idea for another helpful feature: It would be great if on can not only define a point but an area to crop the image (including a given aspect ratio). For example on my website there’s a gallery with square thumbs and big images of various rations and sizes. At the moment I got two files for each image (thumb + original). Being able to define the thumb area on the original image would make life much easier. Especially for clients who can’t use Photoshop etc. to do the cropping before uploading.

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 28, 2016, 11:55am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/5 "2016-05-28T11:55:44Z")

</div>

Thanks for your feedback.

I thought about this, too. But I think the „one-click-one-point“ solution is much more stable. I had really bad experience with third party „rectangle-cropping-plugins“ for Drupal. So I decided to keep it simple … and of course it was easier for me to implement 😉

But this could be an option for the future …

---

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [May 28, 2016, 6:56pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/6 "2016-05-28T18:56:10Z")

</div>

Hi,  
what I miss is a demo to see the plugin in action.  
Apart from that great Plugin.

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 30, 2016, 11:43am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/7 "2016-05-30T11:43:24Z")

</div>

Here’s a [short video](http://files.flokosiol.de/kirby-focus/focus.mp4) (mp4) with the plugin in action.

---

<div class="post-metadata">

**Author:** ![1n3JgKl9pQ6cUMrW](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/1n3jgkl9pq6cumrw/32/2368_2.png) [@1n3JgKl9pQ6cUMrW](https://forum.getkirby.com/u/1n3JgKl9pQ6cUMrW)\
**Post date:** [May 30, 2016, 1:02pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/8 "2016-05-30T13:02:58Z")

</div>

This is really great - I like the “simplicity”; just point and click 🙂

For those interested in a more complex solution (which is not meant a “bad” solution) you can check out the _Kirby Advanced Image Cropper_;

**[https://github.com/blankogmbh/kirby-cropper](https://github.com/blankogmbh/kirby-cropper)**

**[Panel - Cropper for Images](https://forum.getkirby.com/t/panel-cropper-for-images/2414/7)**

---

<div class="post-metadata">

**Author:** ![Malvese](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/malvese/32/12375_2.png) [@Malvese](https://forum.getkirby.com/u/Malvese)\
**Post date:** [May 30, 2016, 2:39pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/9 "2016-05-30T14:39:48Z")

</div>

Like @flokosiol I think a single point is much easier to use (just click on the most important element, boom. Done.) and also much more future-proof: if/when you update the design and the image ratio changes you may have to re-crop every image.  
But I also see use cases where a crop would fit better: more “art directed” thumbs or image headers may require precise cropping. In this case a preview is also very important, but I believe not the purpose of this plugin.

@flokosiol This is so timely, I was thinking of trying to hack one myself. I’m a lousy dev so I’m glad you wrote one first 😊

PS: can it work with Image Magick?

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 30, 2016, 3:23pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/10 "2016-05-30T15:23:55Z")

</div>

Thanks for your reply, @Malvese.

Unfortunately it doesn’t work with ImageMagick at the moment 😥

The reason for this is, that I need to use a custom thumbs driver (GD and IM have different ones) and mine is based on GD (because I use it).

But I created an [issue on github](https://github.com/flokosiol/kirby-focus/issues/1) and this will be the next thing to do, I guess.

---

<div class="post-metadata">

**Author:** ![jash](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jash/32/2173_2.png) [@jash](https://forum.getkirby.com/u/jash)\
**Post date:** [May 30, 2016, 8:47pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/11 "2016-05-30T20:47:50Z")

</div>

Really great work, @flokosiol. Is it possible to get the x- and y-position (in percent) of the focus-point, like $image-\>focus-\>x()? Often you need a flexible “cropping” by showing an image as a css background-image (with background-size: cover), where the size of the image depends on the users viewport. If you now set the background-position value to the focus point, you can be sure, that the desired focus of the image is always visible.

---

<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:** [May 30, 2016, 9:14pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/12 "2016-05-30T21:14:01Z")

</div>

The x and y values are stored in the file meta field as JSON string, e.g.

```auto
Focus: {"x":0.42,"y":0.55}

```

So you can get the values like this:

```auto
$focus = json_decode($file->focus()->value());
$x = $focus->x;
$y = $focus->y;

```

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 31, 2016, 5:00am UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/13 "2016-05-31T05:00:06Z")

</div>

Combining the focus with css backgrounds is a great idea, @jash. I didn’t even think about that!

The solution @texnixe mentioned is exactly the way I do it.

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [May 31, 2016, 9:36pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/14 "2016-05-31T21:36:16Z")

</div>

## Version 0.2

There was a bug with thumbs getting squeezed by the `focusCrop()` method. I thought I had already fixed it for the initial version … but obviously I had not … 😕

> **[flokosiol/kirby-focus](https://github.com/flokosiol/kirby-focus)**
>
> kirby-focus - Better image cropping for Kirby 2

Thanks to @thguenther for testing and reporting!

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [June 2, 2016, 12:12pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/15 "2016-06-02T12:12:52Z")

</div>

##Version 0.3

Hopefully the main cropping issues are fixed with this version. Thanks again @thguenther for extensive testing and fighting against the issues. I really appreciate your work! 🙂

> **[flokosiol/kirby-focus](https://github.com/flokosiol/kirby-focus)**
>
> kirby-focus - Better image cropping for Kirby 2

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [July 5, 2016, 12:31pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/16 "2016-07-05T12:31:33Z")

</div>

I added support for **ImageMagick** to the [develop branch](https://github.com/flokosiol/kirby-focus/tree/develop).

Is there anybody out there who would like to test it?

---

<div class="post-metadata">

**Author:** ![Malvese](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/malvese/32/12375_2.png) [@Malvese](https://forum.getkirby.com/u/Malvese)\
**Post date:** [July 5, 2016, 1:16pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/17 "2016-07-05T13:16:07Z")

</div>

Yes! I will try it for the next few days, I use it on a site that goes live soon 🙂  
Expect feedback on thursday/friday.

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [July 5, 2016, 1:40pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/18 "2016-07-05T13:40:10Z")

</div>

**Great! Thanks a lot** @Malvese  
Please make sure to adjust your config file …

```auto
c::set('thumbs.driver', 'focusIM');

```

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [July 12, 2016, 5:59pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/19 "2016-07-12T17:59:23Z")

</div>

Did you have time to check the ImageMagick support @Malvese? Don’t worry if not … just wanted to ask 😜

Maybe I should publish it without further testing!? Works fine for me so far.

---

<div class="post-metadata">

**Author:** ![Malvese](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/malvese/32/12375_2.png) [@Malvese](https://forum.getkirby.com/u/Malvese)\
**Post date:** [July 14, 2016, 4:46pm UTC](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249/20 "2016-07-14T16:46:36Z")

</div>

Yay! Sorry for the delay, I didn’t have time to really test, and I’m now on holydays 😉  
So far it doesn’t seem to work for me: I can set the focus point in the Panel but `focusCrop()` doesn’t seem to do anything. The portraits below should all be round (well, square actually, but I added a `border-radius`)

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/e/e9b5a9e65d039f2a1a03d1680239afcd55c08c38.png)

I set `c::set('thumbs.driver', 'focusIM');` in the config file as instructed, not sure what’s wrong yet.

I’ll dig a little bit when I have some time.

[Next page](https://forum.getkirby.com/t/focus-define-an-image-focus-point/4249.md?page=2)
