0

I've been searching for a way to use the vignette functionality of ImageMagick with Wand, but I can't find how to do it in Wand's documentation.

Is there a well hidden way to do it, and if there isn't, what are the alternatives ?

2 Answers2

2

For python's library, you'll need to implement the C-API with library.api module.

import ctypes
from wand.api import library
from wand.image import Image

# Define C-API
library.MagickVignetteImage.argtypes = [ctypes.c_void_p,  # Wand
                                        ctypes.c_double,  # Radius
                                        ctypes.c_double,  # Sigma
                                        ctypes.c_long,    # x
                                        ctypes.c_long]    # y
# Warning: `x' & `y' are ssize_t. Usually the same size as size_t, or long type.

# Extent Image class with new method
class VignetteImage(Image):
    def vignette(self, radius=0.0, sigma=0.0, offset_x=0, offset_y=0):
        library.MagickVignetteImage(self.wand,
                                    radius,
                                    sigma,
                                    offset_x,
                                    offset_y)

# Usage
with VignetteImage(filename="rose:") as rose:
    rose.vignette(0.0, 5.0)
    rose.save(filename="RoseVignette.png")
emcconville
  • 23,800
  • 4
  • 50
  • 66
0

See http://www.imagemagick.org/api/magick-image.php#MagickVignetteImage in the ImageMagick Wand documentation

Sorry, I do not code in MagickWand or any other API. I assume you just could not find the documentation for vignette.

OOPS! I see you want a different Wand. Sorry, I cannot help with that. I do not see anything but drawing in your Wand documentation.

What language alternative are you looking for? You can do it directly in ImageMagick (likely PythonMagick).

See also opencv, python and numpy vignette at https://www.packtpub.com/mapt/book/application_development/9781785283932/2/ch02lvl1sec25/creating-a-vignette-filter

See also https://github.com/alexjohnson505/image-filter/blob/master/image-filter.py

See also https://imagepy.wordpress.com/2015/11/21/raw-image-processing-in-python-an-example/

fmw42
  • 46,825
  • 10
  • 62
  • 80