My main question requires some set up. I'm not asking about POVray or ImageMagick, but if you notice I am doing something inefficiently or incorrectly, I would be grateful for advice.
I want to generate an animation which contains a lot of static intervals, meaning the frame to generate is identical to the previous frame. I don't want to waste execution time generating these frames over and over. So the script reads the clock value and if it is within such an interval, it exits, resulting in a black frame with pathname %o. I want to include in my povray.ini file a post-frame shell command which looks something like this pseudo code:
identify -verbose %o | grep Colors: | if (? & (the string which is $2 is "1")) then cp lastimage %o else cp %o lastimage fi;
where lastimage is a path to the last non-black frame generated. If the frame just generated was black, replace it with lastimage, otherwise copy it into lastimage. Yes this is inefficient during an animation interval but I believe it should work.
The output from the grep command, when the frame is black, for me, is "Colors: 1" and if the frame is a generated image, there is no text ouput. But I don't know that that would always be the case. Maybe the output from identify would include the line "Colors: 123456" for example. In the if command, ? checks the output status from grep. If grep produced output then parameter $1 would be the string "Colors:" and $2 should correspond to the number of colors. Please how do I check the number of colors within this if command within this pipeline? Is there some sort of string compare I could use inside the if clause?
I am grateful for any clue.