-
Notifications
You must be signed in to change notification settings - Fork 62
-
The Image#max
method isn't intuitive in Ruby.
(byebug) joined.max
349359.7355973516
(byebug) joined.max(size: 5)
349359.7355973516
(byebug) joined.max(x: true, y: true)
[349359.7355973516, {"x"=>1271, "y"=>720}]
(byebug) joined.max(size: 5, x: true, y: true)
[349359.7355973516, {"x"=>1271, "y"=>720}]
Only after checking the libvips docs I've realised it's because of how you are supposed to code in C where you allocate the array and give it to fill.
(byebug) joined.max(size: 5, x: true, y: true, out_array: [])
[349359.7355973516, {"x"=>1271, "y"=>720, "out_array"=>[21686.8706957009, 348422.8158518145, 349093.1501689977, 349098.8357107653, 349359.7355973516]}]
I propose to remove the array args and build them for user if he has passed size
or x
, resulting in return value for the example above not:
[
349359.7355973516,
{"x"=>1271, "y"=>720,
"out_array"=>[21686.8706957009, 348422.8158518145, 349093.1501689977, 349098.8357107653, 349359.7355973516]
}
]
but either of these:
{
"out_array"=>[21686.8706957009, 348422.8158518145, ...],
"x_array"=>[1271, 1300, ...],
...
]
{
out_array: [21686.8706957009, 348422.8158518145, ...],
x_array: [1271, 1300, ...],
...
]
[
[21686.8706957009, {"x"=>1271, "y"=>720}],
[348422.8158518145, {"x"=>1300, "y"=>800}],
...
]
[
[21686.8706957009, {x: 1271, y: 720}],
[348422.8158518145, {x: 1300, y: 800}],
...
]
[
{value: 21686.8706957009, x: 1271, y: 720},
{value: 348422.8158518145, x: 1300, y: 800},
...
]
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment