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

PNG encode feature #20

Open
1 task done
ee-lynn opened this issue Sep 18, 2024 · 3 comments
Open
1 task done

PNG encode feature #20

ee-lynn opened this issue Sep 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ee-lynn
Copy link

ee-lynn commented Sep 18, 2024

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Nice to have (e.g. Adoption is possible, the feature will enhance the use-case even more).

Please provide a clear description of problem this feature solves

nvImageCodec includes the png decoder, how about the encoder counterpart?

Feature Description

nvImageCodec includes the png decoder, but lacks the encoder counterpart.
The libpng encoder costs a noticeable time in my project, i don't find any existing solutions. It will be nice that nvImageCodec supports the png encoder.

Describe your ideal solution

a gpu accelerated png encoder

Describe any alternatives you have considered

No response

Additional context

No response

Check for duplicates

  • I have searched the open bugs/issues and have found no duplicates for this bug report
@ee-lynn ee-lynn added the enhancement New feature or request label Sep 18, 2024
@smatysik-nv
Copy link
Collaborator

Thank you for proposing that. Currently we have just CPU PNG decoding. Short term plan is to add CPU PNG encoding in next release which should be yet this year. Long term plan is to add GPU accelerated PNG decoding and encoding which should be expected in some release next year.

@whisper-bye
Copy link

any good news?

@smatysik-nv
Copy link
Collaborator

In v0.4.0 we have added CPU OpenCV encoders for all formats that were already supported by OpenCV decoder:

  • 8 bit unsigned encoding is supported in following codecs: JPEG, JPEG 2000, PNG, BMP, PNM, TIFF, WebP
  • 16 bit unsigned encoding is supported in following codecs: JPEG 2000, PNG, PNM, TIFF

If a GPU encoder is available (currently for JPEG and JPEG 2000), it will be given higher priority, with the CPU encoder serving as a fallback. For formats like PNG, WebP, and TIFF, only CPU encoders are currently available. This means there is no need to switch to another library for these formats anymore. Later when GPU encoders are added, no code changes will be necessary and CPU encoders would be just for fallback (or for parallel encoding on both CPU and GPU).

Please try following code snippet and let us know if it works.

from nvidia import nvimgcodec
dec = nvimgcodec.Decoder()
img = dec.read("cat.bmp") 

enc = nvimgcodec.Encoder()
enc.write("cat.png", img)
enc.write("cat.webp", img)
enc.write("cat.tiff", img)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants