Hi all,

On Wed, Jul 25, 2018 at 2:56 PM Mateusz Loskot via Boost-users <boost-users@lists.boost.org> wrote:
On 18 July 2018 at 15:05, Frédéric via Boost-users
<boost-users@lists.boost.org> wrote:
> Hi,
>
> Is it possible to read/write an image as JPEG from/into a memory
> buffer instead of a file?


I assume you mean using something like a stringstream as an in-memory buffer. The test suite has some examples, like:

BOOST_AUTO_TEST_CASE( stream_test )
{
    // 1. Read an image.
    std::ifstream in( jpeg_filename.c_str(), ios::binary );

    rgb8_image_t img;
    read_image( in, img, tag_t() );

    // 2. Write image to in-memory buffer.
    std::stringstream out_buffer( ios_base::in | ios_base::out | ios_base::binary );
    write_view( out_buffer, view( img ), tag_t() );

    // 3. Copy in-memory buffer to another.
    std::stringstream in_buffer( ios_base::in | ios_base::out | ios_base::binary );
    in_buffer << out_buffer.rdbuf();

    // 4. Read in-memory buffer to gil image
    rgb8_image_t dst;
    read_image( in_buffer, dst, tag_t() );

    // 5. Write out image.
    std::string filename( jpeg_out + "stream_test.jpg" );
    std::ofstream out( filename.c_str(), ios_base::binary );
    write_view( out, view( dst ), tag_t() );
}

Does that help?

Regards,
Christian​