How can I convert a very large Portable Pixel Map (ppm
) file into a png
on MacOS?
I have a massive ppm
image on my computer. The file is ~70 GB and I need to convert it to a png which would make it ~100 MB. I have cleared up enough space (>70 GB) on my machine to complete the conversion but am having some issues.
What I Have Tried
-
Open image in preview and export to png
Preview refuses to show the image and instead just shows a black square. When I try to export it tells me that the exported file will be zero bytes. So… no dice.
-
Use ImageMagick to convert the file from terminal
This actually runs and tries to convert the file, but problems arise after about a minute of computation. First, my computer freezes then after a minute or two restarts because of a kernel panic.
Best Answer
netpbm
Try using the open source netpbm tools to perform the conversion. The conversion will likely look like:
Where
input.ppm
is the name of the existing large file andoutput.png
is the name of the desiredpng
formatted file.The project talks about trying to keep memory use low:
Installing
You can install netpbm on your Mac using the Homebrew project, see Install Homebrew. Once
brew
is on your Mac, use the following command to installnetpbm
:If you need help using the command line or tools mentioned, please ask questions.