• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The fastest Ruby EXIF reader.

A Ruby EXIF reader written in C. Build Status

Installation

$ gem install exif

Please make sure you have installed libexif:

$ brew install libexif             # Homebrew
$ sudo apt-get install libexif-dev # APT
$ sudo yum install libexif-devel   # CentOS

Usage

data = Exif::Data.new(IO.read('sample.jpg'))   # load from string
data = Exif::Data.new("Exif\x00\x00II...")     # load raw exif data
data = Exif::Data.new(File.open('sample.jpg')) # load from file
data.model         # => "NIKON D600"
data.image_width   # => 4000
data.gps_longitude # => [(121/1), (76869/2500), (0/1)]
data.date_time     # => "2013:12:08 21:14:11"

# get all entries in an IFD
data[:ifd0]             # => {image_width: 4000, image_length: 2670, ...}
data[:ifd1]             # => {x_resolution: (72/1), y_resolution: (72/1), ...}
data[:exif]             # => exposure_time: (1/125), fnumber: (8/1)}
data[:gps]              # => {gps_version_id: [2, 2, 0, 0], gps_latitude_ref: "N", ...}
data[:interoperability] # => {...}
data.to_h               # => {:ifd0 => {...}, :ifd1 => {...}, :exif => {...}}
data.ifds == data.to_h  # => true

ifd0 takes precedence over ifd1, since ifd0 and ifd1 share the same domain of tags, sometimes the same tag can be both used inside them, in this case, calling top-level API like Exif::Data#image_width will return the value of ifd0.

Typecasting

Tag Type Ruby Class
ASCII String
BYTE Integer
DOUBLE Flat
FLOAT Float
LONG Integer
RATIONAL Rational
SHORT Integer
UNDEFINED String

How fast?

It's hundreds of times faster than mini_exiftool or exiftool and several times faster than exifr.

There are similar excellent gems like exifr, mini_exiftool and exiftool built in pure Ruby while this one is a C extension.

If you are using JRuby you might want to give exifr, exiftool or mini_exiftool a look, the latter two are commandline wrappers for ExifTool by Phil Harvey and support many file formats. The exiftool gem can process multiple files at once while mini_exiftool can modify or copy EXIF data.

Benchmark

You can find all benchmark files in /benchmark:

Read a single tag from 100 files.

$ ruby benchmark/load_file.rb
Rehearsal ---------------------------------------------------------
mini_exiftool (2.9.0)   0.240000   0.110000  22.830000 ( 23.275885)
exiftool (1.2.0)        0.480000   0.130000  22.870000 ( 23.311755)
exifr (1.3.2)           0.120000   0.010000   0.130000 (  0.139821)
exif (49b6835)          0.020000   0.000000   0.020000 (  0.019927)
----------------------------------------------- total: 45.850000sec

                            user     system      total        real
mini_exiftool (2.9.0)   0.240000   0.120000  22.830000 ( 23.267355)
exiftool (1.2.0)        0.490000   0.130000  23.190000 ( 23.678799)
exifr (1.3.2)           0.120000   0.010000   0.130000 (  0.134572)
exif (49b6835)          0.020000   0.000000   0.020000 (  0.018419)
-----------------------------------------
1263 times faster than mini_exiftool (2.9.0)
1286 times faster than exiftool (1.2.0)
7 times faster than exifr (1.3.2)

Read many tags from the same file 1000 times.

$ ruby benchmark/read_tag.rb
Rehearsal ---------------------------------------------------------
mini_exiftool (2.9.0)   0.390000   0.000000   0.390000 (  0.404067)
exiftool (1.2.0)        0.030000   0.000000   0.030000 (  0.027073)
exifr (1.3.2)           1.220000   0.020000   1.240000 (  1.268672)
exif (49b6835)          0.010000   0.000000   0.010000 (  0.006862)
------------------------------------------------ total: 1.670000sec

                            user     system      total        real
mini_exiftool (2.9.0)   0.410000   0.010000   0.420000 (  0.412627)
exiftool (1.2.0)        0.030000   0.000000   0.030000 (  0.028518)
exifr (1.3.2)           1.180000   0.010000   1.190000 (  1.203806)
exif (49b6835)          0.010000   0.000000   0.010000 (  0.006925)
-----------------------------------------
60 times faster than mini_exiftool (2.9.0)
4 times faster than exiftool (1.2.0)
174 times faster than exifr (1.3.2)

