An extension would be needed to analyse the exif data of the image, and carry out any necessary rotation/s. This is dependent on there being suitable exif data in the first place.
It may not be acceptable, but consider introducing an image editor option (rotate/crop/colourize/etc) for the user, prior to continuing with chunking ?
Along with Taifun's Image extension, perhaps @gordonlu310 's ImageUtils