Giter VIP home page Giter VIP logo

magickwand-crystal's Introduction

MagickWand for Crystal - PROJECT UNMAINTAINED

This project is not maintained anymore

If you like it or continue to use it fork it please.



Crystal C bindings for MagickWand library, an interface to use the ImageMagick image processing libraries - see www.imagemagick.org

NOTE: Base on ImageMagick-7.0.8-66. MagickWand is a quite large library, if you find something missing contact me

Requirements

  • libMagickWand must be installed
  • pkg-config must be available

Installation

  • Add this to your application's shard.yml:
dependencies:
  magickwand-crystal:
    github: blocknotes/magickwand-crystal

Usage

Get image info:

require "magickwand-crystal"
LibMagick.magickWandGenesis    # lib init
wand = LibMagick.newMagickWand # lib init
if LibMagick.magickReadImage( wand, "test.png" )
  puts LibMagick.magickGetImageWidth wand
  puts LibMagick.magickGetImageHeight wand
end
LibMagick.destroyMagickWand wand  # lib deinit
LibMagick.magickWandTerminus      # lib deinit

Scale image and save in Jpeg format:

require "magickwand-crystal"
# ... lib init ...
LibMagick.magickReadImage wand, "test.png"
LibMagick.magickScaleImage wand, 320, 240
LibMagick.magickWriteImage wand, "test2.jpg"
# ... lib deinit ...

Convert to grayscale:

require "magickwand-crystal"
# ... lib init ...
LibMagick.magickReadImage wand, "test.jpg"
LibMagick.magickTransformImageColorspace wand, LibMagick::ColorspaceType::GRAYColorspace
LibMagick.magickWriteImage wand, "grayscale.jpg"
# ... lib deinit ...

More examples

See examples folder. There is also an example to generate an image on the fly with Kemal.

Documentation

The functions mapped have the same names of the MagickWand C library but with the first letter in lowercase.

Example: MagickWandGenesis => LibMagick.magickWandGenesis

Notes

Branches with different ImageMagick version:

  • im_6.9.7-3
  • im_7.0.4-1

The Crystal Magic Wand ! :)

Sounds funny but I hope you find it a useful piece of software.

Contributors

magickwand-crystal's People

Contributors

blocknotes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

magickwand-crystal's Issues

Quality setting alongside AVIF / JXL has no effect

Using Imagemagick 7.1.1 (latest in Fedora 38) and 0.3 of this lib

Convert an image (jpg) to webp quality 10 and 90, the filesize is as expected, eg
51K Jun 14 15:22 test_10.webp
284K Jun 14 15:22 test_90.webp

However, repeat the same test with AVIF
91K Jun 14 15:22 test_10.avif
91K Jun 14 15:22 test_90.avif

If I use magick convert .avif - I get the same 91k, so looks like the quality is getting dropped and using the default.

Crystal Convention for Methods

Hey @blocknotes

Thanks a lot for this library. I saw that the method names aren't snake cased and were like newMagickWand.

In Crystal (also in Ruby) is to follow snake cases in method and variable names. So newMagickWand should be new_magick_wand.

WDYT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.