sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Facing issue on converting formate .dng to .png - Error: Input buffer has corrupt header: tiff2vips: tile size out of range

Open furkan-wve opened this issue 2 years ago • 1 comments

Current Error

Error converting .dng to .png: Error: Input buffer has corrupt header: tiff2vips: tile size out of range
    at Sharp.toBuffer (../Nodo-demo/node_modules/sharp/lib/output.js:161:17)

Used URL --> https://ovvyfiles.s3.us-east-2.amazonaws.com/listing-image/65b1125d76cb13c2979f2bb8/zmNpg3iUrP7a2OF7tuFC.dng

Possible bug

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

  • [x] Running npm install sharp completes without error.
  • [x] 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?

  • [x] 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?

System: OS: macOS 13.5.2 CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz Memory: 1.57 GB / 20.00 GB Shell: 3.2.57 - /bin/bash

Binaries: Node: 21.6.0 - /usr/local/bin/node npm: 10.2.4 - /usr/local/bin/npm

What are the steps to reproduce?

run rpm dev

Error :

Error converting .dng to .png: Error: Input buffer has corrupt header: tiff2vips: tile size out of range
    at Sharp.toBuffer (/Users/wvelabs/Documents/node project/Nodo-demo/node_modules/sharp/lib/output.js:161:17)

What is the expected behaviour?

png image file

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

Calling this function

async function convertDngToPng(dngBuffer, outputFilePath, options = { quality: 80,quality:9 }) {
    try {
        // Use Sharp to read the .dng image and convert it to PNG format with compression
       const  pngImage = await sharp(dngBuffer)
            .png(options) // Set PNG compression options (e.g., quality)
            .toBuffer();

        console.log('Conversion completed successfully.');
        return pngImage;
    } catch (error) {
        console.error('Error converting .dng to .png:', error);
        throw error
    }
}

// Usage example:

            const asyncRequest = promisify(request.get);
            const response = await asyncRequest({ url, encoding: null });
            const dngBuffer = response.body;
    
           
            const inputFilePath = 'input.dng'; // Path to the input .dng file
            const outputFilePath = 'output.png'; // Path for the output .png file
            const options = { quality: 80 }; // Compression options (adjust as needed)

           const output = await convertDngToPng(dngBuffer, outputFilePath, options);

note: relevant library required added

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

furkan-wve avatar Jan 29 '24 11:01 furkan-wve

$ identify -verbose zmNpg3iUrP7a2OF7tuFC.dng 
identify: "dcraw" -c -w -6 -T "zmNpg3iUrP7a2OF7tuFC.dng" > "/tmp/gmPWYMsJ".
Image: zmNpg3iUrP7a2OF7tuFC.dng
  Format: DCRAW
  Geometry: 3024x4032
...

This image is a RAW DNG ("Digital NeGative") masquerading as a TIFF. Please see #616

lovell avatar Jan 29 '24 11:01 lovell

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

lovell avatar Feb 27 '24 14:02 lovell