
Show HN: Snowy – a new image library for Python - prideout
https://github.prideout.net/snowy/
======
noobermin
Massive opinionated opinion ahead: I like libraries that don't invent new
types but just build around established ones. I think it's great that it uses
numpy arrays and doesn't venture to (essentially) wrap an array of some kind
and reinvent the wheel.

~~~
prideout
Yes, I'm happy with this design decision. The only bummer is that it doesn't
allow daisy-chaining, as in:

    
    
        img = img.resize(...).blur(....).hflip()

~~~
Sileni
I always regret writing those lines when I come back to them anyway. Any time
I try to refactor them I throw something out of order or drop a function.

That said, I don't claim to be a clever man.

~~~
prestonh
What is the alternative besides chaining, devise a new variable name for every
operation? I understand that daisy chaining can be error prone, but the
alternative is so difficult to maintain in long chains.

~~~
jacobolus
If the object is modified in place (as it seems to be in this case), then the
“pythonic” approach is:

    
    
       img = ...
       img.resize(...)
       img.blur(....)
       img.hflip()

------
ktpsns
Something I would miss as a user is interoperability. There should be ways to
read from/export to numpy arrays, pytables, PIL, OpenCV, ImageMagick,
basically all the mentioned and widespread libraries so far.

(Edit: There is in fact:
[https://github.prideout.net/snowy/reference.html#load](https://github.prideout.net/snowy/reference.html#load)
, haven't noticed, very good!)

~~~
prideout
Understood. Maybe it helps that Snowy does not define an Image object, instead
it simply operates on numpy arrays.

See also
[https://github.prideout.net/snowy/index.html#interop](https://github.prideout.net/snowy/index.html#interop)

------
jhare
What's the overlap with ImageMagick and its pals? This meant to replace or
just be a smaller-tool-for-the-job?

~~~
prideout
Smaller tool, not a replacement.

ImageMagick is much bigger, more powerful, and more production ready. Snowy is
hopefully a bit more Pythonic and easy to play with.

~~~
bobosha
so, who is your target audience? The just getting started developer?

~~~
prideout
It's a small target audience :)

I think graphics developers like myself would be interested; people who work
with distance fields, tileable images, HDR imagery, and height map data.

Maybe a technical artist at an animation studio would be interested, or
someone working with map imagery.

------
staticautomatic
Neat. How does it benchmark against PIL and OpenCV for common image processing
tasks?

~~~
prideout
Not as fast as PIL but has reasonable optimizations like performing
convolution in two passes, caching filter weights from row to row, and using
numba decorations.

It's not quite apples to apples because Snowy offers a variety of filters,
does everything in fp64, and is purely written in Python.

~~~
nine_k
"Purely" meaning it does not _add_ any C code; it still very actively uses
numpy.

------
firefwing24
Under Alpha Composition

    
    
      icon = snowy.load('snowflake.png')
      icon = snow.resize(snowflake, height=100)
      sunset[:100,200:300] = snowy.compose(sunset[:100,200:300], icon)
      snowy.show(sunset)
    

Pretty sure you meant to say on line 2 `icon = snowy.resize(icon, height=100)`

~~~
prideout
Thanks, this is fixed now.

------
supernintendo
Well done! Some commenters have compared this to ImageMagick. I would equate
this to comparing love2d [1] to SDL. If you want a user-friendly API for quick
image manipulation, use Snowy. If Snowy doesn't give you the level of control
you need, use something like ImageMagick or vips.

I could see myself using this in the future.

[1] [https://love2d.org/](https://love2d.org/)

------
Sileni
Would you mind defining a primary use case for this as opposed to PIL,
ImageMagick or OpenCV? For the purposes of saving a description with the
website.

~~~
prideout
High-quality filtering of floating-point image data.

