GreycLab / CImg

The CImg Library is a small and open-source C++ toolkit for image processing
http://cimg.eu
Other
1.48k stars 282 forks source link

Saving images (PNG) extremely slow. #298

Closed raaaaaymond closed 3 years ago

raaaaaymond commented 3 years ago

Hello! I just noticed that saving images (PNG)s is extremely slow, like several seconds per frame. Am I doing something wrong? Using the wrong libpng or something? I'm on Windows by the way, Visual Studio 2019. I've double-checked that I'm on a release build. Very simple code snippet:

    CImgList<unsigned char> video(R"(D:\some\video.mp4)");
    for (size_t i = 0; i < video.size(); i++) {
      LOG(INFO) << "Saving frame " << i << ".";
      video(i).save("D:\some\destination.png);
    }

Just use any MP4 video you have, and you'll notice that it takes several seconds to save each frame. Am I doing something stupid?

dtschump commented 3 years ago

Are you using CImg with the libpng enabled, or just the ImageMagick fallback ? The latter case is probably really slow.

In case you have indeed enabled libpng when compiling your program with CImg (defining #cimg_use_png), it should be not that slow.

raaaaaymond commented 3 years ago

Yep it was my fault for not using libpng. Thank you!