h2non / bimg

Go package for fast high-level image processing powered by libvips C library
https://pkg.go.dev/github.com/h2non/bimg?tab=doc
MIT License
2.68k stars 337 forks source link

Add TrimBackground as an argument + go.mod + fix pointer bug [Proposal] #382

Open angelo-hub opened 2 years ago

angelo-hub commented 2 years ago
  1. Use case: when using Vips_find_trim (for the Trim: true the last argument is the "background" and any alpha channel is looked at as the background argument. In this case you may want to keep the alpha channel but pass it an argument that's a bright easily edge-able color (similar to a green screen). When using the regular Background argument in this case it will flatten alpha channels to that background color when we want to keep alpha channel transparency. [Added in a way that maintains backwards compatibility with the existing API]

  2. adds unit testing for this new options

  3. adds a trim padding option to allow

  4. this also removes a unset pointer that was causing crashes when running trim operations at 30 RPS

  5. add go.mod for modern module support

I can and would break these out into different branches and you guys can pick which features if any you want out of them but I'd highly recommend merging 1,2 and 4. 3 is more of a nice to have feature for our use case.

angelo-hub commented 2 years ago

I know this is stale, we're working through some stuff internally with our version of imaginary, once we've wrapped up, can update this proposal/PR