Sharp: Reading png file error

Created on 14 Feb 2017  路  3Comments  路  Source: lovell/sharp

@lovell
I encountered a problem when opening a specified .png file.

My code is like this:

Sharp(filePath)
  .raw()
  .toBuffer(function(data, info) {
    console.log(data);
    console.log(info);
  });

There is a message output like this:

vips warning: linecache: error in tile 0 x 24

I've no idea that it's a bug of libvips or sharp. If it's an error caused by the image format. How can I modify the image file to avoid the error?

Looking forward your reply! Best wishes!

question

Most helpful comment

Here's your fixed .png

Info:
It appears that the provided image hasn't an IEND chunk. I've added the IEND chunk with a hex editor and recalculated the IDAT CRC32 checksum with PNGCSum.

Then I did a check with pngcheck (pngcheck -v chatLockIcon.png) to see if everything was fixed:

File: chatLockIcon.png (1588 bytes)
  chunk IHDR at offset 0x0000c, length 13
    22 x 29 image, 32-bit RGB+alpha, non-interlaced
  chunk tEXt at offset 0x00025, length 25, keyword: Software
  chunk iTXt at offset 0x0004a, length 888, keyword: XML:com.adobe.xmp
    uncompressed, no language tag
    no translated keyword, 867 bytes of UTF-8 text
  chunk IDAT at offset 0x003ce, length 594
    zlib: deflated, 32K window, maximum compression
  chunk IEND at offset 0x0062c, length 0
No errors detected in chatLockIcon.png (5 chunks, 37.8% compression).

All 3 comments

Hello, the image appears to be corrupt. ImageMagick has similar problems reading it:

convert: Expected 4 bytes; found 0 bytes `chatLockIcon.png' @ warning/png.c/MagickPNGWarningHandler/1709.
convert: Read Exception `chatLockIcon.png' @ error/png.c/MagickPNGErrorHandler/1676.

Here's your fixed .png

Info:
It appears that the provided image hasn't an IEND chunk. I've added the IEND chunk with a hex editor and recalculated the IDAT CRC32 checksum with PNGCSum.

Then I did a check with pngcheck (pngcheck -v chatLockIcon.png) to see if everything was fixed:

File: chatLockIcon.png (1588 bytes)
  chunk IHDR at offset 0x0000c, length 13
    22 x 29 image, 32-bit RGB+alpha, non-interlaced
  chunk tEXt at offset 0x00025, length 25, keyword: Software
  chunk iTXt at offset 0x0004a, length 888, keyword: XML:com.adobe.xmp
    uncompressed, no language tag
    no translated keyword, 867 bytes of UTF-8 text
  chunk IDAT at offset 0x003ce, length 594
    zlib: deflated, 32K window, maximum compression
  chunk IEND at offset 0x0062c, length 0
No errors detected in chatLockIcon.png (5 chunks, 37.8% compression).

@lovell Thanks for your quickly reply!

@kleisauke It's a very useful information! Thank you a lot for your help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knoxcard picture knoxcard  路  3Comments

DuckerMan picture DuckerMan  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments

Andresmag picture Andresmag  路  3Comments

genifycom picture genifycom  路  3Comments