Focus // Define an image focus point


#21

Yes, I had a similar effect when I tested this briefly with IM, but didn’t have time to look into it any further so far.


#22

Thanks a lot for your replies @Malvese and @texnixe. I will have a look at it again. Maybe my setup was not right.


#23

It might be just me missing the “how does this work” part ^^. So you define that focus spot with a simple click and then? Does this plugin save the resized versions of the images back to the file system or are they just created once a user makes the request? Is this plugin the right one if you want to use responsive images (e.g. creating 3 different version for mobile / tablet / desktop ?)

Maybe I need to try it out to understand the way this plugin works. But it would be great to put some more helpful text into the description so people can better decide if this plugin would solve someones problem or not.

At least for me this is not totally clear.

Never the less this looks really interesting for me, but have to see if it solves my problem of cropping images (or if it is even working on my shared hosting)


#24

The plugin does two things:

  1. it provides a custom field that allows you to set a focus point. The focus point is saved to the meta data file.
  2. it provides a new method focusCrop(), which uses the focus point saved in the meta data file to crop an image in such a way that the focus point is in the center of the cropped image.

And yes, of course, you can use the plugin to create different sized responsive images just in the same way as you would use the inbuilt cropping method. You don’t need the plugin if you want to simply resize images without cropping.


#25

After struggling a bit with my local ImageMagick setup I think Kirby Focus is now ready to go with ImageMagick. I pushed my changes to the develop branch. Anyone interested in testing? @Malvese @texnixe? Any feedback is appreciated :smiley:

Please notice that setting a custom tumb driver is not necessary anymore. The plugin overrides the default GD or IM driver.

So for IM testing add the following line to your config.php

c::set('thumbs.driver', 'im');

Thanks in advance!


#26

Sure, I’ll test it as soon as possible :slight_smile:


#27

Fantastic! I had a feeling it could be done that way, but didn’t have time to dig deeper. You know, I had to choose between coding and jumping in the swimming pool :wink:

I’ll test ASAP.


#28

Ok I took some time to test, and it seems to work as expected :grinning: :poultry_leg: Thank you very much!

Imagick is so much better than gd, better quality, crispier images with equivalent or smaller file sizes…


#29

:tada: Thanks a lot for testing!

I think I should polish the documentation a bit and then ship v1.0 :smiley:


#30

Sorry, Flo, I haven’t got round to testing it yet, somehow I messed up ImageMagick …


#31

No problem and nevertheless thanks for your support! I really appreciate your work for the community.


#32

##Version 1.0

Finally … :tada:


#33

##Version 1.0.1

Fixed a small positioning issue after saving the focus point in the panel.

/cc @jenstornell


#34

looks awesome, definitly will try this out soon.


#35

Will give it a go, thanks Flo.


#36

i noticed, when changing the focus point after thumbnail has been created before, my thumbnail is not getting refreshed. is there any chance i need to adjust to get that sorted out?


#37

This is strange?! The file name of the thumb should contain the x and y coordinate (as well as the quality factor) so that changing the focus point forces Kirby to generate a new thumbnail with a different name.

Could you please check if the changed focus point is saved correctly to the files’ meta data (txt file) and if the filenames of the thumbs contain the x and y coordinates?

Thanks.


#38

to change my thumbs folder i have this added to my config

c::set('thumbs.destination', function($thumb) {

  $page     = $thumb->source->page();
  $filename = $thumb->source->name() . '-' . $thumb->settingsIdentifier() . '.' . $thumb->source->extension();
  $root     = $thumb->options['root'] . DS . str_replace('/', DS, $page->uri()) . DS . $filename;
  $url      = $thumb->options['url'] . '/' . $page->uri() . '/' . $filename;

  // create the directory
  dir::make(dirname($root));

  return new Obj(array(
    'url'  => $url,
    'root' => $root
  ));

});

might this conflict with focus?
when i remove this config setting, focus won’t even load any picture, while with it, it works just fine unless i change focus point and the thumbs not getting renewed.

setting c::set(‘thumbs.driver’, ‘focusIM’); does not work for me, too.

the txt file shows the coordinates just right, the thumb filename however does not seem to have any.


#39

I think the problem with this custom thumb setup is that $thumb->settingsIdentifier() does not consider the focus coordinates. I’m not sure if I can extend this method … I may have a look at this in the future.

c::set('thumbs.driver', 'focusIM') won’t work, because since IM is officially supported (as of v0.4) the plugin overrides the default thumbs driver. This setting exists only while testing things out on the develop branch.

If you are using IM just stick to c::set('thumbs.driver', 'im'). This should work with the latest version of the plugin.


#40

Version 1.0.2

There’s a small update. The main new feature is the introduction of two new file methods:

$image->focusX();
$image->focusY();

In addition to this I fixed a php 5.4 issue and enhanced the README.