Giter Club home page Giter Club logo

heic-jpg-exif's Introduction

heic-jpg-exif

ci npm-downloads npm-version

Conversion from HEIC to JPG while retaining essential EXIF metadata

Install

npm install heic-jpg-exif

Usage (NodeJS)

const convert = require('heic-jpg-exif');

Convert an HEIC image file to a JPEG file at maximum quality (1)

await convert('input.HEIC', 'output.jpg', 1);

Convert an HEIC buffer to a JPEG buffer

const inBuffer = fs.readFileSync('input.HEIC');
const outBuffer = await convert(inBuffer);

Background

The HEIC image is first converted to a JPG with heic-convert and then complemented with the EXIF metadata of the source image using exifr and piexif-ts.

See also

heic-jpg-exif's People

Contributors

szapp avatar

Watchers

 avatar  avatar

heic-jpg-exif's Issues

Convert logic does not rotate the image upright

First of all awesome implementation, i had a lot of trouble where when i converted from heic to jpg/jpeg it just removed that underlying metadata (including the exif data).

However in your convert module you specify that this following logic rotates the image upright, but through different test it does not seem to do it. And i usually deal with quite a lot of heic images that are rotated differently, and we want to store the image in it's "correct orientation"
// Conversion rotates the image upright if (ifd0[piexif.TagValues.ImageIFD.Orientation] > 4) { const xd = exif[piexif.TagValues.ExifIFD.PixelXDimension] const yd = exif[piexif.TagValues.ExifIFD.PixelYDimension] exif[piexif.TagValues.ExifIFD.PixelXDimension] = yd exif[piexif.TagValues.ExifIFD.PixelYDimension] = xd ifd0[piexif.TagValues.ImageIFD.Orientation] = 1 }

This is my implementation:

if (fileExtension === "heic") { const outBuffer = await convert(file.buffer, undefined, 0.7); fileObj = { originalname: file.originalname, buffer: outBuffer, }; }

Thank you very much

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.