Skip to content

Instantly share code, notes, and snippets.

@monkeywithacupcake
Created September 8, 2018 13:56
Show Gist options
  • Save monkeywithacupcake/9e0092733302668b2a4adbbfb1d35748 to your computer and use it in GitHub Desktop.
Save monkeywithacupcake/9e0092733302668b2a4adbbfb1d35748 to your computer and use it in GitHub Desktop.
A shell script to generate an Image with text
#!/bin/zsh
# Asks a series of questions and then returns an image
# use like "bash catchphrase.sh"
echo "What is your favorite color?"
read theColor
echo "What is your catchphrase?"
read thePhrase
convert -size 1000x1000 xc:$theColor +repage \
-size 800x800 -fill white -background None \
-font CourierNewB -gravity center caption:"$thePhrase" +repage \
-gravity Center -composite -strip catchphraseimage.jpg
echo "See your special image at ${PWD}/catchphraseimage.jpg"
@TarunavBA
Copy link

TarunavBA commented Sep 17, 2021

Can you share a picture lf the program working? Or possibly a gif?

@monkeywithacupcake
Copy link
Author

monkeywithacupcake commented Sep 28, 2021

Hi @TarunavBA You can see that I got an error from ImageMagick on fonts, but it still made the image.
I used terminal to create a new file called catchphrase.sh and then I pasted my code above directly. Then, I saved that and then ran bash catchphrase.sh and it was interactive.
Screen Shot 2021-09-27 at 19 49 37

@monkeywithacupcake
Copy link
Author

I went into my Font Book to find a different font, and then I used convert -list font to see which fonts I had available. I changed the font from CourierNewB to Marker-Felt-Wide
Screen Shot 2021-09-27 at 19 56 21
Then, I reran the program, and you can see a different result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment