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

Add alignment or left field to image properties #445

Open
AntoninHuaut opened this issue May 31, 2024 · 3 comments
Open

Add alignment or left field to image properties #445

AntoninHuaut opened this issue May 31, 2024 · 3 comments

Comments

@AntoninHuaut
Copy link

Hey thanks you for your library, I have a feature request.

Is your feature request related to a problem? Please describe.
I would like to have the possibility to have the Align field like text on image. Or it's not possible, the right field like the existing left field.

Describe the solution you'd like

image.NewFromBytes(imageBytes, extension.Png, props.Rect{
    Align: align.Right,
})

or

image.NewFromBytes(imageBytes, extension.Png, props.Rect{
    Right: 5,
})

Describe alternatives you've considered
Use the left option, but if the image width is variable, it's not a viable solution, because it can overflow to the right

Additional context
I'm using :

  • row
    • col 6
      • text
    • col 6
      • text or image

image

@johnfercher
Copy link
Owner

Currently is possible to put the image in any local of a col. As you can see here: https://maroto.io/#/v2/features/image?id=image

@johnfercher
Copy link
Owner

props.Rect{
        Center:  false,
        Percent: 80,
        Top:     5,
        Left:    10, // move here
}

@AntoninHuaut
Copy link
Author

My image can be different, with a variable width, but I found something like that:

imgWidth := float64(img.Width) * lineHeight / imgHeight
...
props.Rect {
  Left: 41 - imgWidth
}

Just a random magic value '41', but I tried different images and it's always well aligned to the right. It does the job

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

No branches or pull requests

2 participants