implement cropping and saving for jpg/png/gif formats