What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands tagged image from sorted by
Terminal - Commands tagged image - 30 results
lame -v 2 -b 192 --ti /path/to/file.jpg audio.mp3 new-audio.mp3
for I in *.CR2; do if [ `exiv2 pr -p a -u $I | grep 'xmp.Rating' | awk '{ print $4 }'` == "1" ]; then echo $I; fi; done
jhead -rgt file-name.jpg
ffmpeg -loop 1 -i image.png -i sound.mp3 -shortest video.mp4
-y -r 1 -t 3 -f video4linux2 -vframes 1 -s sxga -i /dev/video0 ~/webcam-$(date +%m_%d_%Y_%H_%M).jpeg
2013-02-27 05:32:03
User: navyjeff
Functions: date

Take a picture from your webcam and save it to a jpeg.

A very slightly modified version of MarxBro's command.

find . -iname '*jpg' -print0 | xargs -0 exiftool -warning; find . -iname '*jpg' -print0 | xargs -0 jpeginfo -c
2013-01-28 16:44:19
Functions: find xargs

This checks jpeg data and metadata, should be grepped as needed, maybe a -B1 Warning for the first, and a -E "WARNING|ERROR" for the second part....

read && ffmpeg -y -r 1 -t 3 -f video4linux2 -vframes 1 -s sxga -i /dev/video0 ~/webcam-$(date +%m_%d_%Y_%H_%M).jpeg
2013-01-17 11:37:09
User: MarxBro
Functions: date read

This command takes a 1280x1024 p picture from the webcam.

If prefer it smaller, try changing the -s parameter: qqvga is the tiniest, vga is 640x480, svga is 800x600 and so on.

Get your smile on and press enter! :)

ffmpeg -i source.mpg -r 24 -f image2 still-%6d.png
2013-01-10 02:49:15
User: manuq

-i sets the source file

-r sets the output frame rate, set it to the same frame rate as the input to output each frame

-f sets the output format, trough it might be guessed by the extension

convert -size 100x100 xc:grey nopic100_100.jpg
2012-06-15 11:23:02
User: theduke

Quickly create a new image with a certain size and background color.

icotool -l demo.ico
aspectRatio () { for i in `seq 1 1000 `; do awk "BEGIN {print $1/$i, $2/$i}"; done |grep -v "\."; }
2012-03-07 06:22:25
User: totti
Functions: awk grep

EG: aspectRatio 1920 1200

For display a image in full screen it should be in any of the resolution obtained from the output. So resize an image to any of it and you can display it in full screen

For general aspect ratio :

aspectRatio () { for i in `seq 1 1000 `; do awk "BEGIN {print $1/$i, $2/$i}"; done |grep -v "\." |tail -1; }
identify -format "%[fx:w]x%[fx:h]" logo:
2012-02-19 08:29:56
User: dratini0

You can use the -format switch to get the size of the image. Replace "logo:" with your image.

identify image.jpg |grep -o "[[:digit:]]*x[[:digit:]]*" |tail -1
find . -iname "*.jpg" -printf '<img src="%f" title="%f">\n' > gallery.html
mogrify -resize 600x800! *.jpg
2011-09-09 18:19:59
User: totti

- Backup data before reszie as it over write original

-To preserve aspect ratio remove !

wallpaperWarn() { BG="/desktop/gnome/background/picture_filename"; convert "`gconftool-2 -g $BG`" -pointsize 70 -draw "gravity center fill red text 0,-360 'Warn' fill white text 0,360 'Warn'" /tmp/w.jpg; gconftool-2 --set $BG -t string "/tmp/w.jpg"; }
2011-09-07 19:00:40
User: totti

Display some text on the wallpaper especially warning messages

convert -background none -pointsize 55 label:"`whoami`" me.png
2011-09-07 17:06:38
User: totti

Create transparent image to use as icon, watermark for other images, etc.

mogrify -modulate 100,100,70 ../../icons/32x32/*.png
/bin/ls *.png | xargs -l1 -I {} convert {} -modulate 100,100,70 ../../icons/32x32/{}
losetup /dev/loop0 harddrive.img; kpartx -a -v /dev/loop0; mount /dev/mapper/loop0p1 /mountpoint/
convert *.jpg output.pdf
2010-10-10 15:41:03
User: fazen

Given some images (jpg or other supported formats) in input, you obtain a single PDF file with an image for every page.

convert example.png -resize 100x100 output.png
2010-08-08 16:40:21
User: dbbolton

You can also specify width and height of the resized image (in pixels), as an alternative to using a percentage.

find . | perl -wne 'chomp; print qq|<img src="$_" title="$_" /><br />| if /\.(jpg|gif|png)$/;'> gallery.html
2010-07-04 01:43:50
User: spotrick
Functions: find perl

This includes a title attribute so you can see the file name by hovering over an image. Also will hoover up any image format - jpg, gif and png.

find . -iname '*.jpg' | sed 's/.*/<img src="&">/' > gallery.html
2010-07-04 00:50:32
User: kniht
Functions: find sed

My take on the original: even though I like the other's use of -exec echo, sed just feels more natural. This should also be slightly easier to improve.

I expanded this into a script as an exercise, which took about 35 minutes (had to look up some docs): http://bitbucket.org/kniht/nonsense/src/7c1b46488dfc/commandlinefu/quick_image_gallery.py

find . -iname '*.jpg' -exec echo '<img src="{}">' \; > gallery.html
2010-07-03 16:36:15
Functions: echo find

Setting: You have a lot of jpg files in a directory.

Maybe your public_html folder which is readable on the net because of Apache's mod_userdir. All those files from the current folder will be dropped into a file called gallery.html as image tags that can be viewed within a web browser locally or or over the Internet.


find . -iname "*.jpg" -exec echo "<img src=\"{}\">" >> gallery.html \;