Tutorials 24 min read

Strip the Location From a Photo and It Can Turn Sideways — Remove the GPS, Keep the Orientation Tag

MMNMNOTE
exifphotosgpsexiftoolimagesmarkdown

A phone photo is often stored sideways, with a small Orientation tag that tells the viewer to turn it upright. Wipe all of its metadata to remove the location, and that tag goes too — so the photo now displays sideways. To remove only the location, run exiftool -location:all= photo.jpg. The Orientation tag stays.

The reason it looked right before is a browser default. The CSS Images specification gives the image-orientation property an initial value of from-image, which means the rotation written in the file's metadata is applied automatically 1. Chrome made it the default in version 81, which reached the stable channel on 7 April 2020 2 3. A photo with the tag looks upright. The same photo without it shows its stored pixels as they are — on their side.

The fix is not new. In 2016 a Stack Overflow user asked "How to remove EXIF data from image, but keep the orientation?", and StarGeek's top answer gave the ExifTool command that does it 4. The question has 14,086 views, and the answer still works with the current ExifTool.

What follows is one measured receipt — six common ways to clean a photo, run on one test JPEG — plus the commands, a one-line check, and the limits of the test.

The single habit: remove the location group, not all the metadata

Remove the location by name and leave everything else alone. exiftool -location:all= photo.jpg deletes every tag in ExifTool's Location category — the GPS block and, in this test, a second copy stored in XMP — and keeps Orientation. Two of six methods in this receipt deleted the tag and left the photo sideways.

That number comes from a test file built for the purpose — 400 × 300 pixels stored landscape, an Orientation value of 6, a GPS latitude and longitude, and a camera-maker tag. Each method ran on a fresh copy, with ExifTool 13.63 and Pillow 13.0.0, on 13 November 2026 5.

Two methods lost the tag and kept the sideways pixels — exiftool -all= and a plain Pillow re-save. The other four left the photo upright, one of them by rotating the pixels.

The command is short because ExifTool sorts tags into groups. Its documentation lists the "Category" family of groups as "Audio, Author, Camera, Device, Document, ExifTool, Image, Location, Other, Preview, Printing, Time, Unknown, Video" 6. Deleting location:all empties one of those groups and nothing else. ExifTool files Orientation under Image 5.

Different group, so the tag survives.

There is a reason to prefer the group over the more familiar -gps:all= — it comes down to where else a location can live. The receipt below shows it.

Why a photo is stored sideways in the first place

A camera sensor records an image in its own fixed orientation. Hold the phone upright and a camera can keep the pixels as the sensor saw them, then write an Orientation tag that says how to turn them. The picture is two parts — the pixels, and an instruction about the pixels. Display software is meant to apply the instruction.

The CSS Images specification describes the situation plainly: "If a picture is taken with a camera turned on its side, or a document isn’t positioned correctly within a scanner, the resultant image may be "sideways" or even upside-down." 1

The instruction is one number. ExifTool's tag reference lists eight values for tag 0x0112, from "1 = Horizontal (normal)" through "6 = Rotate 90 CW" to "8 = Rotate 270 CW" 7. This post's test file carries 6 — rotate the stored image 90° clockwise to see it upright.

Android's camera library documents the same split. Its ImageCapture.setTargetRotation reference says: "This will affect the EXIF rotation metadata in images saved by takePicture calls" 8. The rotation is a property of the metadata, not of the pixels. Not every camera app works this way, and this post did not survey them. Where one does, the tag is doing real work.

Delete the instruction and the pixels have nothing to say they are sideways — they simply are.

Why the photo looked right until you cleaned it

A browser that follows the CSS Images default applies the Orientation tag without being asked. The specification sets image-orientation to from-image, and Chrome switched to that default in version 81, in April 2020. So a tagged photo displays upright — and the sideways pixels underneath stay invisible until something removes the tag.

The specification's wording for from-image is direct: "If the image has an orientation specified in its metadata, such as EXIF, this value computes to the angle that the metadata specifies is necessary to correctly orient the image." 1 Chrome's feature entry translates it into behaviour: "In practice this means that the exif orientation, when present in an image, will be used to orient the image unless the "image-orientation: none" CSS property is present." 2

One caveat — the document's status. CSS Images Level 3 is a W3C Candidate Recommendation Draft dated 18 December 2023, not a finished Recommendation, and the property section adds: "This property is optional for implementations." 1 The default is a specification's choice and a browser's shipped behaviour — not a law every viewer follows.

MDN's compatibility data lists support for the property in Chrome 81, Firefox 26 and Safari 13.1 9. Those are the versions that recognise image-orientation — not necessarily the versions where from-image became the default.

This post does not date that change for Firefox or Safari.

It used to fail the other way. In 2013 a portrait photo in a GitHub README displayed rotated, though the asker had confirmed the file in the repository was still portrait. The first answer, posted the same day, read: "I think this is caused by github's missing support for the EXIF "Orientation" tag." 10 Then, the tag was present and ignored. Now it is honoured — so the failure appears when the tag is gone.

The receipt: six ways to clean a photo, three outcomes

Six common methods produced three different results on the same test JPEG. Two removed the Orientation tag and left landscape pixels, so the photo shows sideways. Three kept the tag. One rotated the pixels themselves and dropped the tag it no longer needed. Only the two Pillow methods changed the stored image data.

The test file started with Orientation 6, a GPS position, a camera-maker tag of TestCam, and 400 × 300 pixels 5. "Shows as" follows from the from-image default and Chrome's documented behaviour, and it was checked in one browser — Chrome 148, headless, where the tagged files laid out 300 × 400 and the two untagged ones 400 × 300 5. Firefox and Safari were not tested.

MethodOrientation afterGPS afterCamera makerStored pixelsImage dataShows as
original6presentkept400 × 300—portrait
exiftool -all=gonegonegone400 × 300unchangedsideways
exiftool -gps:all=6EXIF copy gone; XMP copy kept (file 2)kept400 × 300unchangedportrait
exiftool -location:all=6gone, EXIF and XMP (file 2)kept400 × 300unchangedportrait
exiftool -all= -tagsfromfile @ -orientation6gonegone400 × 300unchangedportrait
Pillow Image.open(f).save(g)gonegonegone400 × 300re-encodedsideways
Pillow ImageOps.exif_transpose(), then savegone (not needed)gonegone300 × 400re-encodedportrait

The -gps:all= row needs its own test. On a second test file that also carried the position in XMP — a second metadata format that can sit inside the same JPEG — -gps:all= removed the EXIF GPS block and left GPSLatitude 48.8566 and GPSLongitude 2.3522 in XMP. -location:all= removed both and kept Orientation 6 5.

How often real phones or editors store a second, XMP copy of the location was not measured here. The point is narrower — if a photo has been through an editor that writes XMP, the location can be stored twice, and the group command covers both.

The image-data column comes from ExifTool's own hash of the compressed image stream. All four ExifTool outputs matched the original byte for byte; both Pillow outputs differed 5. ExifTool rewrote the metadata around the picture — and never touched the picture itself.

The -all= result is documented behaviour, not a bug. ExifTool's manual describes exiftool -all= dst.jpg as "Delete all meta information from an image." 11 The Orientation tag is meta information.

The command does exactly what it says.

The five-minute version: check, remove the location, check again

Check what the photo carries, remove the location group on a copy, then check again. The whole job is three ExifTool commands, and each prints only a few lines. If the second check still shows Orientation 6 and no GPS lines, the photo has kept its rotation — and lost its location.

  1. Work on a copy. Duplicate the photo, or the folder, before editing anything.
  2. Look first. Run the check below and note the Orientation value and every GPS line.
  3. Remove the location group. Run exiftool -location:all= on the copy.
  4. Look again. Run the same check. Orientation should be unchanged — the GPS lines gone.
  5. Open it. View the cleaned copy in a browser or your notes app before replacing the original.

The commands, in order:

# 1. What does the photo carry? -n prints numbers; -a -G1 shows duplicates and where each lives
exiftool -Orientation -n -GPSLatitude -a -G1 photo.jpg

# 2. Remove every Location-category tag. Orientation is not in that group.
exiftool -location:all= photo.jpg

# 3. Same check again
exiftool -Orientation -n -GPSLatitude -a -G1 photo.jpg

On the receipt's two-copy test file, the first check printed five lines 5:

[IFD0]          Orientation                     : 6
[XMP-tiff]      Orientation                     : 6
[GPS]           GPS Latitude                    : 48.8566666666667
[XMP-exif]      GPS Latitude                    : 48.8566
[Composite]     GPS Latitude                    : 48.8566666666667

After -location:all=, only the two Orientation lines remained.

The -n flag matters. Without it ExifTool prints the label, and its manual shows the pair — "Rotate 90 CW" by default, Orientation: 6 with -n 11. Either is fine for reading; the number is easier to compare.

By default ExifTool also keeps a backup of every file it edits, named with _original appended. Keep it — until step 5 passes, it is the undo.

The thirty-minute version: folders, full strips and rotated pixels

The fuller workflow covers three cases the five-minute version does not: a whole folder of photos, a strip that removes everything except the rotation, and photos that need the rotation baked into the pixels for a viewer that ignores the tag. Each has its own command and its own cost.

A folder at once

ExifTool takes a directory and walks it. -r processes subdirectories and -ext jpg limits the run to JPEGs — in a test on copies, it also matched a .JPG file 5:

exiftool -location:all= -r -ext jpg ~/Notes/attachments-copy
exiftool -Orientation -n -GPSLatitude -a -G1 -r ~/Notes/attachments-copy

The manual's description of the backup flag explains what it skips: -overwrite_original will "Overwrite the original FILE (instead of preserving it by adding _original to the file name)" 11. Add it only after a folder run has been checked, and only on a copy you can afford to lose.

Everything gone except the rotation

The location strip keeps everything outside the Location group, including camera, date and serial tags. When you want all of that gone too, delete everything and copy one tag back from the original. ExifTool's manual describes the pattern: "individual tags may be recovered using the -tagsFromFile option (eg. -all= -tagsfromfile @ -artist)" 11.

Applied to rotation, that becomes:

exiftool -all= -tagsfromfile @ -orientation photo.jpg

StarGeek's 2016 answer gave the same idea in a stricter form: "From the command line, you could use Exiftool with this command: exiftool -all:all= -tagsFromFile @ -exif:Orientation example.jpg" 4. This post's version is a shortened copy of it — and on both test files, the two forms left the same single tag, Orientation 6, with byte-identical image data 5.

The manual adds one warning for this kind of strip: "Note: You should NOT do this to RAW images (except DNG) since proprietary RAW image formats often contain information in the makernotes that is necessary for converting the image." 11 This receipt tested JPEG only.

Rotation baked into the pixels

Some places still show the stored pixels and ignore the tag. For those, rotate the image itself. Pillow's ImageOps.exif_transpose does it in one call, and its documentation states the behaviour: "If an image has an EXIF Orientation tag, other than 1, transpose the image accordingly, and remove the orientation data." 12

from PIL import Image, ImageOps

im = Image.open("photo.jpg")
upright = ImageOps.exif_transpose(im)   # pixels now 300 x 400, no tag needed
upright.save("photo-upright.jpg", quality=95)

This one has a cost — quality. Saving writes a new JPEG, and Pillow's documentation for the quality setting says: "The default is 75." 13 Leave quality out and the photo is compressed again at that setting. The receipt's two Pillow outputs both had new image data 5. Choose a quality deliberately, and keep the original.

The saved file also carries no location — or anything else. Pillow writes only the EXIF it is handed; its JPEG docs describe the exif option as "If present, the image will be stored with the provided raw EXIF data." 13 That same rule is why a plain save() dropped the Orientation tag in the receipt.

When the tag is already gone

If a photo has already lost its tag and shows sideways, put the tag back rather than re-saving. ExifTool's manual includes exiftool -Orientation=6 -n a.jpg 11. Use 6 only when you know the stored pixels need a 90° clockwise turn — the full set of eight values is in the tag reference 7.

Common mistakes when removing location from a photo

Most sideways photos come from one of four habits: wiping everything, trusting -gps:all= to catch every copy, re-saving through an image library, or treating a location strip as a full privacy clean. Each is easy to avoid once you know what the command actually removes and what it leaves behind.

