Skip to content

image->size with disabled upscaling -> wrong aspect ratio #628

@thomasaull

Description

@thomasaull

Short description of the issue

Default Image field with one image with Dimensions of 1200x1400 px (Width x Height). In my template I'm exporting this image in different resolutions to use it as an responsive image but with a fixed aspect ratio of 16:9

$options = ['upscaling' => false];
$image->size(1920, 1080, $options);
$image->size(960, 540, $options);
$image->size(480, 270, $options);

Expected behavior

Images which are to small in dimensions for the target image size should still maintain the expected aspect ratio. The two smaller images can be cropped without problems, the larger image would have to be upscaled to meet the required dimensions (which is disabled). I would expect this image to have dimensions of 1200x675 (crop to maximum possible dimensions without upscaling but still maintain the aspect ratio of 16:9)

Actual behavior

The image just uses the original dimensions as a maximum independently. The image with a target size of 1920x1080 gets cropped to 1200x1080. So I end up with the two smaller images in the correct aspect ratio of 16:9 and with the largest image with a completely arbitrary aspect ratio.

Setup/Environment

  • ProcessWire version: 3.0.105

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions