Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# DocumentImage.downscaleTo Method

Module: DocumentImage

## Definition

Downscales the image so that its maximum dimension equals the given maximum size, while preserving the aspect ratio.

Note

If the maximum dimension is already smaller than the given maximum size, the function does nothing and the returned scale ratio is 1.

Python

    downscale_to(self, dst_document_image: DocumentImage, max_size: int) -> float

Parameters

> `dst_document_image` DocumentImage
> in Destination image.
> `max_size` int
> in Maximum image size, in pixels. The value must be greater than 0.

Returns

> `float`
> The scaling ratio applied to the image. Range is ]0:1].

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Dart

    double downscaleTo(DocumentImage dstDocumentImage, int maxSize)

Parameters

> `dstDocumentImage` DocumentImage
> in Destination image.
> `maxSize` int
> in Maximum image size, in pixels. The value must be greater than 0.

Returns

> `double`
> The scaling ratio applied to the image. Range is ]0:1].

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

C#

    public float DownscaleTo(DocumentImage dstDocumentImage, int maxSize)

Parameters

> `dstDocumentImage` DocumentImage
> in Destination image.
> `maxSize` int
> in Maximum image size, in pixels. The value must be greater than 0.

Returns

> `float`
> The scaling ratio applied to the image. Range is ]0:1].

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Java

    public float downscaleTo(DocumentImage dstDocumentImage, int maxSize) throws DocumentException

Parameters

> `dstDocumentImage` DocumentImage
> in Destination image.
> `maxSize` int
> in Maximum image size, in pixels. The value must be greater than 0.

Returns

> `float`
> The scaling ratio applied to the image. Range is ]0:1].

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Swift

    public func downscaleTo(dstDocumentImage: DocumentImage, maxSize: Int32) throws -> Float

Parameters

> `dstDocumentImage` DocumentImage
> in Destination image.
> `maxSize` Int32
> in Maximum image size, in pixels. The value must be greater than 0.

Returns

> `Float`
> The scaling ratio applied to the image. Range is ]0:1].

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

C

    int id3DocumentImage_DownscaleTo (
        ID3_DOCUMENT_IMAGE hDocumentImage,
        ID3_DOCUMENT_IMAGE hDstDocumentImage,
        int maxSize,
        float * scaleRatio)

Parameters

> `hDocumentImage` ID3_DOCUMENT_IMAGE
> in Handle to the DocumentImage object.
> `hDstDocumentImage` ID3_DOCUMENT_IMAGE
> in Destination image.
> `maxSize` int
> in Maximum image size, in pixels. The value must be greater than 0.
> `scaleRatio` float *
> out The scaling ratio applied to the image. Range is ]0:1].

Returns

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