You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does GPUJPEG support saving BMP files as PNG format?Is the encoding and decoding implemented within the GPU?for NVIDIA GPUs #105
1.Does GPUJPEG support saving BMP files as PNG format?Is the encoding and decoding implemented within the GPU?for NVIDIA GPUs
Thanks!
2.The support for png has already been added in 0871ce9
I saw the submission, but i don't know how to using the new png function interface.
3.Could you provide a similar example?
If I want to save it as a PNG file, how should I specify the following parameters?
param_image.color_space = GPUJPEG_YCBCR_JPEG;
param_image.pixel_format = GPUJPEG_U8;
changed the title [-]Are there any PNG encoding/decoding libraries?[/-][+]Are there any PNG encoding/decoding libraries?for NVIDIA GPUs[/+]on Dec 31, 2025
changed the title [-]Are there any PNG encoding/decoding libraries?for NVIDIA GPUs[/-][+]Does GPUJPEG support saving BMP files as PNG format?Is the encoding and decoding implemented within the GPU?for NVIDIA GPUs[/+]on Dec 31, 2025
You mean encoding BMP directly to PNG? Unfortunately this is not possible - GPUJPEG is intended for encoding/decoding JPEGs.
This means that although you can encode from BMP/PNG to JPEG or decode from JPEG to BMP (or transcode from JPEG to PNG), BMP<->PNG conversions are not supported.
Is the encoding and decoding implemented within the GPU?
encoding/decoding JPEGs from/to RAW - of course (this is the aim of this library)
PNG - no
(BMP is trivial even on CPU)
The formats BMP and PNG are implemented via stb_image (as well as TGA and GIF are) so those are CPU only. Mainly PNG and GIF is there mostly for convenience - because are not accelerated and its encode/decode will perhaps consume some time. The main purpose of GPUJPEG is to compress/decompress JPEG from/to RAW bitmap.
If you are looking for accelerated PNG encoder/decoder. you can look here - to view the PDF, registration is needed, but basically a takeaway is that they at NVIDIA managed to speed-up encoding of PNG up to 20x (compared to CPU implementation). for decoding at most x2 (but also slower). IIRC it should be implemented inside NVIDIA DALI.
Thank you!
The performance of stb_image in reading and writing png files is still a bit slow.
I found a library of the CPU, https://github.com/richgel999/fpng, is relatively fast.
But I would rather find an open-source library that can use GPU to encode and decode png files.
Thanks for pointing me to fpng, I've tried it also in my side project and it works nicely.
Furthermore, I've also found fpnge, which seems to be even better to me because it also supports grayscale encode (with optional alpha), which is better if we have a grayscale image, not to be forced to multiply the channel 3 times if we have such a content. The performance/size seem to be roughly the same for fpng and fpnge in case of RGB(A).
So I've added the PNG encode through fpnge to GPUJPEG. It is disabled by default (so that libgpujpeg doesn't depend on stdc++ lib by default) and needs to be enabled by cmake -DENABLE_FPNGE=ON. If enabled, the encoder is preferred over the one from stb_image for PNG. The fpnge source is included in GJ sources and it is explicitly enabled in CI builds.
fpnge supports just the encoder. I've looked into fpng whether the decoder can be used but it seems to me, that the subset of images that the decoder is willing to decode is very restricted. Even for a fpnge encoded file, it returned FPNG_DECODE_NOT_FPNG because it didn't have some fdEC chunk. Technically, I could add fpng decoder and stb_image as a fallback but if the fpng decoder is mostly able to decode just the files that its own encoder encodes, I'll perhaps leave it outside GPUJPEG.
UPDATE 2026-02-18: last paragraph slightly reformulated + dropped last sentence (unneeded)
I am closing this for now. As decoding is implemented with stbi and encoding with fpnge. I believe that it is the best possible code around that I can use. As it is on CPU, it won't be blazing fast and this should be seen rather as a compat.
As far as for the NVIDIA PNG CUDA code that I thought it could be inside DALI (above) - I've now cloned that Git repo and unfortunately I didn't find anything PNG-related so I am unsure if it actually it landed somewhere in open-sourced project.
Feel free to reopen if having some idea but I currently don't have any what can be added easily (ideally using someone's library). At this point we do not have any plans to implement PNG in CUDA by ourselves (for me, it is hard to estimate the required time frame, although LLM may help).
Activity
[-]Are there any PNG encoding/decoding libraries?[/-][+]Are there any PNG encoding/decoding libraries?for NVIDIA GPUs[/+][-]Are there any PNG encoding/decoding libraries?for NVIDIA GPUs[/-][+]Does GPUJPEG support saving BMP files as PNG format?Is the encoding and decoding implemented within the GPU?for NVIDIA GPUs[/+]MartinPulec commentedon Jan 2, 2026
You mean encoding BMP directly to PNG? Unfortunately this is not possible - GPUJPEG is intended for encoding/decoding JPEGs.
This means that although you can encode from BMP/PNG to JPEG or decode from JPEG to BMP (or transcode from JPEG to PNG), BMP<->PNG conversions are not supported.
The formats BMP and PNG are implemented via stb_image (as well as TGA and GIF are) so those are CPU only. Mainly PNG and GIF is there mostly for convenience - because are not accelerated and its encode/decode will perhaps consume some time. The main purpose of GPUJPEG is to compress/decompress JPEG from/to RAW bitmap.
If you are looking for accelerated PNG encoder/decoder. you can look here - to view the PDF, registration is needed, but basically a takeaway is that they at NVIDIA managed to speed-up encoding of PNG up to 20x (compared to CPU implementation). for decoding at most x2 (but also slower). IIRC it should be implemented inside NVIDIA DALI.
libaineu2004 commentedon Jan 2, 2026
Thank you!
The performance of stb_image in reading and writing png files is still a bit slow.
I found a library of the CPU, https://github.com/richgel999/fpng, is relatively fast.
But I would rather find an open-source library that can use GPU to encode and decode png files.
add fpnge encoder
MartinPulec commentedon Feb 11, 2026
Thanks for pointing me to fpng, I've tried it also in my side project and it works nicely.
Furthermore, I've also found fpnge, which seems to be even better to me because it also supports grayscale encode (with optional alpha), which is better if we have a grayscale image, not to be forced to multiply the channel 3 times if we have such a content. The performance/size seem to be roughly the same for fpng and fpnge in case of RGB(A).
So I've added the PNG encode through fpnge to GPUJPEG. It is disabled by default (so that libgpujpeg doesn't depend on stdc++ lib by default) and needs to be enabled by
cmake -DENABLE_FPNGE=ON. If enabled, the encoder is preferred over the one from stb_image for PNG. The fpnge source is included in GJ sources and it is explicitly enabled in CI builds.fpnge supports just the encoder. I've looked into fpng whether the decoder can be used but it seems to me, that the subset of images that the decoder is willing to decode is very restricted. Even for a fpnge encoded file, it returned FPNG_DECODE_NOT_FPNG because it didn't have some fdEC chunk. Technically, I could add fpng decoder and stb_image as a fallback but if the fpng decoder is mostly able to decode just the files that its own encoder encodes, I'll perhaps leave it outside GPUJPEG.
UPDATE 2026-02-18: last paragraph slightly reformulated + dropped last sentence (unneeded)
MartinPulec commentedon Oct 6, 2026
I am closing this for now. As decoding is implemented with stbi and encoding with fpnge. I believe that it is the best possible code around that I can use. As it is on CPU, it won't be blazing fast and this should be seen rather as a compat.
As far as for the NVIDIA PNG CUDA code that I thought it could be inside DALI (above) - I've now cloned that Git repo and unfortunately I didn't find anything PNG-related so I am unsure if it actually it landed somewhere in open-sourced project.
Feel free to reopen if having some idea but I currently don't have any what can be added easily (ideally using someone's library). At this point we do not have any plans to implement PNG in CUDA by ourselves (for me, it is hard to estimate the required time frame, although LLM may help).