Author Topic: Exif-script for linux/mac  (Read 4735 times)

johan_lindgren

  • 120
  • **
  • Posts: 88
Exif-script for linux/mac
« on: August 07, 2015, 01:36:24 AM »
Hello

Well I have no idea really if there is any interest for this, I do things my way and it works for me - but I have added a pretty decent amount of hours all together in writing this script so I mind as well share it with you guys, since I love open source too  :D

I think you need to be a little bit of a geek to do add exif to scanned files, and a even bigger geek to try this out  ::)  ;D



To the point....

Lots of stuff in this script has been re-written a bunch of times, and not all that perfect and a lot of it can be written far better I am sure.
My view of it is that I want to run it in a terminal, easy edited, pretty simple in all.

I found the best way (for me) to not need to re-do all exif-data on each file if I need to, so simply create a small script-file to each image that contains everything; these files looks like this:

Code: [Select]
exiv2 -M"del Exif.Photo.DateTimeOriginal"             ./160_infrared_05.???
exiv2 -M"set Exif.Photo.DateTimeOriginal 2015:03:24 16:27" ./160_infrared_05.???
exiv2 -M"del Exif.Photo.ExposureProgram"       ./160_infrared_05.???
exiv2 -M"set Exif.Photo.ExposureProgram 1" ./160_infrared_05.???
exiv2 -M"del Exif.Photo.FNumber" modify      ./160_infrared_05.???
exiv2 -M"add Exif.Photo.FNumber Rational 8/1" modify  ./160_infrared_05.???
exiv2 -M"del Exif.Photo.ExposureTime Rational" modify      ./160_infrared_05.???
exiv2 -M"add Exif.Photo.ExposureTime Rational 1/250" modify ./160_infrared_05.???
exiv2 -M"del Exif.Photo.FocalLength Rational" modify        ./160_infrared_05.???
exiv2 -M"set Exif.Photo.FocalLength Rational 80/1" modify ./160_infrared_05.???
exiv2 -M"del Exif.Photo.ISOSpeedRatings"      ./160_infrared_05.???
exiv2 -M"set Exif.Photo.ISOSpeedRatings 400" ./160_infrared_05.???
exiv2 -M"add Exif.Photo.UserComment Rollei Infrared" modify ./160_infrared_05.???
exiv2 -M"add Exif.Photo.UserComment Home developed using Rodinal/r09" modify ./160_infrared_05.???
exiv2 -M"add Exif.Photo.UserComment Roll-id 160" modify ./160_infrared_05.???
exiv2 -M"del Exif.Image.Model" modify ./160_infrared_05.???
exiv2 -M"del Exif.Image.Make" modify  ./160_infrared_05.???
exiv2 -M"add Exif.Image.Model Mat" modify             ./160_infrared_05.???
exiv2 -M"add Exif.Image.Make Yashica" modify               ./160_infrared_05.???
exiv2 -M"del Exif.Image.Software" modify                                  ./160_infrared_05.???
exiv2 -M"set Exif.Image.Software Gimp 2.8" modify                 ./160_infrared_05.???
exiv2 -M"add Exif.Photo.UserComment Scanned with: Epson Perfection V700" modify ./160_infrared_05.???
exiv2 -M"del Exif.Image.Artist" ./160_infrared_05.???
exiv2 -M"set Exif.Image.Artist whateveryourmailis@gmail.com"           ./160_infrared_05.???
exiv2 -M"set Exif.Image.Copyright whateveryourmailis@gmail.com" modify ./160_infrared_05.???

And they can be executed like for example sh script.160_infrared_05.out

It works like this:

Execute the script wherever you may have downloaded it to like,
Code: [Select]
sh /home/johan/scripts/add_exif.sh
if you have some nessesary tools available, like 'dialog' and 'exiv2' (standard in Ubuntu I think) in your system, then you will see this:

Here you can edit the parameter to find files available, simple enough it creates a list, and sends that information to a temporary file in your home directory.


Choose thatever information you whish to add to your file:


The "Add a film" section looks like this (I added a fairly big bunch)


To remove any unwanted data from your pictures you can type like this for example:
(I like to remove any xmp-data from editing software anyway)
Code: [Select]
exiv2 rm filename.jpg
To run all exif-script files outside of the main script, do it like this to run 'em all.
Code: [Select]
for X in $(ls script.*); do sh $X; done
Check the imprinted exif-data like this:
Code: [Select]
exiv2 -Pkyct filename.jpg

Download the script as it looks right now:
https://dl.dropboxusercontent.com/u/197380473/other/add_exif.sh

You can (should) run it as your usual user.
I have tried it on a mac too, but it was a few "versions" ago, but I think it should run just fine, given that exiv2 and dialog are installed.
I would suggest that you look it through before you runt it, and please try it out first by creating a temporary folder and add at least one image there to experiment with.

If you have any input, please share or ask!

Pete_R

  • Self-Coat
  • *****
  • Posts: 2,149
    • Contax 139 Resource
