I'm building a Kitura web application, and I need the ability to process user uploaded images.
I have an instance of Foundation's Data
, and I'd like to do the following without using any Cocoa libraries/frameworks (other than Foundation):
Data
is a valid image file.png
How would I do this? I'm fine with using third party libraries / frameworks as long as they work on Linux.
You should use SwiftGD - a wrapper for libgd. It supports all the operations you require: https://github.com/twostraws/SwiftGD
The only thing it doesn't support directly is reading an image from an in-memory Data instance. You'll need to write it to a temporary file and instantiate from there.
I can't vouch for the Swift wrapper itself, which seems to be brand new, but I've used libgd on other platforms and I haven't had any problems.
Another interesting one that I came across is: https://github.com/BradLarson/GPUImage2
I've used the original GPUImage and it is awesome. This new version supports Linux, but it doesn't sound like it's very polished on that platform yet. It also may require a GPU, which could definitely be a problem depending on your end goal.
In the short-term, SwiftGD seems like your best bet.