Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Hello,
I found that the +clone operator does not behave as I would expect when not enclosed in parens. I would expect the result of the first command given below to be similar to that of the second, where the right-hand clone is also swirled. I was surprised because this behavior seems to break with convert's semantics of "everything is processed left to right".
Anthony's examples explains that clone is only intended to be used within parentheses so it probably doesn't work as expected when there aren't any around it.
see: http://www.imagemagick.org/Usage/basics/#clone
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
RetroJ wrote:This is a use-case for +clone in which I do not need to do further processing on the clone, hence there is no logical call for the grouping construct.
It makes more logical sense to group your first commands and then clone, so the clone sees the result of the command not the input plasma image
fmw42 wrote:It makes more logical sense to group your first commands and then clone, so the clone sees the result of the command not the input plasma image
fmw42 wrote:It makes more logical sense to group your first commands and then clone, so the clone sees the result of the command not the input plasma image
Since operators have left-associativity in convert, no grouping should be necessary at all in this example.
This is what Anthony's clone notes say:
Note that "-clone" without the use of parenthesis will just copy images from the current image sequence and directly append them. However this is not its intended use and is to be discouraged as it will produce a different result if you later surround that set of operations by parenthesis.
The first image in the sequence is the plasma: without the parenthesis.
fmw42 wrote:This is what Anthony's clone notes say:
Note that "-clone" without the use of parenthesis will just copy images from the current image sequence and directly append them. However this is not its intended use and is to be discouraged as it will produce a different result if you later surround that set of operations by parenthesis.
The first image in the sequence is the plasma: without the parenthesis.
As he summarizes, the behavior of -clone without parentheses is completely un-useful, and because it is un-useful, and produces inconsistent results, it is discouraged. That is why my request is that the behavior of -clone without parentheses be changed to do something useful. The intuitive and useful thing to do in this case would be to clone the image after having applied the operators appearing to the left of -clone, in normal left-to-right order.
RetroJ wrote:This is a use-case for +clone in which I do not need to do further processing on the clone, hence there is no logical call for the grouping construct.
Even though +clone works without parenthesis, do not use it that way. If you later add parenthesis around your set of operations to use it as a sub-set of a more complex set, you will get in to trouble.
It is was never ment to be used without parenthesis! It was created to pull in images into a sub-sequence of operations - on the side.
An alternative to +clone is -write mpr:{label} then read the iameg using mpr:{label} however this does the WHOLE image sequnece, and not specific images.
anthony wrote:Even though +clone works without parenthesis, do not use it that way. If you later add parenthesis around your set of operations to use it as a sub-set of a more complex set, you will get in to trouble.
It is was never ment to be used without parenthesis! It was created to pull in images into a sub-sequence of operations - on the side.
An alternative to +clone is -write mpr:{label} then read the iameg using mpr:{label} however this does the WHOLE image sequnece, and not specific images.
Please consider my post about this issue as a feature request to change the behavior of -clone when used without parentheses. This would constitute an improvement to the user-interface of convert, because -clone would now be "meant to be used" in any context at all, and the problem of unpredictable results "if you later add parentheses" would be eliminated. The use-case in my initial post shows the obvious desired effect that anyone would expect of -clone, who did not have such esoteric knowledge as that they had to either use "extra" parentheses or an mpr: for such a trivial operation as appending a manipulated image to itself.
[quote="RetroJPlease consider my post about this issue as a feature request to change the behavior of -clone when used without parentheses. This would constitute an improvement to the user-interface of convert, because -clone would now be "meant to be used" in any context at all, and the problem of unpredictable results "if you later add parentheses" would be eliminated. The use-case in my initial post shows the obvious desired effect that anyone would expect of -clone, who did not have such esoteric knowledge as that they had to either use "extra" parentheses or an mpr: for such a trivial operation as appending a manipulated image to itself.[/quote]
Actually I agree with you and that is what is should do. But that isn't its original design and even though it is fix, it should it is not recommended usage. adding parenthesis around it is not a great strain, but makes it correct usage. In all IM examples that is what I do.
Sorry to resurrect this thread, but I was using IM to arrange pictures on a 5x7 page for printing and encountered this behavior of -clone. Two things:
1) Could the command line options web page please be modified to include the recommendation to use parentheses with -clone? I figured out the correct usage by trial and error.
2) Typically I use the built-in version of IM supplied with Ubuntu, which is 6.3.7. Recently, I grabbed the "Portable" distribution for windows, and started to run it under wine, so that I can try out new features.
The following command actually segfaults under wine (IM 6.4.8-8 Q16 OpenMP) and Windows XP (IM 6.4.9-2 Q16 OpenMP), but does not when parentheses are placed around +clone. No segfault from Ubuntu's IM 6.3.7, though.