GithubHelp home page GithubHelp logo

smartlyio / xmp-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from archilogic-com/xmp-editor

0.0 2.0 0.0 1.54 MB

Read and write XMP image metadata in browser and Node.js

Home Page: https://xmp-editor.archilogic.com

License: MIT License

Shell 0.37% JavaScript 41.83% CSS 7.56% HTML 1.15% Vue 44.13% SCSS 4.96%

xmp-editor's Introduction

XMP Editor and JavaScript Library

XMP Editor Sreenshot

Online editor and JavaScript library for XMP data in image files. Library mode supports browser and Node.js environments. XMP is a data format to store any set of standardized and custom metadata properties in digital documents and data sets. Currently reading and writing JPG images is supported. PNG and GIF support will be added later. Contributions are always welcome.

Editor

Visit: https://xmp-editor.archilogic.com

Library

WARNING: This is still work in progress. Expect API changes.

Browser example

Open live demo

<!DOCTYPE html>
<html>
  <head>
    <!-- Load lib via CDN -->
    <script src="https://code.archilogic.com/xmp-editor/xmpEditor.umd.min.js"></script>
  </head>
  <body>
    <!-- XMP code will be displayed here -->
    <pre id="xmp-code"></pre>
    <script>
      // Image URL to read XMP from
      var imageUrl =
        "https://storage.3d.io/535e624259ee6b0200000484/2019-06-16_00-16-32_1BCodw/004.jpg";
      // Fetch image as arrayBuffer
      xmpEditor.helpers.urlToArrayBuffer(imageUrl).then(function(arrBuf) {
        // Extract XMP as text. You can use a XML parser to read the nodes.
        var xmpStr = xmpEditor.jpgReadXmp(arrBuf);
        // Show XMP in DOM
        document.getElementById("xmp-code").textContent = xmpStr;
        // Generate new XMP from template
        var xmpStr = xmpEditor.helpers.createNewXmp();
      });
    </script>
  </body>
</html>

Node.js example:

Install:

npm install archilogic-com/xmp-editor#master

Use:

const { jpgReadXmp } = require('archilogic-com/xmp-editor#master')
const pathUtil = require('path')
const { promisify } = require('util')
const { readFile } = require('fs')

async function getXmpString(imgPath) {
  // Read file from disk
  const buf = await promisify(readFile)(imgPath)
  // Convert to array buffer
  const arrBuf = new Uint8Array(buf).buffer
  // Extract XMP string
  return jpgReadXmp(arrBuf)
}

const IMG_PATH = pathUtil.resolve(`image-with-xmp-metadata.jpg`)
getXmpString(IMG_PATH).then(console.log)

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Run your tests

npm run test

Lints and fixes files

npm run lint

Run your unit tests

npm run test:unit

Customize configuration

See Configuration Reference.

xmp-editor's People

Contributors

tomas-polach avatar frederic-schwarz avatar

Watchers

James Cloos avatar  avatar

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.