Contribution

Tag Reference

  • aperture_value
  • artist
  • battery_level
  • bits_per_sample
  • body_serial_number
  • brightness_value
  • camera_owner_name
  • cfa_pattern
  • cfa_repeat_pattern_dim
  • color_space
  • components_configuration
  • composite_image
  • compressed_bits_per_pixel
  • compression
  • contrast
  • copyright
  • custom_rendered
  • date_time
  • date_time_digitized
  • date_time_original
  • device_setting_description
  • digital_zoom_ratio
  • document_name
  • exif_ifd_pointer
  • exif_version
  • exposure_bias_value
  • exposure_index
  • exposure_mode
  • exposure_program
  • exposure_time
  • file_source
  • fill_order
  • flash
  • flash_energy
  • flash_pix_version
  • fnumber
  • focal_length
  • focal_length_in_35mm_film
  • focal_plane_resolution_unit
  • focal_plane_x_resolution
  • focal_plane_y_resolution
  • gain_control
  • gamma
  • gps_altitude
  • gps_altitude_ref
  • gps_area_information
  • gps_date_stamp
  • gps_dest_bearing
  • gps_dest_bearing_ref
  • gps_dest_distance
  • gps_dest_distance_ref
  • gps_dest_latitude
  • gps_dest_latitude_ref
  • gps_dest_longitude
  • gps_dest_longitude_ref
  • gps_differential
  • gps_dop
  • gps_h_positioning_error
  • gps_img_direction
  • gps_img_direction_ref
  • gps_info_ifd_pointer
  • gps_latitude
  • gps_latitude_ref
  • gps_longitude
  • gps_longitude_ref
  • gps_map_datum
  • gps_measure_mode
  • gps_processing_method
  • gps_satellites
  • gps_speed
  • gps_speed_ref
  • gps_status
  • gps_time_stamp
  • gps_track
  • gps_track_ref
  • gps_version_id
  • image_depth
  • image_description
  • image_length
  • image_resources
  • image_unique_id
  • image_width
  • inter_color_profile
  • interoperability_ifd_pointer
  • interoperability_index
  • interoperability_version
  • iptc_naa
  • iso_speed
  • iso_speed_ratings
  • iso_speedlatitudeyyy
  • iso_speedlatitudezzz
  • jpeg_interchange_format
  • jpeg_interchange_format_length
  • jpeg_proc
  • lens_make
  • lens_model
  • lens_serial_number
  • lens_specification
  • light_source
  • make
  • maker_note
  • max_aperture_value
  • metering_mode
  • model
  • new_cfa_pattern
  • new_subfile_type
  • oecf
  • offset_time
  • offset_time_digitized
  • offset_time_original
  • orientation
  • padding
  • photometric_interpretation
  • pixel_x_dimension
  • pixel_y_dimension
  • planar_configuration
  • primary_chromaticities
  • print_image_matching
  • recommended_exposure_index
  • reference_black_white
  • related_image_file_format
  • related_image_length
  • related_image_width
  • related_sound_file
  • resolution_unit
  • rows_per_strip
  • samples_per_pixel
  • saturation
  • scene_capture_type
  • scene_type
  • sensing_method
  • sensitivity_type
  • sharpness
  • shutter_speed_value
  • software
  • source_exposure_times_of_composite_image
  • source_image_number_of_composite_image
  • spatial_frequency_response
  • spectral_sensitivity
  • standard_output_sensitivity
  • strip_byte_counts
  • strip_offsets
  • sub_ifds
  • sub_sec_time
  • sub_sec_time_digitized
  • sub_sec_time_original
  • subject_area
  • subject_distance
  • subject_distance_range
  • subject_location
  • tiff_ep_standard_id
  • time_zone_offset
  • transfer_function
  • transfer_range
  • user_comment
  • white_balance
  • white_point
  • x_resolution
  • xml_packet
  • xp_author
  • xp_comment
  • xp_keywords
  • xp_subject
  • xp_title
  • y_resolution
  • ycbcr_coefficients
  • ycbcr_positioning
  • ycbcr_sub_sampling

TODO

  1. Create, update and delete tags.

More Repositories

1

jaro_winkler

Ruby & C implementation of Jaro-Winkler distance algorithm which supports UTF-8 string.
Ruby
195
star
2

xdite

Command line tool that prints famous quotes.
Ruby
35
star
3

