4

I would like to be able to take screen shots of a specific area on the screen once every second and have the file named MMDDYYYYHH:MM:ss is this possible using the command line and a program. I was thinking of using a script like this

for((i=0;i<1000;i++))
do
import -window root screenshot-$(date '+%d%b%y-%N').png
sleep 5m
done

But I don't know the commands to access the program to change the area on the screen and limit the images quality when saved to a file. PS: I'm willing to use a different program if it will work. I'm using Linux Ubuntu 10.04 64bit.

Thanks

1
  • Interesting question. I'm curious as to why you need this? If you're trying to create an animation of an interactive session (I'm just guessing here), there are better ways to create screencasts - linuxhaxor.net/?p=815
    – Shawn Chin
    Nov 22, 2011 at 10:57

3 Answers 3

8

You could use -crop WxH+X+Y option for import command To specify the area of the screen. And -quality option for quality/compression level of the output. Something like this:

import -window root -crop 200x300+100+15 -quality 100 $(date +%Y%m%d-%H%M%S).png

Note that -quality option for .png and .jpg format has nearly opposite meanings: value of 10 for png means 'lesser compression' (bigger size) while value of 100 - 'maximum compression' (minimal size). On the other hand value of 10 for jpg means 'lesser quality' (lower size) while value of 100 means 'maximum quality' (maximal size).

1
  • 1
    Thanks that works great. I use shutter to get the coordinates
    – Rick T
    Nov 22, 2011 at 9:55
2

Here's what I used, just in-case it may help the next person. I used the Shutter (screengrab program) and chose the Selection option to get the correct coordinates and put them in the script below.

#!/bin/bash
for((i=1;i<10;i++))
do
    import -window root -crop 454x394+69+269 -quality 200 $(date +%m%d%Y-%H%M%S).png
    echo $i
    #type this in a terminal to run     ./timed.sh
sleep 1
done 
1

Did you try Linux alternatives for screenshot?

These are: Shutter, ScreenGrab, FireShot...

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.