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

Has alpha #585

Merged
merged 10 commits into from Sep 2, 2018
Merged

Has alpha #585

merged 10 commits into from Sep 2, 2018

Conversation

hipstersmoothie
Copy link
Collaborator

What's Changing and Why

determine if an image is using the alpha channel.

closes #271

What else might be affected

Tasks

  • Add tests
  • Update Documentation
  • Update jimp.d.ts
  • Add SemVer Label

@hipstersmoothie hipstersmoothie added the enhancement a request for a new feature or change in behavior label Sep 1, 2018
@@ -135,3 +135,17 @@ describe('FileType', () => {
image.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);
});
});

describe('hasAlpah', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alpha (typo)

const alpha = this.bitmap.data[idx + 3];

if (alpha !== 0xff) {
hasAlpha = true;
Copy link
Contributor

@edi9999 edi9999 Sep 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how well v8 and others engines read the code ahead, but wouldn't it be faster to return early ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the for loops check for hasAlpha to be false so once if find an alpha channel both the loops break. I will go through every pixel if it doesn't find an alpha channel though.

README.md Outdated
@@ -11,6 +11,8 @@ An image processing library for Node written entirely in JavaScript, with zero n

Installation: `npm install --save jimp`

API documnetation can be found in the main [jimp package](./packages/jimp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo documentation

@hipstersmoothie
Copy link
Collaborator Author

@edi9999 comments addressed

@hipstersmoothie hipstersmoothie mentioned this pull request Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request for a new feature or change in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

image.hasAlpha() Method?
2 participants