You'll have to deal with them for now, as the Nim ecosystem is not that big
yet. It's not too hard to provide abstractions for cstrings, as Nim's string
can be converted implicitly to them.
If you're on Linux, `gdk-pixbuf` is a viable choice (bindings provided by
gintro package). Here's a CLI tool that flip and rotate an image of choice.
import os, parseopt
import gintro / gdkpixbuf
var
filename: string
output: string
for kind, key, val in getopt():
case kind
of cmdArgument:
filename = key
of cmdLongOption, cmdShortOption:
case key
of "o", "output":
output = val
else: discard
if filename.len < 1:
quit "No file specified"
if output.len < 1:
output = filename.changeFileExt "modified.png"
let outputType = output[output.searchExtPos + 1..^1]
if outputType.len < 1:
quit "Invalid output type"
var pix = newPixbufFromFile filename
pix = pix.flip true
pix = pix.rotateSimple PixbufRotation.counterclockwise
discard pix.savev(output, outputType, [])
Run