As a simpler partial solution, I propose that kernels should be readable from text files. FileToString() seems suitable for this. The best place to put this seems to be AcquireKernelInfo() in morphology.c.
The following diff (from v6.8.9-6) makes kernels readable from text files.
Code: Select all
--- /home/Alan/imdevsrc/../ImageMagick-6.8.9-6/magick/morphology.c 2014-04-18 02:27:41.000000000 +0100
+++ /home/Alan/imdevsrc/magick/morphology.c 2014-10-30 19:30:37.348558500 +0000
@@ -501,9 +501,30 @@
const char
*p;
+ char
+ *expanded;
+
+ ExceptionInfo
+ exception;
+
+
if (kernel_string == (const char *) NULL)
return(ParseKernelArray(kernel_string));
- p=kernel_string;
+
+ expanded = NULL;
+
+ if (*kernel_string == '@') {
+ printf ("expanding file [%s]\n", kernel_string+1);
+ expanded=FileToString(kernel_string+1,~0UL,&exception);
+ if (expanded == (char *) NULL) {
+ printf ("FileToString failed");
+ return((KernelInfo *) NULL);
+ }
+ printf ("Expanded to [%s]\n", expanded);
+ p=expanded;
+ } else {
+ p=kernel_string;
+ }
kernel=NULL;
while (GetMagickToken(p,NULL,token), *token != '\0')
@@ -538,6 +559,10 @@
break;
p++;
}
+
+ if (expanded != NULL)
+ expanded=DestroyString(expanded);
+
return(kernel);
}