unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
2.05k stars 67 forks source link

feat: add experimental unflatten handler for image processing #248

Open nathanchase opened 1 week ago

nathanchase commented 1 week ago

This pull request introduces a new handler function to the src/handlers/handlers.ts file. The new function, unflatten, is experimental and its API may change in the future.

New handler function added:

See https://sharp.pixelplumbing.com/api-operation#unflatten for more information.

pi0 commented 1 week ago

Thanks for PR dear @nathanchase. Wondering is it worth to wait for sharp feature to be stable first?

Do you have some more context why it is in experimental state?

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.18%. Comparing base (f666cb4) to head (7dd635f). Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
src/handlers/handlers.ts 77.77% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #248 +/- ## ========================================== + Coverage 56.02% 56.18% +0.16% ========================================== Files 14 14 Lines 1203 1212 +9 Branches 83 84 +1 ========================================== + Hits 674 681 +7 - Misses 526 528 +2 Partials 3 3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

nathanchase commented 6 days ago

Thanks for PR dear @nathanchase. Wondering is it worth to wait for sharp feature to be stable first?

Do you have some more context why it is in experimental state?

I don't have any knowledge of why it's experimental. I just know that I have an immediate use case for it with https://github.com/nuxt/image to make all images with a solid white background become transparent backgrounds. I happened to notice it wasn't wired up to sharp's implementation, so this was just meant as a means of connecting to the unflatten functionality that already exists so that I could use it.

nathanchase commented 6 days ago

For what it's worth, unflatten has been in sharp since April 2023. https://github.com/lovell/sharp/issues/1648#issuecomment-1525238474