jimp-dev / jimp-dev/jimp

Autocrop creates one-line image in some situations

Open
#651 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
14.7k
Forks
777
PR merge metrics
No merged PRs in 30d

Description

# Expected Behavior

The image.autocrop() function should remove the transparent parts around the object in the image.

# Current Behavior

Instead, in some rare cases, it creates a seemingly empty, one line graphic.

# Failure Information (for bugs)

I cannot tell when exactly the source image causes autocrop to fail, but in the image in the example down below this is the case.

## Steps to Reproduce

Image:
Imgur: https://imgur.com/a/Vroj0JN
Data URL: https://pastebin.com/kBHZE3Bq

1. Setup an environment with the Jimp version 0.5.5.
2. Run this code. Use the string from pastebin as variable "dataUrl".
```javascript
Jimp.read(Buffer.from(dataUrl, 'base64')).then((image) => {
image.autocrop()
console.log({x: image.bitmap.width, y: image.bitmap.height})
});
```
3. The function logs the dimensions of the image, which will result in `> x: 118, y: 1`. Rendering the result image would confirm this.

## Context

Running Jimp in Electron 2.0.0. The example image was created in a WebGL canvas using `canvas.toDataURL()`

- Jimp Version: v0.5.5
- Operating System: Windows 10
- Node version: v8.9.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.