Open Munksgaard opened 5 months ago
This would be a good feature to add. I can imagine a flag like crop_after_resize
added to the options struct.
Currently I think it's achievable as a multi-step procedure, by first using Thumbnex to shrink to either a width or height (see this test case), and then cropping it as a second step.
I think that could work, but I'd prefer not having to specify which of the sides (height or width) should be shrunk, and have the command figure it out for me.
I'm having a hard time articulating the exact needs of such a shrink command, perhaps you can help me. Here are some examples of how it should work (in my mind at least):
Those examples make sense. To clarify my comment, I agree that a single operation would be ideal, instead of the multi-step operation that it currently requires.
Assuming we're talking still images, not animated GIFs, there is likely an analogous command in ImageMagick that does similar to the ffmpeg command you posted. My ImageMagick knowledge is very rusty but it's possible the Mogrify wrapper library, which this Thumbnex lib depends on, already has a single command that does the resizing and cropping. If so we'd just need to add an option flag in Thumbnex to use the right command.
I think the following ImageMagick command is equivalent:
magick original.jpeg -thumbnail 180x180^ -gravity center -extent 180x180 output.png
Note that ImageMagick, contrary to ffmpeg, does not by default crop to the middle of the image, so the -gravity center
is important. Likewise, the ^
is important in the thumbnail geometry, since it specifies that magick should preserve the aspect size.
Thank you for making this nifty little library!
I would like to make thumbnails that are exactly the specified size, e.g. 180x180 pixels. I would like to do so in a way that first resizes the image to kinda-fit, and then crops it to the specified size. I've fiddled a bit with ffmpeg, and I believe this command fits my needs:
Is this something you'd be interested in supporting?