added a function to reduce the uploaded image size before upload