Skip to content

Question: Cropping to a relative portion of the image (in percents) #384

Description

@Sewdn

Say you want to crop an image to its upper left quadrant. The image should not be resized, only the top-left half of the image (1/4) should be retained. What is the best way to do this?

I understand it is an easy task if the image's dimensions are known beforehand. But what if you would like to skip the extra processing to assess the image's dimensions before cropping (and leave it up to wsrv)?

Is it possible to crop an image to a relative portion of the image, based on a percentage of the original size? Something like cx=0&cy=0&cw=0.5&ch=0.5? In the documentation it looks like you can only give absolute cropping values (in pixels) and would need to know the image dimensions beforehand.

Alignment does support percentage values (or top-left portions), but this is only used when resizing the image and using fit or cover and thus would always resize the image. If you would like to retain the image's ratio, this would always result in a resize without any cropping.

Thanks for your help or suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    completedFeature or request has been completeddocumentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions