https://kotlinlang.org logo
#ktor
Title
# ktor
j

Jonas Ørting

07/20/2019, 5:50 PM
Hi I need to do some basic image processing on the server (scale, crop). Is there a kotlin library for that? If not, what would be the recommended Java library? (I've never worked with Java, and I'm having a hard time figuring out what current best practice is)
d

dave

07/20/2019, 6:21 PM
every time I’ve had to do this kind of thing (and because requirements will probably grow over time), I’ve fallen back on something that wraps ImageMagick... and it turns out that the easiest thing here is to actually use the python bindings (probably Wand). Writing a basic image server in python is actually pretty simple.
I realise that’s not going to be a popular opinion here on this slack 😉, but right tool for the right job etc (Jmagick wasn’t up to the job last time I did it).
j

Jonas Ørting

07/20/2019, 6:27 PM
I was hoping to not have to do that :D Is there a reason you'd user python bindings instead of Java?
I've mainly done python previously, and half my motivation for learning kotlin was doing not-python, so even if your suggestion is sensible I'll jump through some hoops to avoid it :)
d

dave

07/20/2019, 8:41 PM
In general, we fall back on the "use a python server as an image server" pattern - it allows for a more judicious use of caching layers than attempting to utilise a general API server for the same thing. Of course JMMV 😉
r

rocketraman

07/22/2019, 6:39 PM
You could look into im4java for ImageMagick bindings on the JVM. You could also look at the Java Advanced Imaging API as an alternative (though this hasn't been updated in 12 years, so...).
None of these are Kotlin of course, but you shouldn't let that stop you...
This project purports to be a replacement for Oracle's JAI, and their GitHub repo seems to be somewhat active: https://www.geo-solutions.it/blog/developers-corner-jai-ext-the-open-source-replacement-for-oracle-jai/
j

Jonas Ørting

07/22/2019, 10:36 PM
Maybe i should just use something like https://github.com/imazen/imageflow/ - has a server with a rest endpoint to transform images. Using http should keep everything nice and kotlin-y
r

rocketraman

07/22/2019, 10:40 PM
Nice find. Looks like a basic self-hosted open source Cloudinary clone. Cool.
6 Views