The 2016 question shows a fifth route to the same result. Its asker had used the Windows file Properties tool to remove the data, found the orientation gone, and faced re-rotating a large folder by hand 4.

Same result, different tool.

How this works in MNMNOTE

An image in a local-first notes setup is an ordinary file on your own device, so every command above runs on it directly. MNMNOTE keeps notes as open Markdown stored locally in your browser, and this post makes no claim about what any notes app does to a photo's metadata — check the file itself.

That applies to every tool, this one included. The reliable test is the one-line ExifTool check, run on the file before and after it goes anywhere.

Images in notes already behave as separate files you own, with their own paths — the subject of Markdown is portable until you add an image. How the same image can be sized differently from one app to the next is in the image size you set in one app becomes alt text in the next.

Whether a photo in a note still carries a location at all is its own question. This post starts after the answer is yes.

What this test does not show

This is one synthetic JPEG on one machine, built to carry a known rotation, a known location and a camera tag. It shows how six methods treat those tags on 13 November 2026. It does not show how real phones store location, how HEIC, PNG or RAW files behave, or how any particular app displays the results.

The "Shows as" column follows from the specification's from-image default and Chrome's documented behaviour 1 2, and was rendered in one browser only — Chrome 148, headless 5. Before relying on it, open a cleaned copy in the browser or app you actually use.

The Firefox and Safari dates are open — MDN dates their support for the property, not the switch to the default 9.

The XMP case was constructed. It proves that a location can survive -gps:all=, not how often it does.

None of the methods is wrong in general. Each does what its documentation says — the trouble starts only when the job is remove the location and the command chosen is remove everything.

Frequently asked questions

These are real questions from Stack Overflow and Super User, quoted as their askers wrote them. The short answers come from the receipt and the ExifTool, Pillow and CSS documentation cited above. Every command was run on the test JPEG — none was checked against HEIC, PNG or RAW files, which can behave differently.

How to remove EXIF data from image, but keep the orientation?

Remove only the location with exiftool -location:all= photo.jpg, which keeps Orientation and every non-location tag. To remove everything except the rotation, run exiftool -all= -tagsfromfile @ -orientation photo.jpg. Both kept Orientation 6 and left the image data byte-identical in this test. The second form follows StarGeek's 2016 Stack Overflow answer.

Strip EXIF data from image

Stripping everything also strips the Orientation tag, and browsers that follow the CSS default, Chrome among them, use that tag to display a photo upright. The 2014 asker wanted it gone because it "rotates my image on certain browsers". Now, removing it is what turns a phone photo sideways. Rotate the pixels first with Pillow's exif_transpose, or keep the tag.

How to rotate images automatically, based on exif data

Pillow's ImageOps.exif_transpose() reads the Orientation tag, rotates the pixels to match, and removes the tag. Save the result with an explicit quality= value, because Pillow's JPEG default is 75 and every save re-encodes. ExifTool cannot do this — it edits tags only, and left the image data byte-identical in every test here.

How can I modify the EXIF orientation tag of an image?

Use exiftool -Orientation=6 -n photo.jpg, where -n lets you write the number instead of the label. The eight values run from 1, "Horizontal (normal)", to 8, "Rotate 270 CW"; 6 is "Rotate 90 CW". Change it only to match the stored pixels, or the photo will display rotated the wrong way.

How can I avoid that Github rotates my jpg in my readme.md?

That 2013 question had the opposite cause. The photo carried an Orientation tag and, by the first answer's diagnosis, GitHub ignored it — so the stored pixels showed sideways. Chrome made applying the tag its default in version 81, in 2020. If a README photo is sideways now, check whether the tag was removed before it was committed.

How to convert a JPEG to a JPEG with EXIF orientation 1?

Rotate the pixels to match the current tag, then save with the tag removed or set to 1. Pillow's exif_transpose does both in one call. Setting the tag to 1 without rotating the pixels only works if the pixels are already upright — otherwise the photo displays sideways.

Android's camera library can write the rotation into the EXIF metadata, so the stored pixels can be sideways while the tag says how to turn them. Any reader that drops or ignores the tag shows the raw sensor orientation. Read the tag and rotate the pixels, or keep the tag intact.


A photo is two things in one file: the picture, and a note about which way is up. Remove the location and keep the note.


If your notes and their images live as plain files on your own device, mnmnote.com is a local-first Markdown editor built around that — and a file you own is a file you can check.

References


Footnotes

  1. Atkins Jr., T., Etemad, E. J. and Verou, L. (eds.). CSS Images Module Level 3, §5.1 "Orienting an Image on the Page: the image-orientation property." W3C Candidate Recommendation Draft, 18 December 2023. https://www.w3.org/TR/css-images-3/#the-image-orientation (accessed 2026-11-13). ↩ ↩2 ↩3 ↩4 ↩5

  2. Chrome Platform Status. "Support for CSS image-orientation property," feature 6313474512650240, enabled by default in milestone 81. https://chromestatus.com/feature/6313474512650240 (accessed 2026-11-13). ↩ ↩2 ↩3

  3. Chromium Dash. Milestone schedule, Chrome 81, stable date 2020-04-07. https://chromiumdash.appspot.com/fetch_milestone_schedule?mstone=81 (accessed 2026-11-13). ↩

  4. Stack Overflow. "How to remove EXIF data from image, but keep the orientation?" Question 37432580, asked 2016-05-25, 14,086 views; answer 37444051 by StarGeek, 2016-05-25, score 12. https://stackoverflow.com/questions/37432580 (accessed 2026-11-13, via the Stack Exchange API 2.3). ↩ ↩2 ↩3

  5. Own measurement, 13 November 2026 — ExifTool 13.63 (official tarball, SHA-256 matched exiftool.org/checksums.txt), Pillow 13.0.0, piexif 1.1.3, Python 3.14.4, Linux. Test file 1: a synthetic 400 × 300 JPEG with Orientation 6, EXIF GPS and Make. Test file 2: the same with an added XMP GPS position and XMP Orientation. Six methods on fresh copies of file 1; -gps:all=, -location:all= and both keep-orientation forms also on file 2; a folder run with -r -ext jpg on copies. Tags read with exiftool -n -a -G1 (category with -G2); image data compared with exiftool -api ImageHashType=SHA256 -ImageDataHash. Display checked by loading the outputs in Chrome for Testing 148.0.7778.97 (headless shell): computed image-orientation was from-image; the original and the four Orientation-6 or transposed outputs laid out 300 × 400, the -all= and plain Pillow outputs 400 × 300. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14

  6. Harvey, P. Image::ExifTool API documentation, GetGroup, family 2 "Category" groups. https://exiftool.org/ExifTool.html (accessed 2026-11-13). ↩

  7. Harvey, P. ExifTool Tag Names, EXIF table, Orientation (0x0112). https://exiftool.org/TagNames/EXIF.html (accessed 2026-11-13). ↩ ↩2

  8. Android Developers. CameraX ImageCapture, setTargetRotation. https://developer.android.com/reference/androidx/camera/core/ImageCapture (accessed 2026-11-13). ↩

  9. MDN. browser-compat-data, css/properties/image-orientation.json, commit d4a9f99cd8 (chrome 81, firefox 26, safari 13.1). https://github.com/mdn/browser-compat-data/blob/d4a9f99cd8/css/properties/image-orientation.json (accessed 2026-11-13). ↩ ↩2

  10. Stack Overflow. "How can I avoid that Github rotates my jpg in my readme.md?" Question 19434073, asked 2013-10-17; answer 19434513 by A. Donda, 2013-10-17. https://stackoverflow.com/questions/19434073 (accessed 2026-11-13, via the Stack Exchange API 2.3). ↩

  11. Harvey, P. exiftool application documentation, version 13.63 — "WRITING EXAMPLES," -n, -overwrite_original, -TAG= notes. https://exiftool.org/exiftool_pod.html (accessed 2026-11-13). ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  12. Pillow 13.0.0 documentation. PIL.ImageOps.exif_transpose. https://pillow.readthedocs.io/en/stable/reference/ImageOps.html (accessed 2026-11-13). ↩

  13. Pillow 13.0.0 documentation. "Image file formats," JPEG → Saving, quality and exif. https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html (accessed 2026-11-13). ↩ ↩2 ↩3