🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

exifly

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exifly

An ES modules Typescript implementation to get EXIF of an image

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
0
Created
Source

Exifly

An ES modules Typescript implementation based on exif-heic-js to get EXIF of an image.

Example

ESM

import { useState } from 'react';
import * as Exifly from 'exifly';

export default function () {
  const [tags, setTags] = useState('');
  const handleFileChange = e => {
    let extension = e.target.files[0].name.toLowerCase().split('.').at(-1);
    let reader = new FileReader();

    reader.onload = function () {
      const exifly = new Exifly.load(reader.result);
      if (extension === 'heic') {
        tags = exifly.heic();
      } else if (extension === 'jpg' || extension === 'jpeg') {
        tags = exifly.jpeg();
      } else {
        tags = exifly.raw();
      }

      console.log(tags);
      setTags(JSON.stringify(tags, null, 2));
    };

    reader.readAsArrayBuffer(e.target.files[0]);
  };

  return (
    <>
      <div>
        <input
          type="file"
          id="image"
          accept=".heic,.jpeg,.jpg"
          onChange={handleFileChange}
        />
      </div>
      <div>
        <pre>{tags}</pre>
      </div>
    </>
  );
}

UMD

<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Exifly</title>
  </head>

  <body>
    <div>
      <input type="file" id="image" accept=".heic,.jpeg,.jpg" />
    </div>
    <div>
      <pre id="tags"></pre>
    </div>
    <script src="../dist/exifly.umd.js"></script>
    <script>
      document.getElementById('image').onchange = function (e) {
        let extension = e.target.files[0].name.toLowerCase().split('.').at(-1);
        let reader = new FileReader();

        reader.onload = function () {
          const exifly = new Exifly.load(reader.result);
          if (extension === 'heic') {
            tags = exifly.heic();
          } else if (extension === 'jpg' || extension === 'jpeg') {
            tags = exifly.jpeg();
          } else {
            tags = exifly.raw();
          }
          console.log(tags);
          document.getElementById('tags').textContent = JSON.stringify(
            tags,
            null,
            2,
          );
        };

        reader.readAsArrayBuffer(e.target.files[0]);
      };
    </script>
  </body>
</html>

Keywords

exif

FAQs

Package last updated on 28 Jun 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