Re: Exif-script for linux/mac
« Reply #1 on: August 07, 2015, 10:37:45 AM »


"I've been loading films into spirals for so many years I can almost do it with my eyes shut."

Kayos

  • Peel Apart
  • ***
  • Posts: 383
    • My Blog
Re: Exif-script for linux/mac
« Reply #2 on: August 07, 2015, 02:31:54 PM »
Stuff like this makes me want to run linux again

I would love a simple way to add Exif to my scans, AnalogExif likes to ruin stuff in my experience

02Pilot

  • Self-Coat
  • *****
  • Posts: 1,866
  • Malcontent
    • Filmosaur
Re: Exif-script for linux/mac
« Reply #3 on: August 07, 2015, 02:51:27 PM »
Interesting. I've been handling all my photo stuff on my W7 box (newer/faster), but I've got my old one running Mint hooked up to the TV that I could experiment with. Thanks for putting in the effort and sharing it.
Any man who can see what he wants to get on film will usually find some way to get it;
and a man who thinks his equipment is going to see for him is not going to get much of anything.


-Hunter S. Thompson
-
http://filmosaur.wordpress.com/

jharr

  • Self-Coat
  • *****
  • Posts: 1,923
  • Humble Hobbyist
    • Through A Glass, Darkly
Re: Exif-script for linux/mac
« Reply #4 on: August 07, 2015, 03:28:57 PM »
I too love open source and LINUX, but I second Peter's flower foul (because I like flowers too) :)

Johan, in case you aren't familiar with the phenomenon here, if a post is or becomes extremely technical without including anything for the right-brained among us, someone will often post a photo of a flower. This is known as a "Flower Foul" and is all in good fun.

Thanks for posting the exif script. That looks super handy. Alas, I don't have a LINUX system running at the moment.


ftn-slide-dupe026 by James Harr, on Flickr
"The camera is an instrument that teaches people how to see without a camera"   -- Dorothea Lange
Flickr
Blogger

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #5 on: August 07, 2015, 04:03:23 PM »
Stuff like this makes me want to run linux again

I would love a simple way to add Exif to my scans, AnalogExif likes to ruin stuff in my experience

I also tried out AnalogExif a few years ago through wine in linux but it sucked pretty hard is what I remembered, not sure what part really, perhaps it just didnt run well in wine I dont know.

This way it is very easy handling the scripts output, not needing some special format which only one program can handle and if that software is gone in a few years I will have made a lot  of work for nothing because it will no longer run on a newer os (or something like that). I run linux mainly, and I also run a virtual macos sometimes...

Interesting. I've been handling all my photo stuff on my W7 box (newer/faster), but I've got my old one running Mint hooked up to the TV that I could experiment with. Thanks for putting in the effort and sharing it.

One thing that may have been a dealbreaked for me with AnalogExif could be if I have to switch between mouse and keyboard constantly in order to do it all, and also I want to run all individual sections in a row, for example, Dates on all > Program on all > Aperture on all > Speed on all, and so on... I dont like the idea to run all sections on picture #1 and then do it all again on the next if you follow me..

I too love open source and LINUX, but I second Peter's flower foul (because I like flowers too) :)

Johan, in case you aren't familiar with the phenomenon here, if a post is or becomes extremely technical without including anything for the right-brained among us, someone will often post a photo of a flower. This is known as a "Flower Foul" and is all in good fun.

Thanks for posting the exif script. That looks super handy. Alas, I don't have a LINUX system running at the moment.


ftn-slide-dupe026 by James Harr, on Flickr

Haha yeah well what can I say  :-*

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #6 on: August 07, 2015, 04:30:33 PM »
Of course I understand that it is alot to take in for anyone who is not into linux or text-based computing  ::) wheres I am speaking mainly to the (smaller) part of this forum that may actually be looking for something like this as I once did.


I don't have a LINUX system running at the moment.
I just tried it on my work-mac, and it runs nicely :-) Simply installed Exiv2 and Dialog through homebrew.
« Last Edit: August 07, 2015, 04:36:49 PM by johan_lindgren »

Kayos

  • Peel Apart
  • ***
  • Posts: 383
    • My Blog
Re: Exif-script for linux/mac
« Reply #7 on: August 07, 2015, 09:23:58 PM »
I decided i really wanted to try this, but i dont have the time nor inclination for a full Linux install so i used a "simple" method

Install Cygwin
Install missing packages
Try and install Exiv2
Install more development packages
Try and compile Exiv2
Install more packages
Compile Exiv2
Test run script
Get loads of errors but it basically works
Download more packages
re-compile Exiv2
Test run script
Works with one annoying error "command 'clear' not found"

Decide to come back to it later

Was far simpler than a Linux install (I'm too dependant on Lightroom to ditch windows) and nowhere near as painful as i expected, however i used to run Slackware and gentoo so im fairly confident resolving dependencies and compiling from source

Once ive fixed the final error i will probably tweak the script to include my scanning defaults and details etc, plus add a few film i use into the list

Thanks for posting this, I do want Exif data on my scans, and if i get to play with Linux then all the better

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #8 on: August 08, 2015, 12:12:10 AM »
Makes me smile to read what you went through :)

