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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.

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 ImageMagick from sorted by
Terminal - Commands tagged ImageMagick - 65 results
convert -resize '1024x600^' image.jpg small-image.jpg
2011-10-14 22:34:14
User: aguslr
Tags: ImageMagick

This command will resize an image (keeping the aspect ratio) to a specific resolution, meaning the resulting image will never be smaller than this resolution.

For example, if we have a 2048x1000 image, the output would be 1229x600, not 1024x600 or 1024x500. Same thing for the height, if the image is 2000x1200, the output would be 1024x614.

find . -type f -name '*.jpg' -exec convert -quality 75 {} {} \;
2011-09-23 13:51:18
User: bobby_tables
Functions: find

Requires ImageMagick to be installed.

This command was stolen from @climagic on Twitter.

Probably a duplicate of command below, but this command uses slightly higher quality.


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 !

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.

composite -geometry 96x96+250+70 foreground.jpg background.jpg image.jpg
2011-09-04 16:55:51
User: carlosj2585

Compose 2 images (foreground.jpg with background.jpg) into 1 (image.jpg), the numeric parameters stablish the size of the foreground.jpg image (96x96) and the position x,y (+250+70) relative to the background.jpg image.

Images can be any format, jpg, png, bmp, etc...

convert input.png -pointsize 32 -gravity center -annotate 45 "hello, world" output.png
convert input.png -alpha set -channel A -fx 0.5 output.png
convert -size 20x20 xc:white -fill black -draw "circle 10,10 14,14" miff:- | composite -tile - input.png -compose over miff:- | composite - input.png -compose copyopacity output.png
ifconfig | convert label:@- ip.png
composite -dissolve 30% -tile watermark.png input.png output.png
convert input.png -colorspace Gray output.png
convert -size 32x32 \( xc:red xc:green +append \) \( xc:yellow xc:blue +append \) -append output.png
montage *.png -mode concatenate -tile 10x all.png
convert input.png -shave 10x10 output.png
convert input.png -mattecolor gold -frame 10x10+5+5 output.png
convert -crop 32x33 +repage http://code.google.com/more/more-sprite.png icon.png
c=blue;convert -size 50x50 xc:$c $c.png; for i in red green yellow; do convert $c.png -background $i -rotate 20 $i.png; rm $c".png"; c=$i; done; mv $i".png" logo.png; display logo.png
2011-08-21 15:59:11
User: Funatiker
Functions: mv rm
Tags: ImageMagick

Deletes unneeded files after every step and allows to use a color other than yellow at the last position.

mogrify -modulate 100,100,70 ../../icons/32x32/*.png
/bin/ls *.png | xargs -l1 -I {} convert {} -modulate 100,100,70 ../../icons/32x32/{}
montage input.jpg -auto-orient -duplicate 7 -geometry 500 -frame 5 output.jpg
2011-06-09 14:03:01
User: anthony

Yes, You could do it in the GIMP or even use Inkscape, but the command line is so much easier.

This is a new version of a previous command fixing some things complained about.

convert -compress jpeg *.jpg mydoc.pdf
for arq in *.png; do size=$(identify $arq | cut -f3 -d" "); [ $size == "280x190" ] || rm $arq ; done
2011-04-22 20:00:05
Functions: cut rm
Tags: ImageMagick

Removes all png files whose geometry is not 280x190 pixels

convert -density 300x300 input.pdf output.png
2011-01-28 00:36:31

If you skip this part:

-density 300x300

you'll get a very lo-res image.

qrurl() { curl -sS "http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=H|0&chl=$1" -o - | display -filter point -resize 600x600 png:-; }
2010-12-16 04:42:05
User: __

like 7300, but doesn't clutter your working directory with old qr.*.png files. This will get the QR barcode, and send it right into ImageMagick's 'display' tool. Usage is the same as 7300; just call this function followed by the URL:

qrurl http://xkcd.com
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.