Skip to content

Divisor should be double instead of integer #27

@pnoyens

Description

@pnoyens

With the current implementation of Thumbnail.cs in the master branch, the division yielding var divisor returns an integer when in fact, a double precision number should be used. When running the code as is, aspect ratios for images are incorrect after processing. E.g. when divisor should be 1.6, a value of 1 will be returned. Same goes for divisor that should be 0.4, a value of 0 will be returned which in the end results in a "Divide by 0" exception to be thrown.

I've solved this in a forked version to explicitly cast one of the factors in the division to a double, like this:

var divisor = image.Width / (double)thumbnailWidth;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions