.. index:: 
  !PortraitProcessor.cropPortrait Method
  
.. _id3_face_portrait_processor_crop_portrait_class_method:

===============================================================================
PortraitProcessor.cropPortrait Method
===============================================================================

Module: :ref:`PortraitProcessor<id3_face_portrait_processor_class>`

Definition
----------

Creates a portrait image by cropping the source image around the detected face.


.. tab-set::

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

      .. code:: Python

        crop_portrait(self, portrait: Portrait) -> Image

      **Parameters**

        .. line-block::

          ``portrait`` :ref:`Portrait<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output cropped image of the face.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Dart

        Image cropPortrait(Portrait portrait)

      **Parameters**

        .. line-block::

          ``portrait`` :ref:`Portrait<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output cropped image of the face.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: C#

        public Image CropPortrait(Portrait portrait)

      **Parameters**

        .. line-block::

          ``portrait`` :ref:`Portrait<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output cropped image of the face.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Java

        public Image cropPortrait(Portrait portrait) throws FaceException

      **Parameters**

        .. line-block::

          ``portrait`` :ref:`Portrait<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output cropped image of the face.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Swift

        public func cropPortrait(portrait: Portrait) throws -> Image

      **Parameters**

        .. line-block::

          ``portrait`` :ref:`Portrait<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output cropped image of the face.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: C

        int id3FacePortraitProcessor_CropPortrait (
            ID3_FACE_PORTRAIT_PROCESSOR hPortraitProcessor, 
            ID3_FACE_PORTRAIT hPortrait, 
            ID3_FACE_IMAGE hImage)

      **Parameters**

        .. line-block::

          ``hPortraitProcessor`` :ref:`ID3_FACE_PORTRAIT_PROCESSOR<id3_face_portrait_processor_class>`
          :guilabel:`in` Handle to the PortraitProcessor object.

          ``hPortrait`` :ref:`ID3_FACE_PORTRAIT<id3_face_portrait_class>`
          :guilabel:`in` The portrait to extract the face from.

          ``hImage`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`out` The output cropped image of the face.


      **Returns**

        .. line-block::

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


