Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Image element should provide better control over its size #4

Closed
MarcinZiabek opened this issue Mar 20, 2021 · 2 comments
Closed
Projects
Milestone

Comments

@MarcinZiabek
Copy link
Member

Is your feature request related to a problem? Please describe.
I want to decide which scaling rule is used in order to display the Image element. Depending on the scenario, the image element should preserve its aspect ratio and fit available width/height/space. There are also cases when the image should be scaled unproportionally.

Currently, the Image element changes its size according to provided rules:

  1. It tries to fit the available space.
  2. It always prevents its aspect ratio.

Describe the solution you'd like
Provide a flag to decide how the image is going to be scaled:

  1. To fit the available width.
  2. To fit the available height.
  3. To fit the available space (both width and height = safest).
  4. To cover provided area without preserving its aspect ratio (also safe but usually not desired).

Additional context
Important: this change needs to be properly documented. There are cases when a selected option may lead to infinite layouts. For example:

// Infinite layout example:

.Width(400) // constrained size: width and height
.Height(200)
.Image(data, ImageScaling.FitWidth); // image width aspect ratio 4x3

// Example 2:
.Row(row => 
{
    row.ConstantColumn(200)
       .Height(300)
       .Image(data, ImageScaling.FitHeight); // image width aspect ratio 4x3
})
@MarcinZiabek MarcinZiabek added this to the 2021.04 milestone Mar 20, 2021
@MarcinZiabek MarcinZiabek added this to Planned in Roadmap via automation Mar 26, 2021
@MarcinZiabek MarcinZiabek changed the title The Image element should provide better control over its size The AspectRatio element should provide better control over its size Mar 26, 2021
@MarcinZiabek MarcinZiabek changed the title The AspectRatio element should provide better control over its size The Image element should provide better control over its size Mar 26, 2021
@MarcinZiabek
Copy link
Member Author

This functionality is ready and planned to be released with QuestPDF 2021.04

Roadmap automation moved this from Planned to Completed Mar 29, 2021
@sokheangkhun
Copy link

How can I achieve image fit to contain. For example, I set container height to 100 and if image width bigger than height it scale height to fit and crop width or I set container width to 100 and image's height bigger than its width. The Image fit the width and crop height.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Roadmap
Completed
Development

No branches or pull requests

2 participants