Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update EXIF tags of a picture file in Ruby?

Title says everything.

like image 223
aurels Avatar asked Apr 18 '10 15:04

aurels


People also ask

How do I change the Exif metadata of an image?

exiftool is a command line tool that allows you to change and manipulate the EXIF metadata of images. On macOS you can easily install it with: detox is a utility designed to clean up filenames.

What is Exchangeable image file format (Exif)?

Almost all digital cameras record and store various camera settings, scene information, date/time the photo was taken etc as Exchangeable Image File Format (EXIF) data. This metadata is stored within the image file and won’t get lost or overwritten when copying or transferring your photos to other computers.

How do I rename a file based on the Exif date?

If you have a correct EXIF date, you can easily rename all files based on the EXIF date of the file: $ exiftool '-FileName<DateTimeOriginal' -d %Y%m%d_%H%M%S%%-c.%%e .

How to fix the Exif date that was wrong?

Set the file modification date based on EXIF date. With the previous action, the EXIF date might be correct, but now the modified date is set to the date the tool was invoked. To fix the modified date of the file that was destroyed with the previous action, run: $ exiftool -v "-DateTimeOriginal>FileModifyDate".


2 Answers

I'm using MiniExiftool, a ruby interface to Perl's Exiftool.

  • https://github.com/janfri/mini_exiftool
  • http://www.sno.phy.queensu.ca/~phil/exiftool/

Usage:

exif = MiniExiftool.new(file_path)
exif.date_time_original = Time.now
exif["captionextract"] = "This is my new caption"
exif.save

There is also: https://github.com/janfri/multi_exiftool

like image 121
chris_vannoy Avatar answered Nov 27 '22 23:11

chris_vannoy


Have you tried exifr?

EXIF Reader is a module to read EXIF from JPEG and TIFF images.

like image 44
Dr1Ku Avatar answered Nov 27 '22 21:11

Dr1Ku