Added resizing with keeping aspect ratio when dimension is 0.

I have added possibility to resize with keeping aspect ratio as discussed in #613 to be able to write alignTopCrop transformation efficiently. There are some issues like #226 that are solved with this pull request.