summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Wey2011-03-27 23:29:00 +0200
committerMike Wey2011-03-27 23:29:00 +0200
commita2cc5f1844b0e71a7ea68b0d2d4207897ae471df (patch)
tree347b7f93a3edee79b3d62bced088b8e674052d77
parentd19cf7bc14c589e2da57b97f533af53c5ab1ccad (diff)
Some more image properties
-rw-r--r--dmagick/Image.d75
-rw-r--r--dmagick/Options.d40
2 files changed, 114 insertions, 1 deletions
diff --git a/dmagick/Image.d b/dmagick/Image.d
index 86b969b..d644699 100644
--- a/dmagick/Image.d
+++ b/dmagick/Image.d
@@ -6,6 +6,8 @@
module dmagick.Image;
+import std.conv;
+import std.math;
import std.string;
import core.sys.posix.sys.types;
@@ -20,6 +22,8 @@ import dmagick.c.blob;
import dmagick.c.constitute;
import dmagick.c.colormap;
import dmagick.c.colorspace;
+import dmagick.c.composite;
+import dmagick.c.compress;
import dmagick.c.effect;
import dmagick.c.exception;
import dmagick.c.geometry;
@@ -27,6 +31,7 @@ import dmagick.c.image;
import dmagick.c.magickType;
import dmagick.c.memory;
import dmagick.c.pixel;
+import dmagick.c.quantum;
import dmagick.c.resize;
import dmagick.c.resource;
@@ -551,6 +556,8 @@ class Image
void colorspace(ColorspaceType type)
{
TransformImageColorspace(imageRef, type);
+
+ options.colorspace = type;
}
ColorspaceType colorspace() const
{
@@ -562,6 +569,74 @@ class Image
return imageRef.columns;
}
+ void compose(CompositeOperator op)
+ {
+ imageRef.compose = op;
+ }
+ CompositeOperator compose() const
+ {
+ return imageRef.compose;
+ }
+
+ void compression(CompressionType type)
+ {
+ imageRef.compression = type;
+ options.compression = type;
+ }
+ CompressionType compression() const
+ {
+ return imageRef.compression;
+ }
+
+ void density(Geometry value)
+ {
+ options.density = value;
+
+ imageRef.x_resolution = value.width;
+ imageRef.y_resolution = ( value.width != 0 ) ? value.width : value.height;
+ }
+ Geometry density() const
+ {
+ ssize_t width = 72;
+ ssize_t height = 72;
+
+ if ( imageRef.x_resolution > 0 )
+ width = cast(ssize_t)rndtol(imageRef.x_resolution);
+
+ if ( imageRef.y_resolution > 0 )
+ height = cast(ssize_t)rndtol(imageRef.y_resolution);
+
+ return Geometry(width, height);
+ }
+
+ void depth(size_t value)
+ {
+ if ( value > MagickQuantumDepth)
+ value = MagickQuantumDepth;
+
+ imageRef.depth = value;
+ options.depth = value;
+ }
+ size_t depth() const
+ {
+ return imageRef.depth;
+ }
+
+ string directory() const
+ {
+ return to!(string)(imageRef.directory);
+ }
+
+ void endian(EndianType type)
+ {
+ imageRef.endian = type;
+ options.endian = type;
+ }
+ EndianType endian() const
+ {
+ return imageRef.endian;
+ }
+
/**
* Colors within this distance are considered equal.
* A number of algorithms search for a target color.
diff --git a/dmagick/Options.d b/dmagick/Options.d
index cc41950..1745b64 100644
--- a/dmagick/Options.d
+++ b/dmagick/Options.d
@@ -10,6 +10,7 @@ module dmagick.Options;
import std.conv;
import std.math;
+import std.string;
import core.stdc.stdio;
import core.stdc.string;
@@ -27,6 +28,7 @@ import dmagick.c.image;
import dmagick.c.list;
import dmagick.c.magickType;
import dmagick.c.memory;
+import dmagick.c.option;
import dmagick.c.quantize;
import dmagick.c.quantum;
@@ -138,7 +140,7 @@ class Options
}
/**
- * Set the image border color. The default is "#dfdfdf".
+ * Specifies the image pixel interpretation.
*/
void colorspace(ColorspaceType space)
{
@@ -178,6 +180,42 @@ class Options
//}
/**
+ * Define an option. Use this method to set options for
+ * reading or writing certain image formats. The list of
+ * supported options changes from release to release.
+ * For a list of the valid image formats, keys, and values,
+ * refer to the documentation for the -define option for the
+ * release of ImageMagick installed on your system.
+ * Params:
+ * format = An image format name such as "ps" or "tiff".
+ * key = A string that identifies the option.
+ * vaule = The value of the option.
+ */
+ void define(string format, string key, string value = "")
+ {
+ string option = format ~":"~ key ~ "\0";
+
+ SetImageOption(imageInfo, option.ptr, toStringz(value));
+ }
+
+ //TODO: opindex / opiindexassign for the options.
+
+ /**
+ * Delete an option definition set by define.
+ * This is not the same as setting the option to a null value.
+ * The undefine method removes the option name from the list
+ * of options for the specified format.
+ * format = An image format name such as "ps" or "tiff".
+ * key = A string that identifies the option.
+ */
+ void undefine(string format, string key)
+ {
+ string option = format ~":"~ key ~ "\0";
+
+ DeleteImageOption(imageInfo, option.ptr);
+ }
+
+ /**
* Specifies the vertical and horizontal resolution in pixels.
* The default _density is "72.0x72.0". This attribute can be used
* when writing JBIG, PCL, PS, PS2, and PS3 format images.