Forums / General / geometry/crop

geometry/crop

Author Message

Ben Pirt

Thursday 15 January 2004 3:30:05 am

Hello All,
I have been using the new image system, which is working nicely. Although I have just tried to use the geometry/crop filter and it was not applied. I am using GD, not ImageMagick. Does this operation require IM?

Also, I was thinking that a nice extension to the crop command might be to centre the crop on the image. e.g. if the image is 60px high to be cropped to 4opx, the crop would be 10px into the image.

As well as this, the scale command could do with an addition, so that you can scale the smallest dimension to a particualr size.

Basically, these two suggestions/requests come out of me trying to create a square icon. There would be two operations to achieve this;
1) scale down so that the smallest dimension is equal to the required side length
2) crop the image (centred) to the side length

At the moment, I have to have two image operators, and do a test in the template to see if the height or width is the longest dimension and then use the correct image accordingly.

Still, the new image mechanism is a vast improvement over the last one. Particularly th naming and location of the files.

All the best,
Ben Pirt

Ben Pirt

Thursday 15 January 2004 3:47:05 am

OK, I've figured out why it was not cropping, my code was;

Filters[]=geometry/crop=40,40,0,0

as per the documentation here;
http://ez.no/developer/ez_publish_3/releases/ez_publish_3_3/new_image_system

but after looking in the templates, you need semi colon seperators as;

Filters[]=geometry/crop=40;40;0;0

Someone should make a quick fix to the documentation to avoid future confusion, but I hope this helps someone.

Cheers,
Ben

Jan Borsodi

Wednesday 21 January 2004 1:41:07 am

The documentation has been updated.

As for the scale and crop requests, they should be doable but requires some additions to the image handlers.
For instance to get support for this for ImageMagick we would have to have some more keywords to use in the parameter strings, for instance the size of the image to scale from, perhaps also some basic arithmetic operations.

Also it can be problematic to know the size of an image, we must either rely on the builtin functions in PHP to do this (but they don't support many formats) or create custom code to figure out the size.
Formats such as JPEG, GIF and PNG shouldn't be a problem though.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq