{
 "id": 69786,
 "slug": "auto-rotating-images-by-exif-orientation-with-exiftool-and-imagemagick",
 "url": "https://agents.willem.com/en/snippets/auto-rotating-images-by-exif-orientation-with-exiftool-and-imagemagick/",
 "language": "en",
 "title": "Auto-rotating images by EXIF orientation with exiftool and ImageMagick",
 "subtitle": "Standard Debian tools fix what the camera only flagged.",
 "summary": "On Debian GNU/Linux I read the orientation with exiftool and then apply the matching rotation with ImageMagick's convert command. A small bash script chains the two, so the image bytes match how the camera was held.",
 "topics": [
  "AI",
  "cloud",
  "data",
  "programming",
  "server",
  "work"
 ],
 "date": "2023-05-03",
 "published": "2023-05-03T00:00:00+02:00",
 "created": "2026-08-30T07:13:29.976000+02:00",
 "updated": "2026-08-30T07:16:54.437000+02:00",
 "full_article_url": "https://willem.com/en/2023-05-03_using-ai-to-generate-code/",
 "author": {
  "name": "Willem L. Middelkoop",
  "url": "https://willem.com"
 },
 "note": "A short distillation of a longer willem.com post. Not currently published on willem.com itself.",
 "answers_question": "How do you automatically rotate photos based on EXIF orientation on Linux?",
 "text": "Smartphones always store a photo landscape and only write an extra bit of EXIF information recording how you held the camera. On the phone that is fine, but for the web the actual bits and bytes must reflect the real orientation before you optimise the image for loading speed and viewports.\nStandard Debian GNU/Linux tools do the job: exiftool reads the orientation data from the file, and based on that output ImageMagick's convert applies the right rotation. A bash script ties the two together and adds some robustness in handling exceptions.\nI did not write it by hand. In 2023 I asked OpenAI's GPT4 to generate the script, and within seconds it delivered working, beautifully commented code plus documentation with installation instructions. It replaced a heavier in-process approach in my backend.",
 "markdown_url": "https://agents.willem.com/en/snippets/auto-rotating-images-by-exif-orientation-with-exiftool-and-imagemagick/snippet.md"
}