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.

Error: extract_area: bad extract area

See original GitHub issue

Hello, I’m using 512x512 image. First I resize it then extract and expecting readable stream data but it shows me “Error: extract_area: bad extract area” error. Here’s the code;

test2(x, y, zoom) {
        const width = 500;
        const height = 500;

        return this.image
            .metadata()
            .then((metadata) => {
                var resizedWidth = metadata.width * zoom;
                var resizedHeight = metadata.height * zoom;
                var left = parseInt(resizedWidth * x);
                var top = parseInt(resizedHeight * y);
                return this.image
                    .resize(resizedWidth, resizedHeight)
                    .extract({left: left, top: top, width: width, height: height})
                    .jpeg()
                    .resize(500);
            });
}

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
imCorfitzcommented, Oct 18, 2020

I know this may be an old thread - but I experienced this issue recently, and it was due to the orientation of the image on the server, not being equivalent of the interpreted orientation in the browser. Say I took a picture with my iPhone, then safari and the phone knew how to properly orient the photo, but the server no.

In order to fix that, I simply initialised the sharp procedure with .rotate(), which took care of that.

sharp('image data goes here').rotate().extract({left: left, top: top, width: width, height: height}).resize(width, height);.

Just as a note for future visitors, as this issue pops up as the first result when searching in Google.

0reactions
geiszlacommented, May 23, 2022

This is still an issue until this day. Is there an issue tracking this?

Edit: my bad, didn’t realize the rotate() auto-rotates the image. Works perfectly now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resize image using 'auto' in width or height not working - Bugs
Well the error we were having is gone but I now have this ... message: “extract_area: bad extract area↵”; stack: “Error: extract_area: bad...
Read more >
Error: extract_area: bad extract area - Bountysource
I'm doing facial recognition, meaning I get the position and resolution where to find the face (bounding box). The original image is: 1280x720 ......
Read more >
Python sitk ExtractImageFilter -- basic usage help??
Creates a small image and then extract a sub-image that is even ... itk::ERROR: ExtractImageFilter(0x7f7eb17d8e80): Extraction Region not ...
Read more >
Check-in [67f13ff3ae] - SQLite
Use a wasm runtime error, because a JS error might be seen as a ... the most common failure cause to be a...
Read more >
Kotlin calling non final function in constructor works
abstract class Base(var code: Int) { abstract fun calculate(): Int } class Derived(private val x: ... To: area by lazy { extractArea(room) }....
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