Search code examples
c++11pngjpegimage-conversionraw

C++ library to convert JPEG/PNG images to RAW image format


I have tried searching for a day for converting JPEG & PNG to RAW image format(*.raw format), but couldn't find any and all the result were RAW to JPEG/PNG. Finally i decided to ask here hoping will get the answer.

So, i want to convert images of format JPEG & PNG to RAW image format(*.raw) only and for that i need C++ library which can do this work. Also, if you can suggest some step by step process to achieve it using C++ will be helpful. As i don't have experience in this and not getting start up.

Please guide me for the same. Your help is highly appreciated.

Thanks


Solution

  • "Raw" is not a well defined format.

    Depending on who you talk to, it could mean a manufacturer's proprietary unprocessed format, such as:

    • Nikon's NEF format or
    • Canon's CR2 format or
    • Adobe's DNG format

    Almost no software supports writing such files. dcraw and ufraw support reading them.

    Or it could mean straight RGB888 bytes with no header or size information. Many libraries support this:

    • CImg is probably the simplest - link
    • OpenCV can do it
    • ImageMagick Magick++ can do it
    • libvips can do it

    You don't need to actually write any C/C++ to convert a JPEG/PNG to raw RGB bytes, you can just use ImageMagick in the commandline:

    magick input.png -depth 8 RGB:result.raw