Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Efficiently read a PNG file from disk and return the image
ResourceFunction["ReadPNG"][file] reads file as a PNG image and returns the image. |
Export a random image as a PNG file:
In[1]:= | ![]() |
Out[1]= | ![]() |
Import the file with ReadPNG one hundred times, noting the elapsed time:
In[2]:= | ![]() |
Out[3]= | ![]() |
Repeat the same experiment with Import:
In[4]:= | ![]() |
Out[4]= | ![]() |
Note how ReadPNG is significantly faster than Import:
In[5]:= | ![]() |
Out[5]= | ![]() |
ReadPNG only imports a file as an Image. Import provides many more options:
In[6]:= | ![]() |
Out[6]= | ![]() |
PNG importing can be made even faster by using the underlying symbol directly to avoid ResourceFunction overhead:
In[7]:= | ![]() |
Out[7]= | ![]() |
In[8]:= | ![]() |
Out[8]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License