Rewrite to incorporate pull request

Rewritten the code to incorporate pull request https://github.com/gutierrezalex/photo-resize/commit/3346097eba3a624bc1f468af9a8d850f4c4ce0cb