A photo that looks perfectly upright in your gallery appears rotated 90 degrees when you put it on a web page. The file is not corrupt and nothing resized it. It has an orientation tag, and something along the way ignored it.
The EXIF orientation tag
Phone cameras do not rotate the sensor data when you turn the phone. They record the pixels in whatever order the sensor produced them and write an EXIF tag saying which way up the result should be displayed. There are eight possible values covering rotation and mirroring.
Well-behaved software reads the tag and displays accordingly. Your gallery app does. Some image libraries, older CMS uploaders and some canvas code do not, and they show the raw pixel order.
This produces the familiar situation where an image is upright everywhere except the one place it needs to be.
Stripping EXIF without rotating first is the trap. It removes the orientation tag and leaves the raw pixels, so an image that looked fine in a viewer that honoured the tag is now permanently sideways for everyone. If you are removing metadata for privacy, rotate first.
What rotation costs
Rotating by 90, 180 or 270 degrees is lossless. Pixels are moved to new coordinates and none are invented or discarded. For JPEG specifically this can be done without re-encoding at all, so there is no generation loss. Rotate a photo a hundred times in right angles and the pixel data is identical.
Rotating by an arbitrary angle, say 3 degrees to straighten a horizon, is a completely different operation. There is no one-to-one mapping between source and destination pixels, so every output pixel is interpolated from several input pixels. The image is softened everywhere, and the corners have to be either cropped or filled. Do it once, from the original, and not repeatedly.
Flipping is always lossless in both directions. It is worth remembering that a flip is not a rotation: a mirrored image is a different image, which matters for anything containing text, a clock face, a road sign or a person's parting.
Sharpening does not add detail
This is the one that costs something, and it is worth being precise about what it does.
Sharpening finds edges, places where adjacent pixels differ in brightness, and exaggerates the difference by making the light side lighter and the dark side darker. The eye reads increased local contrast as increased detail.
No information is added. A blurred photograph has lost detail that is not in the file, and no amount of sharpening recovers it. What sharpening does is make the detail that survived more visible, at the cost of also amplifying noise and compression artefacts, which live at exactly the same scale.
Push it too far and you get the telltale halo, a bright outline tracing every edge, which is unmistakable and cannot be removed afterwards.
So the useful cases are narrow and real:
- After resizing down. Downscaling averages pixels together and softens edges. A light sharpen restores the apparent crispness the resize removed. This is the single most legitimate use.
- Counteracting a soft lens or a slight focus miss. Modest improvement.
- Scanned documents. Increasing edge contrast helps OCR read the characters.
And the case it does not fix: motion blur or significant missed focus. That detail was never recorded.
The order that matters
Sharpening last is not a preference, it is a consequence of how the operations interact.
- Rotate and flip, since these are free.
- Crop.
- Adjust brightness and contrast if the exposure needs it.
- Resize to the final dimensions.
- Sharpen, lightly, to taste.
- Export and compress.
Sharpening before resizing means the resize averages away the effect while keeping the amplified noise, which is the worst of both. Sharpening before compression is correct, because the sharpened edges are what you want the encoder to preserve.