[Zope] Photo: somes issues and thoughts
marc lindahl
marc@bowery.com
Fri, 04 Jan 2002 03:16:53 -0500
> From: J M Cerqueira Esteves <jmce@artenumerica.com>
> Organization: Arte Numerica
> Date: Fri, 4 Jan 2002 07:21:39 +0000
> To: zope@zope.org
> Cc: sebrosa@artenumerica.com
> Subject: Re: [Zope] Photo: somes issues and thoughts
>=20
> * J M Cerqueira Esteves <jmce@artenumerica.com> [2002-01-04 06:40 +0000]:
>> while Photo uses (with integer division, therefore with truncation
>> everywhere):
>>=20
>> if hM > h0 * wM / w0:
>> height =3D h0 * wM / w0
>> width =3D wM
>> else:
>> height =3D hM
>> width =3D w0 * hM / w0
>=20
> ... which by the way has idempotency problems. In my example,
> a 272=D7281 pic allowed to have wM=3D480 and hM=3D480, this gives
> 464=D7480 as dimensions respecting the original aspect ratio.
> But if one specifies (wM, hM)=3D(464,480) and starts again with 272=D7281,
> the final result is then (464, 479) instead of the expected (464,480)...
The last line is wrong:
width =3D h0 * hM / w0
But as for float vs fix, I think if you do the same calculation with float
you'll still get the same result after you int. =20