I'm working with documents, so maintaining the the original image dimensions and subsequent dpi is important.

The aspect ratio is always maintained so the automatic fill modes and alike don't seem to have any effect.

Say I have a 300 dpi document and the user want to clear an inch border around the image. So I need an inch cropped from the image but the result needs to be the original image dimensions (2550x3300).

I have been able to achieve this effect with...

...&crop=300,300,-300,-300&margin=300,300,300,300

This works, but seems more than a little clunky. I've tried a lot of other combinations but they all seem to enlarge or reduce the image size which is undesirable in my case.

So does someone know a simpler syntax to achieve the desired result, or do I need to re-size the image then calculate and fill with a margin as I'm doing now.

Thanks

It turns out that my example requests the image in it's full size which turns out to be a special case. When I introduce a width or height into the command line things don't work very well since crop size is in respect to the original image dimensions and margin size is in respect to the result image.

Thinking about it more I abandoned the crop approach. What I really needed was a way to introduce a clipping region into the result bitmap. So I built an extension to do just that. It works well as it doesn't interfere with any of Resizer's layout calculations and the size of the returned image is whatever the height or width were specified as. Which is just what I needed. The Faces plugin has an example of introducing a clipping region.

Karlton

有帮助吗?

解决方案

Cropping and re-adding 300px on each edge is best accomplished exactly the way you're doing it:

&crop=300,300,-300,-300&margin=300

What kind of improved syntax would you expect? This isn't a common operation.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top