NOTE: This patch adds the same filters to version 2 as the one I submitted at: http://drupal.org/node/246328

This patch solves two related issues I ran into.

Issue 1: Most of my themes use an underlying grid structure with both fixed columns (horizontal) and a baseline (vertical) value. I wanted a way to resize images to snap to both axis while keeping their relative dimensions. I introduced a ‘snap-x’ value that lets you resize your image to the nearest point on your grid.
For example, if you have a horizontal grid every 50px and a baseline grid of 18px you can build a filter in two steps:
1: scale the image down to a width of 150px (3 cols wide) with no height value
2: crop the image to a height value of ‘snap-18’.
This will create an image that fits precisely on my underlying grid.

Issue 2: After resizing an image to fit perfectly on my grid I sometimes need to add a border to the image with CSS (e.g. border: 5px;). The border would then render outside my grid boundaries. So I created another filter (‘remove-x’)that I use after the two steps described above.
3. Scale the image again with a width and height value set to ‘remove-10’
This just shaves off the exact amount so that my image and border together fit nicely in my grid again.

I hope this is useful to others.

Comments

drewish’s picture

Status: Needs review » Closed (duplicate)