Here's the code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>
int main(int argc,char **argv)
{
MagickBooleanType status;
MagickWand *w;
unsigned long n;
char **props, *val;
char *pattern = "*";
int i;
if (argc != 2) exit(1);
MagickWandGenesis();
w = NewMagickWand();
status = MagickReadImage(w, argv[1]);
if (status == MagickFalse) exit(1);
MagickResetIterator(w);
while (MagickNextImage(w) != MagickFalse) {
// list properties for image
printf("IMAGE:\n");
props = MagickGetImageProperties(w, pattern, &n);
for (i = 0; i < n; i++) {
val = MagickGetImageProperty(w, props[i]);
printf(" %20s = %s\n", props[i], val);
MagickRelinquishMemory(val);
}
MagickRelinquishMemory(props);
}
DestroyMagickWand(w);
MagickWandTerminus();
return 0;
}
Code: Select all
IMAGE:
create-date = 2008-04-02T19:02:34+01:00
modify-date = 2008-04-02T19:02:34+01:00
IMAGE:
create-date = 2008-04-02T19:02:34+01:00
label = Lager 1
modify-date = 2008-04-02T19:02:34+01:00
Code: Select all
val = MagickGetImageProperty(w, "8BIM:1998,2998");
printf(" %20s = %s\n", val);
MagickRelinquishMemory(val);
Or I can get a path by name, e.g.:
Code: Select all
val = MagickGetImageProperty(w, "8BIM:1998,2998:Work path 1\n");
printf(" %20s = %s\n", val);
MagickRelinquishMemory(val);
...
To provide some background: I'm looking to convert CS3 PSD/TIF/etc. files to PDFs on OS X while allowing the user to specify a clipping path from the files' existing work/clipping paths. Unfortunately, the standard OS X APIs (Quartz, NSImage, etc.) appear to ignore Photoshop's work/clipping path info when importing the files, so the plan is to get that information separately and then use Quartz to apply the desired clipping path to the bitmap along with any other transformations specified by the user.
IM seems an obvious option for solving the first step (extracting path info), if only I can get it to work. Although if anyone knows of any other low-cost, standalone Tiger/Leopard-compatible solutions for part or all of this task, I'm all ears.
Many thanks,
has
--
[1] Side-note: I notice that using 'identify -verbose ...' in the shell lists the first path found as the clipping path, even if it's just a work path; I suspect this is a bug.