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

Convert indexed data into RGB data #23

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

microshine
Copy link

Hi.

I added rgb method to index.js file. It allows converting indexed data into RGB data

Example of usage

const imgFile = fs.readFileSync(path.join(__dirname, "../../img/palette.png"));
const img = fastPng.decode(imgFile);

const data = fastPng.rgb(img.data, img.depth, img.palette)
const newImg = fastPng.encode({
  width: img.width,
  height: img.height,
  channels: 3,
  depth: 8,
  data,
});

@targos
Copy link
Member

targos commented Nov 5, 2021

Thanks for the PR! Can you please remove the second commit? Our repositories expect npm7+ to be present (peer dependencies are installed automatically with it).

@targos
Copy link
Member

targos commented Nov 5, 2021

I'll have a closer look at the code in a few days, as the implementation is quite different than the one I did in image-js: https://github.com/image-js/image-js/blob/5811f5b7e7677cdda1d8ac124a5c963812e5cd59/src/image/core/load.js#L99-L124

@microshine
Copy link
Author

@targos Thanks. Waiting for your review.

@microshine
Copy link
Author

microshine commented Nov 5, 2021

Can you please remove the second commit?

Done

But in my case, it breaks lint tests

https://github.com/microshine/fast-png/runs/4118047939?check_suite_focus=true

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2021

Codecov Report

Merging #23 (0ae308d) into master (bdb81f9) will increase coverage by 0.11%.
The diff coverage is 92.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #23      +/-   ##
==========================================
+ Coverage   90.57%   90.68%   +0.11%     
==========================================
  Files           6        6              
  Lines         403      440      +37     
  Branches       79       86       +7     
==========================================
+ Hits          365      399      +34     
- Misses         38       41       +3     
Impacted Files Coverage Δ
src/types.ts 100.00% <ø> (ø)
src/index.ts 93.61% <92.10%> (-6.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdb81f9...0ae308d. Read the comment docs.

@targos
Copy link
Member

targos commented Nov 5, 2021

Can you please remove the second commit?

Done

But in my case, it breaks lint tests

https://github.com/microshine/fast-png/runs/4118047939?check_suite_focus=true

The Prettier errors can be fixed with npm run prettier-write

@microshine
Copy link
Author

@targos Thank you for the advice. I fixed it

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

Successfully merging this pull request may close these issues.

3 participants