Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposal to change the Image#max/min return value format when additional args are passed #289

Nakilon started this conversation in Ideas
Discussion options

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},
 ...
]
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /