How to limit dimension of jpg file?