Hello
When I open a picture taken by my digital camera in "portrait mode" (but not "landscape mode"), Paint Shop Pro X rotates the Picture by 90°automaticly in the first moment. I would like to write a python script that turns and saves all my pictures in "portrait mode". Is that possible? Windows shows a EXIF variable "Exposure program" that is equal to portrait mode or landscape mode. But what is the correct if-statement in Python? I tryed
def Do(Environment):
if 'Exposure program' == "landscape mode":
...
but that doesn't work. Every hint would be appreciated.
Remo
Script programing (Python)
Moderator: Kathy_9
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Script programing (Python)
Well, you could just compare the width to the height. Since portrait will be taller than wide.
If you want to grab the EXIF information you need to call ReturnImageInfo and grab a specific item from the list.
I used .lower() in this code in case there is ever a photo with "Landscape Mode" or "LANDSCAPE MODE" in it. It forces the casing of the letters to all be lower case when comparing to "landscape mode" it may be unnecessary but it's just a precaution.
Code: Select all
if App.TargetDocument.Width > App.TargetDocument.Height:
#In Landscape
#Command to rotate 90 degrees here
#Command to Save here
Code: Select all
ImageInfo = App.Do( Environment, "ReturnImageInfo", {})
if ImageInfo['ExifExposureProgram'].lower() == "landscape mode":
#In Landscape
#Command to rotate 90 degrees here
https://levifiction.wordpress.com/
Re: Script programing (Python)
Hello LeviFiction
Thanks for your quick answer. The first method doesn't work, because all Pictures (landscape and portrait mode) have the same width and height. But with your second hint, I managed to do what I want
. Thank you again.
Remo, Switzerland
Thanks for your quick answer. The first method doesn't work, because all Pictures (landscape and portrait mode) have the same width and height. But with your second hint, I managed to do what I want
Remo, Switzerland
