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.
Open ViewController. swift and create an outlet with name imageView of type UIImageView! , an implicitly unwrapped optional. The idea is simple. The view controller downloads an image from a URL and displays it in its image view.
An object that manages image data in your app.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With