.. index:: 
  !DocumentImage.crop Method
  
.. _id3_document_document_image_crop_class_method:

===============================================================================
DocumentImage.crop Method
===============================================================================

Module: :ref:`DocumentImage<id3_document_document_image_class>`

Definition
----------

Crop a rectangular region of interest in the image according to the given bounds.


.. tab-set::

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

      .. code:: Python

        crop(self, left: int, top: int, width: int, height: int) -> DocumentImage

      **Parameters**

        .. line-block::

          ``left`` int
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` int
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` int
          :guilabel:`in` Width of the crop to extract.

          ``height`` int
          :guilabel:`in` Height of the crop to extract.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The extracted region of interest.

      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        DocumentImage crop(int left, int top, int width, int height)

      **Parameters**

        .. line-block::

          ``left`` int
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` int
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` int
          :guilabel:`in` Width of the crop to extract.

          ``height`` int
          :guilabel:`in` Height of the crop to extract.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The extracted region of interest.

      **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 DocumentImage Crop(int left, int top, int width, int height)

      **Parameters**

        .. line-block::

          ``left`` int
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` int
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` int
          :guilabel:`in` Width of the crop to extract.

          ``height`` int
          :guilabel:`in` Height of the crop to extract.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The extracted region of interest.

      **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 DocumentImage crop(int left, int top, int width, int height) throws DocumentException

      **Parameters**

        .. line-block::

          ``left`` int
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` int
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` int
          :guilabel:`in` Width of the crop to extract.

          ``height`` int
          :guilabel:`in` Height of the crop to extract.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The extracted region of interest.

      **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 func crop(left: Int32, top: Int32, width: Int32, height: Int32) throws -> DocumentImage

      **Parameters**

        .. line-block::

          ``left`` Int32
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` Int32
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` Int32
          :guilabel:`in` Width of the crop to extract.

          ``height`` Int32
          :guilabel:`in` Height of the crop to extract.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The extracted region of interest.

      **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_Crop (
            ID3_DOCUMENT_IMAGE hDocumentImage, 
            int left, 
            int top, 
            int width, 
            int height, 
            ID3_DOCUMENT_IMAGE hDocumentImageCrop)

      **Parameters**

        .. line-block::

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

          ``left`` int
          :guilabel:`in` Left bound of the crop to extract.

          ``top`` int
          :guilabel:`in` Top bound of the crop to extract.

          ``width`` int
          :guilabel:`in` Width of the crop to extract.

          ``height`` int
          :guilabel:`in` Height of the crop to extract.

          ``hDocumentImageCrop`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`out` The extracted region of interest.


      **Returns**

        .. line-block::

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


