Create a gist now

Instantly share code, notes, and snippets.

@idewz /photostat.R
Last active Apr 16, 2016

What would you like to do?
PhotoStat
import os
import sys
import exifread
import csv
from time import strptime, mktime
from datetime import datetime
types = ('.NEF', '.DNG', '.ARW', '.nef', '.dng', '.arw')
output = open('photostat.csv', 'w', newline='')
error = 0
writer = csv.writer(output)
writer.writerow(
[
'File',
'Orientation',
'Camera',
'Year',
'DayOfWeek',
'DayOfMonth',
'Month',
'Time',
'FocalLength',
'ExposureProgram',
'Exposure',
'FNumber',
'WhiteBalance',
'ISO',
'MeteringMode'
]
)
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(types):
path = os.path.join(root, file)
f = open(path, 'rb')
try:
data = exifread.process_file(f, details=False)
created = strptime(str(data['EXIF DateTimeOriginal']), '%Y:%m:%d %H:%M:%S')
created = datetime.fromtimestamp(mktime(created))
writer.writerow([
file,
data['Image Orientation'],
data['Image Model'],
created.strftime('%Y'),
created.strftime('%a'),
created.strftime('%d'),
created.strftime('%B'),
created.strftime('%H:%M:%S'),
data['EXIF FocalLength'],
data['EXIF ExposureProgram'],
data['EXIF ExposureTime'],
data['EXIF FNumber'],
data['EXIF WhiteBalance'],
data['EXIF ISOSpeedRatings'],
data['EXIF MeteringMode'],
])
except:
print(path)
#print(sys.exc_info()[0])
error += 1
finally:
f.close()
output.close()
print("finished with " + str(error) + " error(s)")
library(plyr)
library(ggplot2)
data <- read.csv('photostat.csv')
u <- unique(data[c("Year", "Month", "DayOfMonth")])
u$Year <- factor(u$Year)
u$Month <- factor(u$Month, levels=month.name)
sorted <- u[ order(u[,1], u[,2], u[,3]), ]
pics <- ddply(data, .(data$Year, data$Month), nrow)
names(pics) <- c('Year', 'Month', 'Photos')
counts <- ddply(sorted, .(sorted$Year, sorted$Month), nrow)
counts$Photos <- pics$Photos
names(counts) <- c('Year', 'Month', 'Days', 'Photos')
counts
table(data$Year)
graph <-
qplot(Month, Days, data=counts, color=Year, size=Photos) +
scale_size(range = c(1,20)) +
geom_point() +
geom_text(
aes(label=ifelse(Photos>500, as.character(Photos), '')),
hjust=0.5,
vjust=0.5,
size=2,
color='black'
) +
theme(axis.text.x = element_text(angle=45, hjust=1))
ggsave(file='photostat.png')
@idewz

This comment has been minimized.

Show comment Hide comment
@idewz

idewz Jul 13, 2015

pip install exifread
python photostat.py
curl -O http://cran.r-project.org/src/contrib/plyr_1.8.3.tar.gz
curl -O http://cran.r-project.org/src/contrib/ggplot2_1.0.1.tar.gz
R CMD INSTALL plyr_1.8.3.tar.gz
R CMD INSTALL ggplot2_1.0.1.tar.gz
Rscript photostat.R

photostat

Owner

idewz commented Jul 13, 2015

pip install exifread
python photostat.py
curl -O http://cran.r-project.org/src/contrib/plyr_1.8.3.tar.gz
curl -O http://cran.r-project.org/src/contrib/ggplot2_1.0.1.tar.gz
R CMD INSTALL plyr_1.8.3.tar.gz
R CMD INSTALL ggplot2_1.0.1.tar.gz
Rscript photostat.R

photostat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment