.. include:: ../substitutions

.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEWriteImageToString

.. _OEDepict_OEWriteImageToString:


.. oe:function:: OEWriteImageToString


   .. oe:language:: c++ java csharp

      .. oe:api::

         std::string OEWriteImageToString(const std::string& ext,
                                          const OEImage& image)

   .. oe:language:: python

      .. oe:api:: python

         OEWriteImageToString(extension: str, image: OEImage) -> bytes

   Writes the image into a string.

   *ext*
      The extension which determine the type of the image.

   *image*
      The :ref:`OEImage <OEDepict_OEImage>` object which is being written
      into the string.

   **Example:**

   .. oe:source:: WriteImageToString.py
      :language: python
      :noindent:
      :frag:     SNIPPET-WRITE-IMAGE-TO-STRING

   .. oe:source:: WriteImageToString.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-WRITE-IMAGE-TO-STRING

   .. oe:source:: WriteImageToString.java
      :language: java
      :noindent:
      :frag:     SNIPPET-WRITE-IMAGE-TO-STRING

   .. oe:source:: WriteImageToString.cs
      :language: csharp
      :noindent:
      :frag:     SNIPPET-WRITE-IMAGE-TO-STRING


   .. oe:language:: python

      .. note::

         In **Python 3** the :oe:func:`OEDepict::OEWriteImageToString`
         function returns ``bytes``.


   .. seealso::

      * :oe:func:`OEDepict::OEIsRegisteredImageFile` function

      .. oe:language:: python

         * :oe:func:`OEDepict::OEWriteImageToBytes` function
