Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Corrupt JPG, exceeded buffer limits #96

Open
joesong168 opened this issue Aug 3, 2017 · 6 comments
Open

TypeError: Corrupt JPG, exceeded buffer limits #96

joesong168 opened this issue Aug 3, 2017 · 6 comments
Milestone

Comments

@joesong168
Copy link

Maybe that's because the JPG is too big, but I would like to know how to avoid.
http://pan.baidu.com/s/1geSFOFT

@stephen-last
Copy link

I have the same issue:

TypeError: Corrupt JPG, exceeded buffer limits
at validateBuffer (C:...\node_modules\image-size\lib\types\jpg.js:23:11)
at Object.calculate (C:...\node_modules\image-size\lib\types\jpg.js:42:5)
at lookup (C:...\node_modules\image-size\lib\index.js:26:31)
at C:...\node_modules\image-size\lib\index.js:93:22
at C:...\node_modules\image-size\lib\index.js:50:9
at C:...\node_modules\graceful-fs\graceful-fs.js:43:10

I need to be able to work with large images.

How can I increase the buffer limits..?

@netroy netroy added this to the 1.0.0 milestone Dec 16, 2017
@onlytropics
Copy link

I just encountered it, too. I can give you an example image, if needed. In my case the image is 2362x2362 pixels, so not too big really, and can be read just fine by any image editor I have.

@alexahdp
Copy link

alexahdp commented May 8, 2018

Is there any decision for this problem?

@mmoczulski
Copy link

mmoczulski commented Jul 19, 2018

Luckily, I found an easy workaround for that problem. Instead of putting the file path to the function, put buffer with already loaded file.

For instance:

fs.readFile(filePath, (err, buf) => {
  if (err) ...
  const result = sizeOf(buf);
  console.log(`dim: ${result.width} x ${result.height}`);
});

Btw, the problem is that image-size tries to load as few bytes of the file as possible, but it may be insufficient for some files (like in our cases). If you read the source code, there's check whether 512kB or file size is smaller and it reads only that amount of bytes
https://github.com/image-size/image-size/blob/master/lib/index.js#L57

I think the author is aware of that but didn't have sufficient resources to implement adaptive version 😉 - https://github.com/image-size/image-size/blob/master/lib/index.js#L10

@johsmic
Copy link

johsmic commented Dec 5, 2018

I get this error when the jpg-image uses CMYK color model.

@AndrewKvalheim
Copy link

Is this the same as #34?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants