Coder Social home page Coder Social logo

exiftool's Introduction

Exiftool

Build Status

Elixir library for the exiftool

Usage

iex> Exiftool.execute([file_path])
{:ok, result}

Installation

If available in Hex, the package can be installed by adding exiftool to your list of dependencies in mix.exs:

def deps do
  [
    {:exiftool, "~> 0.2.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/exiftool.

exiftool's People

Contributors

shavit avatar

Watchers

 avatar  avatar  avatar

Forkers

mihya

exiftool's Issues

exiftool breaks on line lib/exiftool.ex:36

When trying to implement this tool into my project I came along the following error:

{:ok, result} = Exiftool.execute(["test/fixtures/my_file.jpg"])
** (MatchError) no match of right hand side value: nil
(exiftool 0.1.0) lib/exiftool.ex:36: anonymous fn/1 in Exiftool.parse_result/1
(elixir 1.12.2) lib/enum.ex:1582: Enum."-map/2-lists^map/1-0-"/2
(elixir 1.12.2) lib/enum.ex:1582: Enum."-map/2-lists^map/1-0-"/2
(exiftool 0.1.0) lib/exiftool.ex:35: Exiftool.parse_result/1
(exiftool 0.1.0) lib/exiftool.ex:21: Exiftool.execute/1

This is, because the regex does not match in any case to the meta tags of an image.
Here are a few examples where it does NOT match:

"APP14 Flags 0 : [14], Encoded with Blend=1 downsampling"
"APP14 Flags 1 : (none)"
"Data Dump : (Binary data 8200 bytes, use -b option to extract)"
"Internal Serial Number : (F23) 2008:11:20 no. 0182"
"Baby Age : (not set)"
"Scale Factor To 35 mm Equivalent: 5.8"
"Thumbnail Image : (Binary data 7496 bytes, use -b option to extract)"
"Sensor : "
"Manufacture Date : "

So probably the regex should be enhanced or an error handler should be added, when there is no match.

I have tried the following regex:

@regex_result_line ~r/([A-Za-z0-9-\:\/\.,\s]+[a-zA-Z0-9])[\s]*:\s([A-Za-z0-9-\:\/\.,\(\)\s]+)/
(changing [\s]+ to [\s]* and adding () to the right side match.

But still, as I wanted to get the meta tag "orientation" there seems to be an issue, as that value does not appear in the result map. Other meta tags do not appear in the result map too.

I have an image with the following 122 meta tags:

ExifTool Version Number : 12.30
File Name : 3515-1-272208-rotate270.jpg
Directory : test/fixtures
File Size : 989 KiB
File Modification Date/Time : 2021:11:19 10:28:24+01:00
File Access Date/Time : 2021:12:02 12:05:38+01:00
File Inode Change Date/Time : 2021:12:02 12:05:38+01:00
File Permissions : -rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Make : Panasonic
Camera Model Name : DMC-FS5
Orientation : Rotate 270 CW
X Resolution : 180
Y Resolution : 180
Resolution Unit : inches
Software : Ver.1.0
Modify Date : 2021:11:09 10:49:30
Y Cb Cr Positioning : Co-sited
Exposure Time : 1/13
F Number : 3.3
Exposure Program : Program AE
ISO : 800
Exif Version : 0221
Date/Time Original : 2021:11:09 10:49:30
Create Date : 2021:11:09 10:49:30
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 4
Exposure Compensation : 0
Max Aperture Value : 3.3
Metering Mode : Multi-segment
Light Source : Unknown
Flash : Off, Did not fire
Focal Length : 5.2 mm
Image Quality : High
Firmware Version : 0.1.1.3
White Balance : Auto
Focus Mode : Auto
AF Area Mode : Tracking
Image Stabilization : On, Optical
Macro Mode : Off
Shooting Mode : Intelligent Auto
Audio : No
Data Dump : (Binary data 8200 bytes, use -b option to extract)
White Balance Bias : 0
Flash Bias : 0
Internal Serial Number : (F23) 2008:11:20 no. 0182
Panasonic Exif Version : 0260
Video Frame Rate : n/a
Color Effect : Off
Time Since Power On : 00:02:47.81
Burst Mode : Off
Sequence Number : 0
Contrast Mode : Normal
Noise Reduction : Standard
Self Timer : Off
Rotation : Rotate 270 CW
AF Assist Lamp : Fired
Color Mode : Normal
Optical Zoom Mode : Standard
Conversion Lens : Off
Travel Day : n/a
Battery Level : Full
World Time Location : Home
Program ISO : n/a
Advanced Scene Type : 5
Faces Detected : 0
AF Point Position : 0.62 0.5
Num Face Positions : 0
Maker Note Version : 0121
Scene Mode : Intelligent Auto
Highlight Warning : Yes
Dark Focus Environment : Yes
WB Red Level : 1289
WB Green Level : 1054
WB Blue Level : 2201
Text Stamp : Off
Baby Age : (not set)
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 2048
Exif Image Height : 1536
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
Sensing Method : One-chip color area
File Source : Digital Camera
Scene Type : Directly photographed
Custom Rendered : Normal
Exposure Mode : Auto
Digital Zoom Ratio : 0
Focal Length In 35mm Format : 30 mm
Scene Capture Type : Standard
Gain Control : High gain up
Contrast : Normal
Saturation : Normal
Sharpness : Normal
PrintIM Version : 0250
Compression : JPEG (old-style)
Thumbnail Offset : 10144
Thumbnail Length : 7359
Image Width : 2048
Image Height : 1536
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
Aperture : 3.3
Blue Balance : 2.088235
Image Size : 2048x1536
Megapixels : 3.1
Red Balance : 1.22296
Scale Factor To 35 mm Equivalent: 5.8
Shutter Speed : 1/13
Thumbnail Image : (Binary data 7359 bytes, use -b option to extract)
Advanced Scene Mode : Intelligent Auto (intelligent auto)
Circle Of Confusion : 0.005 mm
Field Of View : 61.9 deg
Focal Length : 5.2 mm (35 mm equivalent: 30.0 mm)
Hyperfocal Distance : 1.57 m
Light Value : 4.1

But only the following 48 keys appear in the resulting map:

{:ok,
%Exiftool.Result{
file_inode_change_date_time: "2021:12:02 12:05:38",
bits_per_sample: "8",
camera_model_name: "DMC-FS5",
file_size: "989 KiB",
metering_mode: "Multi-segment",
focal_length: "5.2 mm (35 mm equivalent: 30.0 mm)",
owner_name: nil,
extension: nil,
file_access_date_time: "2021:12:02 12:05:38",
serial_number: nil,
file_name: "3515-1-272208-rotate270.jpg",
exposure_compensation: "0",
file_type_extension: "jpg",
color_tone: nil,
shutter_speed: "1/13",
color_components: "3",
drive_mode: nil,
focus_mode: "Auto",
y_resolution: "180",
file_permissions: "-rw-r--r--",
shootting_mode: nil,
jfif_version: nil,
y_cb_cr_sub_sampling: "YCbCr4:2:2 (2 1)",
sharpness: "Normal",
saturation: "Normal",
iso: "800",
white_balance: "Auto",
image_width: "2048",
contrast: "Normal",
access_date_time: nil,
directory: "test/fixtures",
file_number: nil,
resolution_unit: "inches",
datetime_original: nil,
encoding_process: "Baseline DCT, Huffman coding",
file_type: "JPEG",
quality: nil,
image_height: "1536",
flash: "Off, Did not fire",
mime_type: "image/jpeg",
lens: nil,
exiftool_version_number: "12.30",
aperture: "3.3",
x_resolution: "180",
image_size: "2048x1536",
megapixels: "3.1",
file_modification_date_time: "2021:11:19 10:28:24",
color_space: "sRGB"
}}

That is 74 keys are missing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.