2017-02-19Complete
Python Image Rotation Correction Script (EXFS Data Editing)
This script is written in python to perform EXFS corrections of digital photos. This script traverses the specified directory, stores all images, then performs the required transform to make the images display correctly.
#! /usr/bin/python
import time
import os
from random import randint
import pexif
from PIL import Image, ExifTags
photo_list = [] #List of all photo paths traversed by OS.WALK
for root, dirs, files in os.walk("/yourpath/"):
for file in files:
if file.endswith(".png") or file.endswith(".jpeg") or file.endswith(".jpg") $
# print(os.path.join(root, file)) #Debug for path checking
photo_list.append(os.path.join(root, file)) #Add the current path+ph$
for photo in photo_list:
#print("Try this: " + photo)
img = pexif.JpegFile.fromFile(photo)
#print(photo + "<- Path Orient -> " + str(img.exif.primary.Orientation[0]))
try:
image=Image.open(photo)
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation]=='Orientation':
break
exif=dict(image._getexif().items())
if exif[orientation] == 3:
image=image.rotate(180, expand=True)
elif exif[orientation] == 6:
image=image.rotate(270, expand=True)
elif exif[orientation] == 8:
image=image.rotate(90, expand=True)
image.save(photo)
image.close()
except (AttributeError, KeyError, IndexError):
# cases: image don't have getexif
print("broke") // more in Code
◆ Complete
2017-02-18·code / python / programming
Image Magic: Python Powered Digital Photo Frame On Raspberry Pi
I was looking for a quick way to scan every photo on my media server, and display them one at a time in a photo slideshow. I wanted a python program to…
◆ Complete
2017-01-21·news
Python Cheat Sheets: Uncommon Methods
This is a quick list of uncommon methods in Python. #Set Method - Eliminates duplicates set(my_list)
◆ Complete
2017-01-19·code / coding / programming
Python Cheat Sheet - Working With Lists
Working with Lists: A quick description of different operations that can be performed on a python list #Declare a list with 2 initial values computers =…