There are numerous GUI screen capture tools (like HotShots) which can upload the images to file hosting services like imgur. What if you want the same action from the cmdline? It’s very much possible. This article explores some cmdline utilities (scripts) which can be used to grab and upload images. Continue reading Capture, upload screenshots from cmdline
The maim & slop combo has been my favourite screen capture tool on Ubuntu for quite sometime. However, I love improvisation and was looking for a screenshot tool that can also capture a freehand area on the screen by tracking the mouse movement. Shutter is a nice tool but it doesn’t have this particular feature. My search ended with a much more powerful tool – HotShots. It is written in Qt.
- Grab current screen, all monitors (for multi-monitor setup), current window or a part of the desktop.
- Capture a freehand drawn region of the screen.
- Capture window with or without decoration.
- Capture with custom delay.
- Keep or hide mouse cursor.
- Copy snapshot to clipboard.
- Save the screenshot in multiple formats (PNG, JPG, BMP …).
- Automatically save the screenshot to clipboard, disk.
- Automatically scale the screenshot to a given size.
- Use system shortcuts to take a screenshot.
- In-built editor.
- Add automatically some “post-effects” to the screenshot (drop shadow, rotation, border …).
- Add annotation items (text, arrows, rectangle …) to the snapshot.
- Minimize to system tray
- Export edited image in multiple formats (PNG, JPG, BMP …).
- Send image directly to printer or to web service.
- Available for Linux and Windows.
To install HotShots on Ubuntu:
$ sudo add-apt-repository ppa:dhor/myway $ sudo apt-get update $ sudo apt-get install hotshots
While scrot is an excellent utility to take screenshots, it has some drawbacks wrt. the amount of control you have on the screenshots and image adjustments. For example, here’s a scrot screenshot with garbage lines. maim and slop are a combination of two cmdline utilities which try to fix the shortcomings of scrot.
slop (Select Operation) querys for a selection from the user and prints the region to stdout. It grabs the mouse and turns it into a crosshair, lets the user click and drag to make a selection (or click on a window) while drawing a pretty box around it. Hovering on a window selects it and a left click returns the dimensions. You can also click and drag to select a region on the screen.
maim (Make Image) on the other hand, can take screenshots using region co-ordinates passed to it as arguments or through slop (for user selection). Features include:
- Select or specify any geometry
- Intelligently handle multiple monitors out out of screen areas. Mask off-screen pixels to be black and transparent in screenshots.
- Save to any format
- Blend the system cursor to screenshots
--selectoption is more advanced to scrot’s
- No feature bloat e.g., no
--execor naming features
- Automatically upload to Imgur (needs external script)
The only way to install slop and maim is to compile them from source. I have uploaded the compiled stripped binaries for Ubuntu 14.04 x86_64. Copy the binaries in /usr/bin and make them executable.
Download (md5sum: 6db73169d8ed7ee280439bcd58623695).
The simplest way to run is:
//Capture full screen $ maim screeshot.jpg //Select region/window and capture $ maim --hidecursor -s screenshot.jpg
You can move the mouse around to see how the focussed window changes with hover. To take the screenshot of a whole window (without any overlap), hover and double click on the window. The extension give in the output image name determines the format. Default (no option) is PNG. To push things further, assign a keyboard shortcut.
scrot is the default screenshot tool on LXDE that works with other desktop environments too. Given its few dependencies and tiny size it is much more powerful than it seems. scrot depends on the imlib2 library. scrot stands for SCReenshOT. scrot works best when run from the terminal. Features:
- Take screenshots of the desktop or a window or a selected region
- Grab window manager border along with the window
- Add delay in seconds with countdown before taking screenshot
- Execute an application on the image after taking a screenshot
- Take images of varying quality (1-100). Default is 75.
- Take images from multiple displays and stitch together
- Generate thumbnail (as per input percentage) along with image
- Saves image as PNG by default or if output filename is not available in cmdline arguments. scrot detects extensions to generate the image format. Creates JPEG when an extension with .jpg is provided as output filename.
To install on Ubuntu:
$ sudo apt-get install scrot
An example with explanation of the options used:
$ scrot -s -b -d 5 -c -q 100 myshot.jpg options: -s: select a window or rectangle with the mouse -b: grab border -d: wait for 5 seconds before taking screenshot -c: show a countdown for the delay -q: grab image at 100% quality
Refer to the man pages for detailed explanation of all the cmdline options. It is available in the default repositories of most major distros.
Here’s a collection of various tools to take screenshots and share them:
- xScreenshot: Capture and edit the full screen or part of the screen. Share with friends. Works on Linux and Windows.
- Dropbox script: Take a screenshot and upload to Dropbox using a simple script. Linux only.
- Gyazo: Capture the full or partial screen and share the generated links instantly. For Linux, Windows, Mac.
- Shutter: Feature rich with sharing capabilities. Linux only.
- Scrot: Power screenshots from cmdline. Linux only.
- Lookit: A relatively new project to take screenshots and share them. Linux only.
You can select a rectangular area of your screen and take the screenshot of that area very easily if you are using Unity on Ubuntu. Simply press Shift and Print Screen keys together. You will see a cross-hair pointer that you can click and drag to select any specific area on the screen.
Instead of taking a screenshot of the whole desktop and later trimming it down to get only the terminal, there is an easy way to take the screenshot of the terminal only:
xwd > term.xwd convert term.xwd term.png
The first command with take the screenshot and the second command converts the image file into png.
If you are in taking screenshots every now and then try this tool on Ubuntu – Shutter. It’s very very powerful and has a plethora of features to meet all your needs.
- Capture a specific area, desktop, window, menu or tooltip
- Capture a website
- Edit captured image in image editor
- Share online
Shutter’s only drawback is its high number of dependencies.
To install Shutter on Ubuntu:
$ sudo apt-get install shutter
Another desktop screenshot tool that can add reflections and perspectives is screenie.
The import utility provided by ImageMagick is a powerful utility to take screenshots. The simplest usage is:
$ import mydesktop.png
And click on the window you want to capture or select the region you want to capture.
There are many available options such as:
- Take a screenshot ofthe desktop and resize to 50% after some delay
$ import -window root -resize 50% -delay 500 screen.png
- Take a screenshot ofthe desktop and resize to 800×600
$ import -window root -resize 800x600
Check the man import for full list of options.
To record a video of the desktop, try:
$ ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq desktop_video.mpg
If you are looking for information on how to record the screen on Ubuntu take a look here.