Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xmp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmp

  • 2.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

xmp - Extensible Metadata Platform (XMP) parser

XMP provides an object oriented interface to XMP data. XMP data can be found in PDF, JPEG, GIF, PNG, and many other formats.

Supported Formats

FormatFile extensionAdditional dependency
JPEG.jpeg, .jpgexifr/jpeg
TIFF.tiff, .tifexifr/tiff
XMP Files.xmp, .xmlnone

Usage

require 'xmp'
xmp = XMP.new('example.jpg')
xmp.dc.subject # => ["something interesting"]

xmp.namespaces.each do |namespace|
  xmp[namespace].attributes.each do |attribute|
    puts "#{namespace}.#{attribute}: #{xmp[namespace][attribute].inspect}"
  end
end

XMP.new accepts:

  • Paths to files (it will choose based on file extension)
  • File objects (it will choose based on file extension)
  • Nokogiri documents or XML strings

Attributes can be accessed in the following ways:

# assuming an XMP entry AttributeName within the NamespaceName namespace, these are all equivalent
xmp['NamespaceName']['AttributeName']
xmp.namespace_name.attribute_name
xmp.NamespaceName.AttributeName

# you can also mix them
xmp.namespace_name['AttributeName']

# or convert the data to an actual hash
xmp.to_h # => { 'NamespaceName' => { … }, … }

Installation

$ gem install xmp
$ gem install exifr # optional, for jpeg/tiff support

Or you can add it to your Gemfile:

gem 'xmp',   '~> 1.0'
gem 'exifr', '~> 1.3'

Requirements

  • Ruby 2 (supported on >= 2.6, though xmp may work on earlier versions) or Ruby 3
  • nokogiri (>= 1.10). The xmp gem depends on this gem. It will be installed automatically.
    • On Ruby 2.6, nokogiri 1.13.10 will be installed; nokogiri >= 1.14 require Ruby 2.7.
    • On Ruby 2.7, nokogiri 1.15.5 will be installed; nokogiri >= 1.16 require Ruby 3.
    • See https://nokogiri.org/CHANGELOG.html for nokogiri support for older or newer Ruby versions.
  • exifr (>= 1.3). This gem is optional. If you need it, add it to your Gemfile.

Development

Fork it at https://github.com/amberbit/xmp

$ bundle install # install development dependencies
$ rake spec      # run specs

License

Ruby's license.

Copyright (c) 2011 Wojciech Piekutowski, AmberBit (http://amberbit.com) and contributors.

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc