Add ability to specify target size in "number of pixels" #5082
clairem-sl
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
|
Hi @clairem-sl, We could perhaps implement more of imagemagick's size specifications: https://imagemagick.org/command-line-processing/#geometry&gsc.tab=0 They use the syntax: ie. appending
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For reasons beyond my control, I am sometimes required to submit images "less than N megapixels in total pixels size"
Because the images I need to submit oftentimes do NOT have uniform aspect ratio, currently I have to manually calculate the proper bounding box for each image I want to submit:
In pseudo-code:
I think it will be great to add a new option, let's say
--size-mp M, or--size-pixels P, whereinvipsthumbnailwill perform all the necessary scaling calculation above internally per processed file.Example usages
(Maybe limit the suffixes for
--size-pixelstoK,M, and maaaybeG. I don't think anyone will want terapixel-sized images.)Optionally, for
--size_pixelsshould also be able to ignore_(underscore) inserted for visiblity, e.g.:Of course the desired number of pixels is 'approximately'; depending on the ratio between width and height, an exact number might be impossible to achieve. But using the formula in the pseudocode above, a 'reasonably accurate' number should be achievable. If the "number of pixels limit" is a hard limit, and the calculation method has the possibility of doing a rounding up, it will be the responsibility of the user to target a smaller pixel-size. E.g.
--size-pixels 9_800Kor--size-mp 9if the hard limit is exactly 10 million pixels and not a single pixel more.And finally, this option definitely conflicts with
--size; so if both are specified, an error should be raised.Beta Was this translation helpful? Give feedback.
All reactions