• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

[howto] Simple Avatar maker (from screenshot)

Recommended Posts

markjensen    98

Hey there, just playing a bit more with learning to script, and I have combined a few things to make a simple Linux bash script that will allow you to take a screenshot, superimpose your preferred "main" image on top of it (in my case, it is Opus the penguin), then upload it to an FTP site of your choice.

It is a bit ugly (and I keep it in my home directory, inside a directory non-descriptively titled "temp". :ermm:

I have it commented a bit, and would appreciate expert assistance to improve it (because I just know it is taking up extra intermediate steps that are not necessary and inefficient) :p

Here it is:

#!/bin/bash

# ensure I am in the temp directory where I am doing this work
cd ~/temp
# take a screenie, sized down to 128x128
import -window root -resize 128x128 screenie.png

# center it onto a 128x128 fully transparent png file
composite -gravity center screenie.png blank_128.png step1.png

# throw my 128x128 image of Opus over the top of the screenie
composite -gravity center opus_face.png step1.png final.png

# cleanup
rm screenie.png step1.png

# final resize to Neowin limits
mogrify -resize 80x80 final.png

# start FTP upload
ftp -n ftp.site.com <<FTP-Session
user username password
binary
put final.png
bye
FTP-Session
# -n option to "ftp" disables auto-logon.

With the ftp command above, the "<<" indicates that the following section (which I named "FTP-Session") is not bash code, but is to be passed to ftp as commands (just learned this today) :D The use of the name again marks the end of the section and returns to bash execution.

Of course, change "ftp.site.com" to your ftp site address, and change "username" and "password" to your login name and password for that ftp site.

This isn't exactly a revolutionary script, but I thought I would share it for those others who may be interested. (the ftp command scripting thing was very new to me!)

EDIT: Oh yeah, I forgot to specify, the "blank_128.png" and "opus_face.png" files I used are pre-existing for this script to work right. You will have to create an appropriately-sized transparent .png and also find a suitable image you want plastered on the front yourself.

Share this post


Link to post
Share on other sites
MasterC    10

Amazing! :yes: I have to try this out- thanks a lot Mark! :D

Share this post


Link to post
Share on other sites
The_Decryptor    1,105

Interesting script, see if i can get it to work with my mac (it provides screenshot apps as well)

...

With the ftp command above, the "<<" indicates that the following section (which I named "FTP-Session") is not bash code, but is to be passed to ftp as commands (just learned this today) :D The use of the name again marks the end of the section and returns to bash execution.

...

Never knew that, gotta love bash

Share this post


Link to post
Share on other sites
ichi    359

Nice idea, and interesting code :yes:

Share this post


Link to post
Share on other sites
Scott.Mc    0

Good guide, but maybe you should point out that they need imagemagick installed.

Share this post


Link to post
Share on other sites
t_r_nelson    97

I just want to know where the background image shown on your blog is found...yummy!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.