Wierd that 'clear' is missing in cygwin... you might still have it, but not found in within your PATH variable perhaps?

Tell me which film you shoot and I will add it!!

I too use lightroom sometimes, but I have it in my virtual mac-box.

Kayos

  • Peel Apart
  • ***
  • Posts: 383
    • My Blog
Re: Exif-script for linux/mac
« Reply #9 on: August 08, 2015, 06:30:48 AM »
I think the problem with clear is how basic the initial install is, it seems to install the bare minimum to get Bash running with some simple tools, I haven't even looked at what tools are installed yet

I tried installing an Exiv2 package but it wasn't playing, the site has info for a Cygwin compile so most of my time was spent getting all the extra dependencies working, after I'd got gcc working that is.

The films I want to add are respooled Kodak movie film, Vision 250D and Vision 500T, it's sold under various names but that's what it starts life as


Francois

  • Self-Coat
  • *****
  • Posts: 15,769
Re: Exif-script for linux/mac
« Reply #10 on: August 08, 2015, 02:31:06 PM »
It would probably be easier to do simply by geting Ubuntu running under VMware
Francois

Film is the vinyl record of photography.

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #11 on: August 08, 2015, 02:46:32 PM »
It would probably be easier to do simply by geting Ubuntu running under VMware

...or Virtualbox.

btw.
I have added the two "Kodak Motion Picture" films now!

Kayos

  • Peel Apart
  • ***
  • Posts: 383
    • My Blog
Re: Exif-script for linux/mac
« Reply #12 on: August 08, 2015, 05:58:55 PM »
I wanted to avoid running a virtual machine as its far more stuff than i need, plus last time i tried i had issues with accessing files outside the VM on my raid, where all my scans live, with Cygwin Ive put a symlink to my raid in my home directory and can access it all from the bash prompt

Kayos

  • Peel Apart
  • ***
  • Posts: 383
    • My Blog
Re: Exif-script for linux/mac
« Reply #13 on: August 08, 2015, 06:24:20 PM »
Clear is part of Ncurses, added 240kb to my install but now the script works as expected

Thanks for adding the movie film :)

Francois

  • Self-Coat
  • *****
  • Posts: 15,769
Re: Exif-script for linux/mac
« Reply #14 on: August 08, 2015, 09:35:52 PM »
I'm going to have to put cygwin back on... I haven't used it in what feels like forever.
Francois

Film is the vinyl record of photography.

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #15 on: August 08, 2015, 10:38:58 PM »
I am all open for suggestions and questions if you have any, please let me know if I can fix/add something  :)

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #16 on: August 08, 2015, 10:56:14 PM »
I can add that I removed some old unused code from the RUN-part of the script to simplify any customization.

Francois

  • Self-Coat
  • *****
  • Posts: 15,769
Re: Exif-script for linux/mac
« Reply #17 on: August 09, 2015, 10:19:05 PM »
When I get a bit of spare time, I might try and port this to a regular batch file for windows...
Francois

Film is the vinyl record of photography.

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #18 on: August 10, 2015, 12:37:29 AM »
When I get a bit of spare time, I might try and port this to a regular batch file for windows...
Be my guest ;)

jojonas~

  • Self-Coat
  • *****
  • Posts: 2,928
  • back at 63° 49′ 32″ N
    • jojonas @ flickr
Re: Exif-script for linux/mac
« Reply #19 on: August 11, 2015, 08:31:46 AM »
When I get a bit of spare time, I might try and port this to a regular batch file for windows...
yay~!  :D

cue flowers:
/jonas

Francois

  • Self-Coat
  • *****
  • Posts: 15,769
Re: Exif-script for linux/mac
« Reply #20 on: August 11, 2015, 01:56:54 PM »
Started trying to figure out how I'm going to get this to work... Not obvious since I have to re-write everything pretty much from scratch...
Right now, I'm concentrating on getting menus working... Since I want to get a half decent interface going I have to put extra care into it.

Boy do I miss object oriented programming...
Francois

Film is the vinyl record of photography.

mcduff

  • Self-Coat
  • *****
  • Posts: 867
  • Loving the 645...
    • ...on Flickr...
Re: Exif-script for linux/mac
« Reply #21 on: August 13, 2015, 04:01:49 PM »
You won't get flower-bombs from me pal! I am going to try this out on my Mac. I like tagging my photos and really do not like my current workflow that much. Plus it looks fun.
---------------
check out Don's stuff at http://www.flickr.com/photos/mcduffco/

johan_lindgren

  • 120
  • **
  • Posts: 88
Re: Exif-script for linux/mac
« Reply #22 on: August 14, 2015, 12:42:47 PM »
You won't get flower-bombs from me pal! I am going to try this out on my Mac. I like tagging my photos and really do not like my current workflow that much. Plus it looks fun.

Yay nice to hear someone in here who doesn't necessarily run windows && not afraid of text mode :)