summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Wey2011-07-10 23:40:58 +0200
committerMike Wey2011-07-10 23:40:58 +0200
commit5998d6ab64d27812ca5d1bc8cc90a5c7ba42d3c2 (patch)
tree4fa1462f15dfb505fa10fb36f56d9cb424c367fe
parentc93b37fa592d7578ecbc1fa0ced629e0ca80b78c (diff)
Add ping, polaroid, posterize, preview and process.
-rw-r--r--GNUmakefile8
-rw-r--r--dmagick/Image.d94
2 files changed, 101 insertions, 1 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 10b3bec..54a1824 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -43,6 +43,12 @@ endif
AR=ar
RANLIB=ranlib
+QUANTUMDEPTH = $(lastword $(shell MagickCore-config --version))
+
+ifneq ("$(QUANTUMDEPTH)","Q16")
+ DCFLAGS+= -version=$(subst Q,Quantum,$(QUANTUMDEPTH))
+endif
+
#######################################################################
LIBNAME_DMAGICK = libdmagick.a
@@ -71,7 +77,7 @@ $(LIBNAME_DMAGICK): $(OBJECTS_DMAGICK)
$(shell echo "void main(){}" > /tmp/stubmain.d)
unittest: /tmp/stubmain.d $(SOURCES_DMAGICK)
- $(DC) $(DCFLAGS) $(UNITTESTFLAG) $(LINKERFLAG)-lMagickCore $(SOURCES_DMAGICK) $< $(output)
+ $(DC) $(DCFLAGS) $(UNITTESTFLAG) $(LINKERFLAG)-lMagickCore $^ $(output)
./$@
#######################################################################
diff --git a/dmagick/Image.d b/dmagick/Image.d
index 09572e7..fb35cc1 100644
--- a/dmagick/Image.d
+++ b/dmagick/Image.d
@@ -1933,6 +1933,99 @@ class Image
}
/**
+ * Ping is similar to read except only enough of the image is read to
+ * determine the image columns, rows, and filesize. The columns, rows,
+ * and fileSize attributes are valid after invoking ping.
+ * The image data is not valid after calling ping.
+ */
+ void ping(string filename)
+ {
+ options.filename = filename;
+
+ MagickCoreImage* image = PingImages(options.imageInfo, DMagickExceptionInfo());
+
+ imageRef = ImageRef(image);
+ }
+
+ ///ditto
+ void ping(void[] blob)
+ {
+ MagickCoreImage* image =
+ PingBlob(options.imageInfo, blob.ptr, blob.length, DMagickExceptionInfo());
+
+ imageRef = ImageRef(image);
+ }
+
+ /**
+ * Produce an image that looks like a Polaroid® instant picture.
+ * If the image has a "Caption" property, the value is used as a caption.
+ *
+ * Params:
+ * angle = The resulting image is rotated by this amount,
+ * measured in degrees.
+ */
+ void polaroid(double angle)
+ {
+ MagickCoreImage* image =
+ PolaroidImage(imageRef, options.drawInfo, angle, DMagickExceptionInfo());
+
+ imageRef = ImageRef(image);
+ }
+
+ /**
+ * Reduces the image to a limited number of colors for a "poster" effect.
+ *
+ * Params:
+ * levels = Number of color levels allowed in each channel.
+ * Very low values (2, 3, or 4) have the most
+ * visible effect.
+ * dither = If true, dither the image.
+ */
+ void posterize(size_t levels = 4, bool dither = false)
+ {
+ PosterizeImage(imageRef, levels, dither);
+ DMagickException.throwException(&(imageRef.exception));
+ }
+
+ /**
+ * Creates an image that contains 9 small versions of the receiver
+ * image. The center image is the unchanged receiver. The other 8
+ * images are variations created by transforming the receiver according
+ * to the specified preview type with varying parameters.
+ *
+ * A preview image is an easy way to "try out" a transformation method.
+ */
+ Image preview(PreviewType preview)
+ {
+ MagickCoreImage* image =
+ PreviewImage(imageRef, preview, DMagickExceptionInfo());
+
+ return new Image(image, options.clone());
+ }
+
+ /**
+ * Execute the named process module, passing any arguments arguments.
+ * An exception is thrown if the requested process module does not exist,
+ * fails to load, or fails during execution.
+ *
+ * Params:
+ * name = The name of a module.
+ * arguments = The arguments to pass to the module.
+ */
+ void process(string name, string[] arguments)
+ {
+ MagickCoreImage* image = imageRef;
+ const(char)*[] args = new char*[arguments.length];
+
+ foreach( i, arg; arguments )
+ args[i] = toStringz(arg);
+
+ InvokeDynamicImageFilter(toStringz(mod), &image, cast(int)args.length, args.ptr, DMagickExceptionInfo());
+
+ imageRef = ImageRef(image);
+ }
+
+ /**
* Read an Image by reading from the file or
* URL specified by filename.
*/
@@ -3100,6 +3193,7 @@ class Image
//Should we implement these as actual properties?
//attribute
//comment
+ //caption
//label
//signature