ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Oxspring" <roxspr...@imapmail.org>
Subject [PATCH] Image scaling
Date Thu, 21 Aug 2003 17:58:17 GMT
First up, sorry for no unit tests - just doing enough to get by for now :)

Anyway, I was using the image task to create thumbnails and couldn't figure out how to keep
proportions of an image but keep it within a fixed size.  My solution was to change the keepproportions
attribute to be a little cleverer.  The keepproportions attribute is no more and has been
replaced by the proportions attribute has been added with the following features:

proportions="ignore" - treat the dimensions independantly (==keepproportions="false" and is
default)
proportions="width" - keep proportions based on the width (==keepproportions="true")
proportions="height" - keep proportions based on the height
proportions="fit" - keep proportions and fit in the supplied dimensions
proportions="cover" - keep proportions and cover the supplied dimensions

So for example I can use the following to create thumbnails of my images and make sure they
all fit within the 160x160 size whether the image is portrait or landscape.

<image destdir="samples/low" overwrite="yes">
    <fileset dir="samples/full">
        <filename name="**/*.jpg"/>
    </fileset>
    <scale width="160" height="160" proportions="fit"/>
</image>

Hope that's helpful to others,

Rob


Mime
View raw message