question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HEIF produced by sharp is corrupted

See original GitHub issue

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

npx: installed 1 in 2.023s

System: OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa) CPU: (8) x64 Intel® Core™ i7-6850K CPU @ 3.60GHz Memory: 1.46 GB / 3.84 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.17.5 - ~/.nix-profile/bin/node Yarn: 1.22.0 - ~/.nix-profile/bin/yarn npm: 6.14.14 - ~/.nix-profile/bin/npm

What are the steps to reproduce?

Running the sample code will produce an heif image that is corrupted.

What is the expected behaviour?

An heif image that can be opened normally.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

#!/usr/bin/env node

'use strict'

const sharp = require('sharp')

async function resizeImage () {
  try {
    await sharp('elephant.png')
      .resize({
        width     : 1000,
        height    : 1000,
        background: { r: '255', g: '255', b: '255', alpha: '0' },
      })
      .toFormat('heif')
      .toFile('wow-resized.heif')
  } catch (error) {
    console.log(error)
  }
}

resizeImage()

Please provide sample image(s) that help explain this problem

elephant

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juliangrubercommented, Feb 23, 2022

Interestingly https://www.checkfiletype.com/ can render a preview of the heif image

0reactions
danielehrhardtcommented, Aug 13, 2022

@lovell The issue was on my side and I fixed it now. Thank you very very very much 🙏

I have the same Issue. What have you done to fix it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constructor - High performance Node.js image processing
Constructor factory to create an instance of sharp , to which further methods are chained. JPEG, PNG, WebP, GIF, AVIF or TIFF format...
Read more >
Convert HEIF (.heic) to JPEG on a server? - Stack Overflow
The only way you can do this by exporting your images from your device, that should produce a JPEG image. Nokia has a...
Read more >
Re: Help! Images wont read or open! - Canon Community
Hi there, I would recommend trying to open those files in Digital Photo Professional, this should open any Canon RAW file which is...
Read more >
Sony A7 IV Review - Imaging Resource
The A7 IV produces sharp, detailed images with excellent dynamic range, ... Both JPEG and HEIF formats each have four levels of quality...
Read more >
Using HEIF or HEVC media on Apple devices - Apple Support
HEIF (High Efficiency Image File Format) for photos; HEVC (High Efficiency Video Coding), also known as H.265, for videos. HEIF and HEVC offer ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found