brainana_shop

歐付寶 + Rails 串接範例網站
Ruby
29
star
4

tj-markdown-paste

Markdown publishing service with mathematical syntax and automatic code highlight.
Ruby
29
star
5

gistyle

GIStyle is a Rails plug-in for DOM-based routing of Javascript, inspired from Paul Irish and Jason Garber.
Ruby
24
star
6

sonycam

Sony Camera API Wrapper
Ruby
19
star
7

allpay

歐付寶 API 的 Ruby 包裝。
Ruby
19
star
8

easycard

台灣悠遊卡交易紀錄查詢工具/A search tool for Taiwan EasyCard
Ruby
15
star
9

TJDict

TJDict is a fast, easy, open-source, and ad-free browser extension for multi-dictionary searching.
JavaScript
14
star
10

lagdown

An open source blogging system
JavaScript
14
star
11

guest-chat

(前)五倍紅寶石匿名聊天室
Ruby
12
star
12

tjstamp

A tool for generating Chinese characters stamp image
Ruby
12
star
13

rr3

Ruby wrapper of c9s/r3
C
8
star
14

libpuzzle_ruby

This is a C extension for libpuzzle to find similar pictures.
Ruby
8
star
15

sfacg_downloader

SFACG Comic Downloader
Ruby
7
star
16

good_lock

Ruby
7
star
17

rails_gulp_bower

A demonstration of integrating gulp, bower and rails without any 3rd party gem
HTML
7
star
18

hahadict

教育部重編國語辭典修訂本 Chrome 離線版
JavaScript
6
star
19

TJNGram

N-Gram generator in Ruby, supporting English, Chinese, Janpanese and Korean.
Ruby
6
star
20

tonytonyjan.github.io

My blog
HTML
5
star
21

rack_encrypted_cookie

Rack middleware for signed encrypted session cookie
Ruby
4
star
22

admin_scaffold

admin scaffold generator
Ruby
4
star
23

react_on_rails

Rails + Webpack + React + Redux + React Router + Server Rendering without other gems
Ruby
4
star
24

geodesics

geodesics calculates the geodesic distance between 2 points with latitude and longitude on ellipsoid Earth using Lambert's formula.
Ruby
4
star
25

octopress-indexer-demo

Demo of indexer Octopress plugin.
JavaScript
4
star
26

fc2_get

FC2 Video Downloader
Ruby
3
star
27

treerful_scanner

小樹屋掃描器 - 找出特定日期所有小樹屋的時間表
Ruby
3
star
28

taiwan-id

Taiwan ID checker and generator.
JavaScript
2
star
29

my_cart

This repo is used for teaching in my class.
Ruby
2
star
30

plist_lite

plist_lite the fastest plist processor for Ruby written in C.
Ruby
2
star
31

material_design_icons_rails

Rails plugin for Google Material Design Icons
CSS
2
star
32

cover_rage

A Ruby production code coverage tool designed to assist you in identifying unused code
Ruby
2
star
33

rfc_2047

A Ruby implementation of RFC 2047
Ruby
2
star
34

ruby-cookbook

A chef cookbook to download, compile and install MRI Ruby.
Ruby
1
star
35

q_and_a

A "question and answer" Rails application architected with Clean Architecture
Ruby
1
star
36

smalldo-robot

1
star
37

past-paper-crawlers

PHP
1
star
38

nctu-course-plus

JavaScript
1
star
39

gym_finder

台灣運動中心場地租用狀況查詢器
Ruby
1
star
40

brainana.com

Brainana Studio official site
CSS
1
star
41

zhrb

Program Ruby in Chinese
Ruby
1
star
42

spritz

A command line tool for spritzing.
Ruby
1
star
43

TJChatbot

Ruby
1
star
44

tjplurk

Plurk API wrapper
Ruby
1
star
45

tj-bootstrap-helper

Tony Jian's Bootstrap helper.
Ruby
1
star
46

timestamp_maker

timestamp_maker is a command-line tool that adds timestamp on images/videos based on their creation time.
Ruby
1
star
47

rails_on_webpack

This product is a demonstration of integration between Rails and Webpack without using any ruby gem.
Ruby
1
star
48

sql_boolean_vs_timestamp

Shell
1
star
49

ruby-conf-tw-twitter-wall

JavaScript
1
star
50

colored_man

A fisherman plugin for fish shell that colorize your man page.
Shell
1
star