.. index:: 
  !DocumentImage.fromFile Method
  
.. _id3_document_document_image_from_file_class_method:

===============================================================================
DocumentImage.fromFile Method
===============================================================================

Module: :ref:`DocumentImage<id3_document_document_image_class>`

Definition
----------

Creates an Image from the specified file.


.. tab-set::

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

      .. code:: Python

        @staticmethod
        from_file(filepath: str, pixel_format: PixelFormat) -> DocumentImage

      **Parameters**

        .. line-block::

          ``filepath`` str
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``pixel_format`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input 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.


    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

        static DocumentImage fromFile(String? filepath, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

          ``filepath`` String
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``pixelFormat`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input 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.


    .. tab-item:: C#
      :sync: C#

      .. code:: C#

        public static DocumentImage FromFile(string filepath, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

          ``filepath`` string
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``pixelFormat`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input 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.


    .. tab-item:: Java
      :sync: Java

      .. code:: Java

        public static DocumentImage fromFile(String filepath, PixelFormat pixelFormat) throws DocumentException

      **Parameters**

        .. line-block::

          ``filepath`` String
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``pixelFormat`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input 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.


    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

        public static func fromFile(filepath: String, pixelFormat: PixelFormat) throws -> DocumentImage

      **Parameters**

        .. line-block::

          ``filepath`` String
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``pixelFormat`` :ref:`PixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input 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.


    .. tab-item:: C
      :sync: C

      .. code:: C

        int id3DocumentImage_FromFile (
            ID3_DOCUMENT_IMAGE hDocumentImage, 
            const char * filepath, 
            id3DocumentPixelFormat ePixelFormat)

      **Parameters**

        .. line-block::

          ``hDocumentImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` Handle to the DocumentImage object.

          ``filepath`` const char *
          :guilabel:`in` A string that contains the name of the file from which to create the Image.

          ``ePixelFormat`` :ref:`id3DocumentPixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          ``int``
          An error code.
          See :ref:`id3DocumentError<id3_document_document_error_enum>` file for the list of possible error codes.


