convert source.jpg %%d.jpg
would be the way to go, however, this produces an output file called "%%d.jpg", not "%d.jpg" as expected. This is because InterpretImageFilename() does not set canonical=MagickTrue in either of the places where double-percent handling is done. So the output filename is fixed and then reverted.
If canonical is true for some other reason, it works, for example:
convert source.jpg %d-%%d.jpg
This produces a file called "0-%d.jpg". The fix is simple enough:
Code: Select all
Index: magick/image.c
===================================================================
--- magick/image.c (revision 3430)
+++ magick/image.c (working copy)
@@ -1797,8 +1797,10 @@
}
}
for (q=filename; *q != '\0'; q++)
- if ((*q == '%') && (*(q+1) == '%'))
+ if ((*q == '%') && (*(q+1) == '%')) {
(void) CopyMagickString(q,q+1,(size_t) (MaxTextExtent-(q-filename)));
+ canonical = MagickTrue;
+ }
if (canonical == MagickFalse)
(void) CopyMagickString(filename,format,MaxTextExtent);
return(strlen(filename));
Downstream bug: https://bugzilla.wikimedia.org/show_bug.cgi?id=26233