-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
lists.filbranden(a)idilia.com wrote:
Basically I want to understand how should I use
getImageSize() and
doTransform() on a subclass of ImageHandler in a way to defer
calculation of the image size only after the transformation is done.
You can't -- doTransform() is told what size it should render at, which
means the system needs to already know an appropriate native size of the
image.
The native size is used to:
* List as image metadata
* Establish the aspect ratio for scaling
* Establish a default rendering size
* Establish a maximum rendering size (for raster images we don't render
when scaling up, we just show the original file bigger on screen)
Ideally, you can in fact extract a size from the file. If you can't get
it from the file yourself, you should be able to get it from your
external program in some way. (Worst case, render to a temporary PNG at
"native" size and check *its* size. Probably crappy, but hey.)
Then, when you rasterize to PNG from doTransform() you're passing your
external program an exact target size, which it should in fact hit exactly.
On the code of ImageHandler, there is a comment that
suggests that I
could return "false" on getImageSize() if I still don't know the size
of the image, but I did not understand how to do that and set the
appropriate size later.
You should only return false if it's not possible to get a size from the
file -- that is, if it's not an image file of a type you recognize.
- -- brion
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org
iEYEARECAAYFAkjBbXoACgkQwRnhpk1wk44rKQCeMj5dboYB8Zz9uLIX2aQeLFfI
SwgAni01D9qnfkDp+5cQ4xzXN+1R7zRN
=IbAm
-----END PGP SIGNATURE-----