Overlay_text = "/usr/bin/convert "+ photo_path + " -pointsize 36 -fill white -annotate +40+728 '" + tweettime + "' " Print "about to set overlay_text variable" # Add text overlay of data on the photo we just took Status = tweet_text + ' #optionalhashtag ' + tweettime # Creation of the actual interface, using authentication # OAuth process, using the keys and tokensĪuth = tweepy.OAuthHandler(consumer_key, consumer_secret)Īuth.set_access_token(access_token, access_token_secret) Consumer keys and access tokens, used for OAuthĬonsumer_key = 'copy your consumer key here'Ĭonsumer_secret = 'copy your consumer secret here'Īccess_token = 'copy your access token here'Īccess_token_secret = 'copy your access token secret here' Tweet_text = "Photo from insert your location here" # then overlay a small logo and tweet the final image # take a photo with the Pi camera, overlay some text Here is a slightly modified version of the code I used at the Cambridge Raspberry Jam last weekend to tweet photos of people who visited the HDMIPi stand. If they’re not, you can scale them, but if you’re doing the same thing over and over again, it’s more efficient to do that processing once and in advance. It’s a good idea to make sure your logos are a suitable size. So, in my program, I ran this command twice. It puts the output in the file your_modified_photo.jpg This uses ‘convert’ to take your_photo.jpg and overlay the file overlay.png 1 pixel from the left-hand edge and 1 pixel down from the top edge. usr/bin/convert /path/to/your_photo.jpg /home/pi/overlay.png -geometry +1+1 -composite path/to/your_modified_photo.jpg We use the same program as before, but different command arguments and parameters… There is a way to change the font, but I had trouble with it, so stayed with the default font.īut I want logos too. So the program does this step for each piece of data it wants to overlay. This is incredibly powerful and – once you’ve got your head round it – not very hard. The resulting file is saved as your_output_photo.jpg, but you can use the same filename and path as the input file to overwrite the original. The text will be 36 points high and white. It takes the photo your_photo.jpg and overlays the text your overlay text 40 pixels in from the left-hand edge and 728 pixels from the top edge. usr/bin/convert /path/to/your_photo.jpg -pointsize 36 -fill white -annotate +40+728 'your overlay text' /path/to/your_output_photo.jpg So What Does This Do? There are a couple of traps though because, from within a program, it’s better to specify the full path to files and programs. Sudo apt-get install imagemagick (install program) Overlaying Textįrom the command line, this is how it works…Ĭonvert your_photo.jpg -pointsize 36 -fill white -annotate +40+728 'your overlay text' your_output_photo.jpg Sudo apt-get update (update package list) It can all be done with an excellent package called ImageMagick. It didn’t take long to find a helpful thread. I had no idea how to overlay text on a photo, but I headed over to the Raspberry Pi forums and did a search.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |