Nimagemagick
ImageMagick wrapper for Nim (MagickCore/MagickWand)
Install / Use
/learn @zedeus/NimagemagickREADME
nimagemagick
nimagemagick is an ImageMagick 7.0 wrapper for Nim. It wraps the MagickCore and MagickWand APIs, though at this point it's mostly a "thin" wrapper. With time more functions will be covered by the wrapper for a convenient interface. See the current progress in src/nimagemagick.nim
The wrapper gets automatically generated at compile time using the nimterop package, which leverages the tree-sitter project.
Requires ImageMagick 7.0 or later. Run convert -version to check.
Only tested on Linux.
Contributions are welcome.
Installation
nimble install https://github.com/zedeus/nimagemagick.git
Example usage
import nimagemagick
proc main =
# create a new wand, and read the built-in logo image
var wand = newWand("logo:")
wand.resizeImage(200, 200)
wand.displayImage()
# save the image
wand.writeImage("logo.png")
# genesis must be called to setup the MagickWand environment
genesis()
main()
# terminus must be called after the main proc has exited.
# If called inside main, the wands will be destroyed after
# the environment has terminated, leading to a segfault
terminus()
See other examples in the examples folder.
Notes
To use a function from MagickCore/MagickWand that doesn't yet have a
wrapper in wand.nim, ptr MagickWand can be accessed via the impl
field of any Wand object. Here's the example above without the
convenience wrappers:
import nimagemagick
proc main =
var wand = newWand()
discard MagickReadImage(wand.impl, "logo:")
discard MagickResizeImage(wand.impl, 200, 200, LanczosFilter)
discard MagickDisplayImage(wand.impl, "")
MagickWandGenesis()
main()
MagickWandTerminus()
If you don't want to use the Wand object, replace newWand() with
NewMagickWand(), and remember to call DestroyMagickWand(wand).
Related Skills
node-connect
341.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
