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

WebP shrink-on-load rounding error produces "extract_area: bad extract area" #508

Closed
asilvas opened this issue Jul 13, 2016 · 8 comments
Closed
Labels
Milestone

Comments

@asilvas
Copy link

asilvas commented Jul 13, 2016

Appears there is some sort of rounding error going on. As I validated the inputs and found that if I change the top position from 1 to 0, it works.

Code to reproduce (sharp 0.15.0):

var sharp = require('sharp');

var image = sharp('./test/files/bad-crop.jpg');

image
  .toFormat('webp') // if i don't do this step, it won't fail
  .toBuffer(function(err, outputBuffer, info) {
    console.log('info:', info); // reports 1080x607
    sharp(outputBuffer)
     .ignoreAspectRatio()
     .resize(233, 131)
     .extract({ top: 1, left: 0, width: 233, height: 130 }) // notice, height 130 + top of 1 = height of 131 - VALID
     .toFormat('jpeg')
     .toFile('result.jpg')
     ;

  });

Results in:

Unhandled rejection Error: extract_area: bad extract area

    at Error (native)

It only happens with this image: https://img1.wsimg.com/isteam/stock/5518eebf9a5d704c916de1acd4fe355e2c14463b39e4852697e1ec62859b5f5a?download

@lovell
Copy link
Owner

lovell commented Jul 14, 2016

Hi Aaron, v0.15.0 had a small rounding error fixed as part of #452. Are you able to test with v0.15.1?

@lovell lovell added the triage label Jul 14, 2016
@asilvas
Copy link
Author

asilvas commented Jul 14, 2016

Using v0.15.1 I get:

Unhandled rejection Error: enum 'VipsOperationBoolean' has no member 'null', should be one of: and, or, eor, lshift, rshift
enum 'VipsOperationBoolean' has no member 'null', should be one of: and, or, eor, lshift, rshift
extract_area: bad extract area

    at Error (native)

This is not a warning or "noise" as indicated in #509 -- it is failing.

@lovell
Copy link
Owner

lovell commented Jul 16, 2016

Thanks for confirming this fails with v0.15.1 also (PR #511 on master should have fixed the contents of the error message). I'll make time to investigate further over the next couple of days.

lovell added a commit to lovell/libvips that referenced this issue Jul 20, 2016
@lovell
Copy link
Owner

lovell commented Jul 20, 2016

I've created https://github.com/jcupitt/libvips/pull/489 for this.

@lovell lovell changed the title Unhandled rejection Error: extract_area: bad extract area WebP shrink-on-load rounding error produces "extract_area: bad extract area" Jul 20, 2016
@lovell lovell added this to the v0.15.2 milestone Jul 21, 2016
@lovell
Copy link
Owner

lovell commented Jul 21, 2016

Commit a5bd68e recalculates scaling factors after any use of shrink-on-load, as discussed at https://github.com/jcupitt/libvips/pull/489

@lovell lovell modified the milestones: v0.16.0, v0.15.2 Jul 25, 2016
@asilvas
Copy link
Author

asilvas commented Aug 1, 2016

Seems this bug is impacting more images than I thought. Any idea when you think this patch would be made available? Thanks @lovell !

@lovell
Copy link
Owner

lovell commented Aug 2, 2016

@asilvas This will be in v0.16.0, which will ship with libvips v8.3.3 (v8.3.2 fixes a buffer overflow but introduces a performance regression - see https://github.com/jcupitt/libvips/blob/master/ChangeLog#L36-L42).

@lovell
Copy link
Owner

lovell commented Aug 18, 2016

v0.16.0 is now available via npm.

@lovell lovell closed this as completed Aug 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants