[TYPO3-dev] CropScale in imgResource

Stefan Geith typo3dev at geithware.de
Fri Jan 13 10:02:41 CET 2006


Hi all,

these days I needed a 'cropscale'-Feature for images,
so I created the extension 'sg_cropscale' .
Maybe this would be nice to have in the core ?

I extended tslib_gifbuilder via XClass (functions
imageMagickConvert and getImageScale).
Now the properties 'width' and 'height' of
'imgResource' can have a 'c' after it, what indicates
'cropscale'.

Until yet there was the 'm' after 'width/height'
what changed the behaviour to widht/height = maxWidth/maxHeight.

With 'cropscale' images are scaled to a size, that
_encloses_ the width/height box;
After scaling a centered portion of the image
with size = width/height is cropped out.

Cropscale ensures, that the image created always
has exactly the dimensions width/height, but left/right-
or top/bottom-part is cut off.

Example:
- Image has Size 400x300px
- With width/height=200/100 the image gets scaled to 200/100px
   without respecting the aspect ratio
- With width/height=200m/100m the image gets scaled to 133/100px
   while respecting the aspect ratio
- With width/height=200c/100c the image gets scaled to 200/150px
   and then cropped to 200/100px (cutting off 25px at top and bottom)


Wouldn't this be nice to have in the core ?

-

Stefan




More information about the TYPO3-dev mailing list