Image conversion without resizing

If I want to convert an image from BMP to JPG without resizing, this is the only approach I know of:

{{ $i := resources.Get "image.bmp" }}
{{ $resizeOptions := printf "%dx%d jpg" $i.Width $i.Height }}
{{ $i = $i.Resize $resizeOptions }}

Is there a better way?

1 Like

Currently no, but I have thought about adding a Convert method.

While the body’s open, how about a Rotate method as well?

Well, you could imagine:

{{ $img = $img.Convert "webp r90" }}
{{ $img = $img.Convert "r90" }}

As in Convert does no scaling, but allows “all the other keywords”.

4 Likes

Perfect.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.