[howto] Simple Avatar maker (from screenshot)


Recommended Posts

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.

  • 4 weeks later...

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

  • 1 month later...
  • 3 years later...
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It is silly there is no simple way to check whether this profile has been activated. CFRs are normal, but trying to even hide the fact if it's on / off seems silly, especially for something so user-facing. Surely Microsoft is "proud" of their engineering efforts on this one and ought to display it somwhere in the GUI.
    • Many Linux distros are not known for excellent battery life, so I'm not sure that is the best example. A more apt example may be Apple, but Apple's CPUs are simply far more efficient than Intel & AMD at single-threaded tasks like these, so "boosting" is not as power-hungry and less heat-inducing. Not to mention Apple will hardly engage P-cores for basic UI tasks; they use a pretty complicated QoS scheme to only activate P-cores for more serious workloads like HTML / JS execution or decompression or application launch. Microsoft is (smartly) doing it for launch, but also for UI tasks, which is the more nonsensical part: why ... do Windows 11's UIs need modern CPUs to boost? It should load so quickly that there's not even time for the CPU to boost.
    • I've not seen any controlled testing and, judging by Microsoft's mentality, within a year, they'll have added so much more bloat, it'll undo any perceptible latency benefit and we'll have boosted the CPU clocks for nothing.
    • It depends: heat soak is a thing. Initially on cold boot-up, the heatsinks & heatpipes are at ambient temp. After heatsinks & heatpipes warm up (through normal usage), they don't immediately cool to ambient temp when the load goes away. So their baseline is higher and the trigger point for fans is much less stress. Add a few more CPU spikes → it's too hot to stay at the same fan RPM → fans get triggered to start up up much sooner / get triggered to ramp much more quickly.
    • Can LibreOffice just shut up and worry about themselves and stop comparing themselves? Do we see Microsoft complaining about euro office?
  • Recent Achievements

    • One Year In
      slackerzz earned a badge
      One Year In
    • One Year In
      highriskpaym earned a badge
      One Year In
    • One Month Later
      highriskpaym earned a badge
      One Month Later
    • Week One Done
      highriskpaym earned a badge
      Week One Done
    • Week One Done
      FBSPL earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      PsYcHoKiLLa
      198
    3. 3
      +Edouard
      157
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      74
  • Tell a friend

    Love Neowin? Tell a friend!