Cropping

95 views
Skip to first unread message

Idaho

unread,
Aug 25, 2011, 1:22:22 PM8/25/11
to Smart Lencioni Image Resizer
First I'd like to say what a great scrip this is, it's saved me so
much time.

I noticed I can change: public static $defaultCropper =
SLIR::CROP_CLASS_TOP_CENTERED
and the image is cropped from the top. It would be quite cool to be
able to also crop from the bottom. I haven't figured out how to do it
yet.

It would also be good if we could change it from CROP_CLASS_CENTERED
to CROP_CLASS_TOP_CENTERED or CROP_CLASS_BOTTOM_CENTERED on an image
by image basis.

Any thoughts guys?

NW

unread,
Jul 3, 2013, 9:36:17 AM7/3/13
to smart-lencioni...@googlegroups.com
The ability to specify a crop type on an image by image basis is built into the code - there just doesn't seem to be any documentation for it.

you can do it like this for example

<img src="/slir/w150-h100-c15x10xsmart/path/to/image.jpg"/>

I have added xsmart to the crop parameter

you can use:

xcentered
xtopcentered
xsmart

To crop from the bottom create a file in 
core\libs\gd\croppers\

which is a copy of topcentered.class.php

and edit to this:

  public function getCropY(SLIRImage $image)
  {
     return $image->getHeight() - $image->getCropHeight();
  }

Also need to change the class name

You then need to add in a parameter which is the same name as the filename you created into 

core\slir.class.php


apologies to the author if any of this is incorrect, but it has worked for me
Reply all
Reply to author
Forward
0 new messages