Git Product home page Git Product logo

jekyll-exif-data's Introduction

Jekyll-exif-data

Gem Version

This Jekyll plugin adds the Liquid filter exif, supplying exif data to Jekyll websites. To read the data exifr is used as a dependency.

Installation

Add the plugin to your site's Gemfile:

group :jekyll_plugins do
  # your other jekyll plugins...
  gem 'jekyll-exif-data', '~> 0.0'
end

Then run

$ bundle install

in your jekyll project directory. The dependency of the plugin is also automatically installed by this command.

Manual installation

In your terminal:

$ gem install jekyll-exif-data

Then add the plugin to your _config file:

plugins:
  - jekyll-exif-data

Usage

{{ image_path | exif: '[exif-tag]'}}

The exif filter takes the exif tag as the argument and acts on the image (path without leading slash).

Examples:

{% assign image_path = "assets/my_image.jpg" %}
{{ image_path | exif: 'model'}}
{{ "assets/images/example.jpg" | exif: 'date_time' | date: "%Y" }}

For more examples of possible exif tags see exifr. The argument taken by the exif filter is the name of the method in exifr (for deeper methods join them with a dot e.g. gps.latitude or f_number.to_f).

You can use the arguments exif? and gps? to figure out whether there is any exif/gps data for your image. The code shown below links to the location on https://www.openstreetmap.org where the image was taken and additionally provides the model of the camera used and the year.

{% capture has_exif %}{{ image-path-no-leading-slash | exif: "exif?" }}{% endcapture %}
{% capture has_gps %}{{ image-path-no-leading-slash | exif: "gps?" }}{% endcapture %}
{% if has_exif %}
    Taken
    {% if has_gps=="true" %}
        <a href="https://www.openstreetmap.org/?mlat={{ image-path-no-leading-slash | exif: 'gps.latitude' }}&mlon={{ image-path-no-leading-slash | exif: 'gps.longitude' }}&zoom=8&layers=M" target="_blank">here </a>
    {% endif %}
    with a {{ image-path-no-leading-slash | exif: 'model' }}
    in {{ image-path-no-leading-slash | exif: 'date_time' | date: "%Y" }}.
{% endif %}

If the exif tag exists, but there is no value saved for it an empty String is returned opposed to nil by exifr.

jekyll-exif-data's People

Contributors

niklasei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jekyll-exif-data's Issues

doesn't run on github

Hello,
I use the 0.0.3 version, jekyll version 4.1.0
Run correctly on my local machine (Linux)
Doesn't run when I deploy on github !

I applied carefully the readme.
What I could forget ? dependencies ?
My code:
Modèle: {{ include.content | exif: 'model' }} Prise de vue: {{ include.content | exif: 'date_time' | date: "%d-%m-%Y" }} Vitesse: {{ include.content | exif: 'exposure_time.to_s' }} Ouverture: {{ include.content | exif: 'f_number.to_f' }}
where include.content is a image path.

Need for help!

I would like to use your pluin but I'm unable to make it working.

Now, I got this error:
Liquid Warning: Liquid syntax error (line 17): Unexpected character / in "{{ assets/images/ori/01.jpg | exif: 'model'}}" in index.html
Liquid Exception: undefined method getbyte' for nil:EXIFR::JPEG::Reader in index.html bundler: failed to load command: jekyll (/usr/local/lib/ruby/gems/2.6.0/bin/jekyll) NoMethodError: undefined method getbyte' for nil:EXIFR::JPEG::Reader
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/delegate.rb:87:in method_missing' /usr/local/lib/ruby/gems/2.6.0/gems/exifr-1.3.6/lib/exifr/jpeg.rb:101:in examine'
/usr/local/lib/ruby/gems/2.6.0/gems/exifr-1.3.6/lib/exifr/jpeg.rb:36:in initialize' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-exif-data-0.0.3/lib/jekyll/exif-data.rb:9:in new'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-exif-data-0.0.3/lib/jekyll/exif-data.rb:9:in exif' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/strainer.rb:56:in invoke'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/context.rb:86:in invoke' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:84:in block in render'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in each' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in inject'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in render' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in render_node_to_output'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:80:in render' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:208:in block in render'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:242:in with_profiling' /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:207:in render'
/usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:220:in render!' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:35:in block (3 levels) in render!'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:49:in measure_counts' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:34:in block (2 levels) in render!'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:53:in measure_bytes' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:33:in block in render!'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:60:in measure_time' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/liquid_renderer/file.rb:32:in render!'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/renderer.rb:127:in render_liquid' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/renderer.rb:80:in render_document'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/renderer.rb:63:in run' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:523:in render_regenerated'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:516:in block in render_pages' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:515:in each'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:515:in render_pages' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:202:in render'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:76:in process' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:28:in process_site'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:65:in build' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:36:in process'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in block in process_with_graceful_fail' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in each'
/usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in process_with_graceful_fail' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/serve.rb:86:in block (2 levels) in init_with_program'
/usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in block in execute' /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in each'
/usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in execute' /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in go'
/usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in program' /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/exe/jekyll:15:in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/bin/jekyll:23:in load' /usr/local/lib/ruby/gems/2.6.0/bin/jekyll:23:in <top (required)>'

exifr is installed and working ... I tested with:
irb(main):005:0> EXIFR::JPEG.new('assets/images/ori/01.jpg').model
=> "X-E1"
irb(main):006:0>

an for the "/" character I'm following your examples ... I think ...

Can you help me where I'm wrong?

Thank you!

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.