Generated By Artificial Stupidity

Today’s cutup always generates a surplus of images with which I sometimes try to generate more interesting collages and sometimes create animate gifs with a series of similar sized images.

The raw gif for this series ended up being a bit too large for my blog to handle but after processing via it brought it down around 10MB which I could upload.

$ identify coalesce-Oct-30-2021-114.jpg
coalesce-Oct-30-2021-114.jpg JPEG 1000x820 1000x820+0+0 8-bit sRGB 196458B 0.000u 0:00.000

The images come from stories I randomly select in my mostly unread RSS reader. Each day I select 100 random stories, scrape the images and text from them and reassemble. Since I am not able to read all the stories in my RSS reader I would like to take a random sample of material from them and create this assemblage which will at least give me a vague idea of what is happening in the Internet world today.

As if I didn’t know a certain Internet site was pitching a new idea. Which will go horribly wrong in my opinion, but what are you going to do. Make art is one thing I can do, or at least try.

In my RSS reader at the moment there are 89,307 unread stories. So there is a lot going on I will never know about, but with this method I have devised of “cutting up” the Internet I can filter out a few interesting things.


DATE=$(date +"%b-%d-%Y")

if [ $# -ne $EXPECTED_ARGS ]
  echo "Usage: Needs a number to put on the end of the file name, plus the
  image size of the images to animate. Also put the delay as the third 
  exit $E_BADARGS

IMAGES_TO_ANIMATE=$(identify coalesce-"$DATE"-* | grep "$IMAGE_SIZE" | awk '{ print $1 }')
echo " * Images To Animate:"
echo ""
echo ""
echo "File Name will be: coalesce-$DATE-$IMAGE_NUMBER.gif"

convert -delay "$DELAY" $IMAGES_TO_ANIMATE coalesce-"$DATE"-"$IMAGE_NUMBER".gif

Above is the script that has to be run from the directory where all the collected images live. It is a fairly dumb bash script.

~/Werk/coalesce/2021/10/30/images$ shellcheck 

In line 27:
convert -delay "$DELAY" $IMAGES_TO_ANIMATE coalesce-"$DATE"-"$IMAGE_NUMBER".gif
                        ^----------------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
convert -delay "$DELAY" "$IMAGES_TO_ANIMATE" coalesce-"$DATE"-"$IMAGE_NUMBER".gif

For more information: -- Double quote to prevent globbing ...

If I quote the variable which contains all the image names the script will not work. Running the script to create a gif:

~/Werk/coalesce/2021/10/30/images$ bash 5 1000x820 30

If the variable is quoted in the command as shellcheck suggests:

convert -delay "$DELAY" "$IMAGES_TO_ANIMATE" coalesce-"$DATE"-"$IMAGE_NUMBER".gif

Would result in:

convert-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
convert-im6.q16: no images defined `coalesce-Oct-30-2021-5.gif' @ error/convert.c/ConvertImageCommand/3258.

But if I leave the command unquoted then it will produce an animated image like the ones above.

The blog post here explains this is due to the “IFS” or Internal Field Separator in bash. From what I gather when the variable is quoted, it is interpreted as a list of things which should be split by space, tab and line feed. Which is not what I want. I am not claiming to understand, this is a fuzzy part of bash that I don’t entirely grasp. Sure enough I could illustrate with the “cat -et” command:

echo " * Images To Animate: Quoted"
echo ""
echo "$IMAGES_TO_ANIMATE" | cat -et
echo ""
echo " * Images To Animate: Not Quoted"
echo ""
echo $IMAGES_TO_ANIMATE | cat -et
echo ""

Then using another image size (this would make a really big gif)

~/Werk/coalesce/2021/10/30/images$ bash 6 4046x2275 30

 * Images To Animate: Quoted


 * Images To Animate: Not Quoted

coalesce-Oct-30-2021-137.jpg coalesce-Oct-30-2021-184.jpg coalesce-Oct-30-2021-374.jpg coalesce-Oct-30-2021-3.jpg coalesce-Oct-30-2021-60.jpg coalesce-Oct-30-2021-81.jpg coalesce-Oct-30-2021-89.jpg$

I don’t quite understand, but it’s good to know. I think I could make an array, or disable the IFS variable by setting it nothing, or just ignore not having quotes on that variable which is what I have chosen to do for now. Eventually I would like to rewrite the scripts in Python, and learn the wrong to do this in a new language. But not today.






Leave a Reply

Your email address will not be published. Required fields are marked *