Julia implementation of IDL's rebin?


I am looking for the Julia equivalent of IDL’s rebin function. It basically applies a reduction function f to “macro-cells” of an array. For example, a (M₁ * N₁, M₂ * N₂, …, Mₚ * Nₚ) array, x would be transformed into a (N₁, N₂, …, Nₚ) array, y, where each cell of y is the result of applying f to a sub-array of x

y[i₁, i₂, …, iₚ] = f(x[s₁, s₂, …, sₚ]),

where sₖ is the following slice (hope I didn’t get indices wrong!)

sₖ = (iₖ * Nₖ):((iₖ+1) * Nₖ).

For strided arrays, this is quite easily achieved using a little bit of stride magic. I proposed a Python implementation of fiew years ago : https://github.com/sbrisard/rebin, based on the discussion presented here. Since then, another implementation has been published: pydl.rebin, which is probably more robust.

My question is: is there a Julia equivalent for this (extremely useful) function?

Thanks in advance!