.. index:: 
  !DocumentImage.fromNumpy Method
  
.. _id3_document_document_image_from_numpy_class_method:

===============================================================================
DocumentImage.fromNumpy Method
===============================================================================

Module: :ref:`DocumentImage<id3_document_document_image_class>`

Definition
----------

Creates an Image from the specified data buffer. Supported pixel formats are grayscale formats, BGR and RGB 24bits, and BGRA. For integers format, input datatype must be UINT8.


.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

        @staticmethod
        from_numpy(data: bytearray, pixel_format: PixelFormat) -> DocumentImage

      **Parameters**

        .. line-block::

          ``data`` bytearray
          :guilabel:`in` A numpy array containing the image data.

          ``pixel_format`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.



