Giter Club home page Giter Club logo

exiv's Introduction

exiv

Description

Read and Write ‘Exif’, ‘ID3v1’ and ‘ID3v2’ Image/Media Tags

README FIRST!!!

This package shld work on macOS and Linux systems that have the exiv2 and taglib packages installed:

  • macOS: brew install taglib exiv2
  • Ubuntu/Debian sudo apt-get install libexiv2-dev exiv2 libtag1-dev

For the time being, they need to be easily findable. It’ll be more robust when the pkg is out of Alpha status.

ONLY “Standard” Exif TAGS ARE SUPPORTED FOR THE MOMENT.

Value Exif types currently supported:

  • ascii
  • long
  • short
  • rational
  • srational
  • comment

What’s Inside The Tin

The following functions are implemented:

  • read_exif: Retrieve Exif data from an image file
  • set_exif: Set Exif tag data on an image file
  • exif_tags: Return a data frame of all possible Exif tags

Installation

devtools::install_github("hrbrmstr/exiv")

Usage

library(exiv)
library(tidyverse)

# current verison
packageVersion("exiv")
## [1] '0.1.0'

Tags, you say?

We got your tags, right here:

exif_tags(filter_type="ascii")
## # A tibble: 49 x 4
##                              key  type
##                            <chr> <chr>
##  1 Exif.Image.ProcessingSoftware ascii
##  2       Exif.Image.DocumentName ascii
##  3   Exif.Image.ImageDescription ascii
##  4               Exif.Image.Make ascii
##  5              Exif.Image.Model ascii
##  6           Exif.Image.Software ascii
##  7           Exif.Image.DateTime ascii
##  8             Exif.Image.Artist ascii
##  9       Exif.Image.HostComputer ascii
## 10           Exif.Image.InkNames ascii
## # ... with 39 more rows, and 2 more variables: description <chr>, rname <chr>

Read exif data

This shld be an empty data frame:

r_logo <- system.file("extdata", "Rlogo.png", package="exiv")

read_exif(r_logo)
## # A tibble: 0 x 0

Let’s move it and add some ASCII metadata!

tf <- tempfile(fileext=".png")
file.copy(r_logo, tf)
## [1] TRUE
set_exif(tf, "Exif.Image.ProcessingSoftware", "The incredibly unassuming exiv R package!")
## # A tibble: 1 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii

Just to prove we did it:

read_exif(tf)
## # A tibble: 1 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii

Can I have another, then?

set_exif(tf, "Exif.Image.ImageDescription", "The R logo. Duh!")
## # A tibble: 2 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii

There should be two now!

read_exif(tf)
## # A tibble: 2 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii

Some numerics:

set_exif(tf, "Exif.Image.ImageWidth", 1000)
## # A tibble: 3 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2         Exif.Image.ImageWidth                                      1000     SLong
## 3   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii
set_exif(tf, "Exif.Image.RatingPercent", 30)
## # A tibble: 4 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2         Exif.Image.ImageWidth                                      1000     SLong
## 3   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii
## 4      Exif.Image.RatingPercent                                        30     Short
set_exif(tf, "Exif.Image.YResolution", c(-2, 3))
## # A tibble: 5 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2         Exif.Image.ImageWidth                                      1000     SLong
## 3   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii
## 4        Exif.Image.YResolution                              4294967294/3  Rational
## 5      Exif.Image.RatingPercent                                        30     Short
set_exif(tf, "Exif.Photo.DateTimeOriginal", as.character(Sys.time()))
## # A tibble: 7 x 3
##                        exif_key                                  exif_val exif_type
##                           <chr>                                     <chr>     <chr>
## 1 Exif.Image.ProcessingSoftware The incredibly unassuming exiv R package!     Ascii
## 2         Exif.Image.ImageWidth                                      1000     SLong
## 3   Exif.Image.ImageDescription                          The R logo. Duh!     Ascii
## 4        Exif.Image.YResolution                              4294967294/3  Rational
## 5      Exif.Image.RatingPercent                                        30     Short
## 6            Exif.Image.ExifTag                                       154      Long
## 7   Exif.Photo.DateTimeOriginal                       2017-11-15 06:37:54     Ascii

exiv's People

Contributors

cecilesauder avatar hrbrmstr avatar jeroen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

exiv's Issues

For multipage TIFFs, tags are only viewable for the first 3 images in the stack, and only editable for the first image.

I have a multipage TIFF with >50 TIFFs. But read_exif only shows the first 3. Tags are repeated for each TIFF in the stack like this: E.g., the image description tags are Exif.Image.ImageDescription, Exif.Image2.ImageDescription, and Exif.Image3.ImageDescription. Same for the others. But no more than 3 sets regardless of how many are in the stack.

I can easily change the tags:
set_exif(x = stackedTIFF,tag = "Exif.Image.ImageDescription",val = "DNA")

But reassigning tags for anything but the top TIFF
set_exif(x = stackedTIFF,tag = "Exif.Image2.ImageDescription",val = "DNA")

gives an error:

Error in set_exif(x = mcdVStackedPath, tag = "Exif.Image2.ImageDescription",  : 
  Tag not found

I've had a hell of a time finding a way to edit TIFF tags in R and this comes so close. Is there a fix for this?  🙏🏼

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.