LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-06-2020, 01:35 PM   #1
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,378

Rep: Reputation: Disabled
any batch command to rotate many photos at once?


I took a large number of photos on a trip; many are dupes that I will delete, but as it is, I have over 130 at the moment. Most or all of them are sideways. Is there any command that would save me some time by rotating them all in a batch to the desired position?
 
Old 07-06-2020, 01:42 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Imagemagick's convert command. Would be easy to write a bash script.

Check out mogrify too.

Last edited by michaelk; 07-06-2020 at 01:45 PM.
 
2 members found this post helpful.
Old 07-06-2020, 01:50 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,966

Rep: Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332
just curious: Usually I process all the images one by one, so rotating is not an issue, because I check every and each picture taken. By the way, the software I use knows the original orientation, so the pictures are adjusted by default. This problem only occurred when non-official tools were used.
 
Old 07-06-2020, 02:58 PM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by pan64 View Post
the software I use knows the original orientation, so the pictures are adjusted by default. This problem only occurred when non-official tools were used.
Important point, though I wouldn't have used the term "non-official" here.
Your image viewer might not be aware of exif rotation data.
It depends on what you do with these pictures in the end, but it might not be necessary to do anything at all.
 
1 members found this post helpful.
Old 07-06-2020, 06:00 PM   #5
KGIII
Member
 
Registered: Sep 2015
Location: North-Western, Maine - in the mountains.
Distribution: Lubuntu 18.04 LTS
Posts: 158
Blog Entries: 6

Rep: Reputation: 64
If you want a GUI, non-opensource, option to rotate a bunch of images at once, there's XNViewMP (available in 32/64 bit for Linux) and it has a "Batch Convert." In the actions section of the batch convert you can choose to rotate the images (among many other things).

It's free for personal use, but not opensource. I like it, mostly because I'm used to the workflow and know where everything is. It has been around forever and I was *really* grateful when they made it into a Linux app.
 
1 members found this post helpful.
Old 07-12-2020, 04:58 PM   #6
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,804

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by pan64 View Post
just curious: Usually I process all the images one by one, so rotating is not an issue, because I check every and each picture taken. By the way, the software I use knows the original orientation, so the pictures are adjusted by default. This problem only occurred when non-official tools were used.
You could look at the aspect ratio of the images with identify(1) and decide whether they need to be rotated. Not a guarantee that would work in all cases---I tend to do portrait shots of people and landscape shot of, well, landscapes and would not want people or nature arbitrarily rotated.

Fire up a file manager and examine and move (or copy, for the more paranoid of us) all the photos that need to be rotated into a temporary subdirectory, and turn a script loose on those that require rotation in that subdirectory. I might even rename those to something like "img_1234.rotated.jpg" after rotation and before moving them back into the original directory to preserve the original, un-rotated images.
 
1 members found this post helpful.
Old 07-12-2020, 05:28 PM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,244

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
Do you want to reorder the pixels, or do you want to change the EXIF information?
 
Old 07-12-2020, 07:58 PM   #8
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
create 2 directories called "notrotated" and "rotated". copy all the image files that need to be rotated into "notrotated". once you know what option for the convert commant will rotate them for you, you can run a command like this:
Code:
(ls -1 notrotated|while read n;do ls -l "notrotated/$n";convert put_options_here "notrotated/$n" "rotated/$n";ls -l "rotated/$n";done)
then you will have the rotated ones in the "rotated" directory with the same name. do not do this directly on your only copy of files, just in case.

i do bash commands like this a few times every day.
 
1 members found this post helpful.
Old 07-12-2020, 10:03 PM   #9
EdGr
Senior Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,000

Rep: Reputation: 472Reputation: 472Reputation: 472Reputation: 472Reputation: 472
jpegtran can rotate JPEG images with no loss of image quality.

Code:
for n in *.JPG; do jpegtran -rotate 90 $n >$n-rotate.jpg; done
Ed
 
1 members found this post helpful.
Old 07-16-2020, 03:41 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by EdGr View Post
jpegtran can rotate JPEG images with no loss of image quality.
Not always, unfortunately:
Quote:
Originally Posted by jpegtran
-perfect Fail if there is non-transformable edge blocks
I had to find out the hard way.
 
1 members found this post helpful.
Old 07-16-2020, 08:25 AM   #11
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,483

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
I've found that using -auto-orient with ImageMagic convert works nicely to sort out orientation on files. Of course this depends on whether your image source contains relevant orientation information.
 
1 members found this post helpful.
Old 07-16-2020, 09:28 PM   #12
EdGr
Senior Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,000

Rep: Reputation: 472Reputation: 472Reputation: 472Reputation: 472Reputation: 472
Quote:
Originally Posted by ondoho View Post
Not always, unfortunately:
I had to find out the hard way.
There is something to be said about reading the manual.

jpegtran should have worked on the OP's photos.
Ed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: imgp – multi-core batch image file resize and rotate LXer Syndicated Linux News 0 11-05-2018 08:33 AM
Log rotate not rotate newFreeBSD Linux - Server 13 09-12-2013 08:59 PM
[SOLVED] Searching an program to simplify rotate, zoom and crop photos A-Freak Linux - Software 5 07-05-2013 12:18 PM
Rotate display -- Option "Rotate" "CCW" Brad.Scalio@noaa.gov Linux - General 0 01-27-2009 05:32 AM
need software to batch-rotate jpeg's based on exif data mfcarroll Linux - Software 3 03-07-2005 02:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration