People think linux console/terminal is for administration, configuration, text processing and programming. The reality is terminal can do much more things than what we regularly do on it. You can listen to audio (read man pages for mpg123, mpg321, ogg123, play, mp3blaster….), record/process audio/video files (read man pages for sox, rec, mencoder, ffmpeg… ), manipulate/animate image (read manpages for import, fbgrab, fbshot, convert, composite, imagemagick, ), and many more…
Let’s discuss how to manipulate images in this post.
The easiest tool pclinuxos has for taking screenshot is fbgrab.
Just issue: fbgrab filename.png in the commandline, that’s it. Fbgrab produces only png image shots.
Else you can use import command (from imagemagick suite). Import produces screenshots in jpg, png and bmp. Choose the one that suits best to your screenshot color depth.
To take screenshot of the entire screen issue: import -window root filename.png
To take screenshot of a particular screen issue: import screenshot.png you cursor will turn into an crosshair, drop the cursor on the section you want to capture.
Using import you can also set a time delay so that you hide the terminal containing the import command or arrange your windows properly. For example if you want 5 seconds delay issue: sleep 5; import -window root screenshot.png
You can also add timestamp. For it issue: import -window root ‘date +%Y-%m-%d’.png
ImageMagick is a small but versatile suite to manipulate images. It comes as default in many linux distributions.
You can issue convert with tile argument to tile the input image into an output image of a size you specify with the -size argument. For example: convert -size 640x480 tile :image.jpg tiledimage.jpg
Add border to image:
Using -border and -bordercolor arguments with convert, you can add a border to an image. The width you specify applies to the left and right of the image, while the height applies to the top and bottom of the image. You can pass a color either in text (red, blue, white, etc.) or as an RGB value. For example: convert -border 15x18 -bordercolor white image.jpg image2.jpg
Using convert with -thumbnail argument you can create thumbnails. To create a thumbnail that has a width of 160 pixels, issue: convert -thumbnail 160 image.jpg thumbnail.jpg
To create a thumbnail with a height of 160 pixels, precede the geometry with x: convert -thumbnail x160 image.jpg thumbnail.jpg
This command is very useful if you have handle a lot of digital images to a web gallery. You can create a script to automate thumbnail creation. For example, to create a thumbnail with a width of 160 pixels from every JPEG image in a directory, issue: for i in *.jpg; do convert -thumbnail 160 $i thumb-$i; done;
With the help of composite using -gravity and –watermark options you can define watermarks to your protected graphics.The -gravity option defines a number of locations for a watermark. The supported locations are north, east, south, west, northeast, southeast, southwest, northwest, and center. The -watermark option takes as its argument a percentage that defines how translucent to make the watermark. To add a 35% translucent watermark in the bottom right-hand corner of an image, issue: composite -watermark 35% -gravity southeast watermark.gif image.jpg image-watermarked.jpg
In this example, watermark.gif is the watermark, image.jpg is the image to watermark, and image-watermarked.jpg is the newly created image.
You can also create a script to automate watermark creation for your web gallery.
You can use the animate tool of imagemagick suite and apply -delay option to create nice web animations. For example how it looks like one second delay on a directory full of gif images, issue: animate -delay 100 *.gif
This command will display images in that directory in alphabetical order.
If you are satisfied with the above delay effect. You can use convert command to convert a directory of gif files into a single gif animation by issuing: convert -delay 100 *.gif animated.gif