I don't think that you can, not programmatically.
I know that we pass in images in our stored procs and then display them in a image container. The down side on CR is that, as far as I can tell, you can't change the dimension of the image container programmatically and you can't interrogate the image to see if the container needs to change (again, not that you can change it from inside CR).
so we ended up with stretched or scrunched images
HTH