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/
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.
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
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:
Converts red-cyan 3D anaglyphs to side-by-side format viewable by crossing your eyes. Useful for people who don't have 3D glasses or prefer not to use one.
Creates a PDF from multiple images. One page per image.
If you want a specific arbitrary order you can use {1,3,5,10,12}
* you may use jpg, tif etc
** if you do use jpg images you might want to add "-compress Zip" as suggested below to prevent from having the images from being re-compressed.
Now try this. Ones you see small cross arrow, double click on any window you like to make a screenshot "selectively".
mogrify can be used like convert. The difference is that mogrify overwrites files:
http://www.imagemagick.org/www/mogrify.html
Of course, other source colors can be used as well.
Runs the identify command (from ImageMagick) on each jpg file in the current directory and returns image details according to the format parameter. The example here returns:
Filename FileSize Compression Width Height
More information about the available format options can be found here: http://www.imagemagick.org/script/escape.php
I usually redirect the output to a text file using "> listofdetails.txt" at the end. Spreadsheet magic can then be applied.
Quickly create a new image with a certain size and background color.
Outputs the number of different pixels.
2 params to increase tolerance:
* thumbnails size
* fuzz, the color distance tolerance
See http://en.positon.org/post/Compare-/-diff-between-two-images for more details.
You can use the -format switch to get the size of the image. Replace "logo:" with your image.
optipng *.png
http://www.mobileread.com/forums/showpost.php?p=147076&postcount=7
-dither FloydSteinberg produces a more uniform dither than the default.
full command:
for fn in xkcd*.png xkcd*.jpg; do; echo $fn; read xw xh <<<$(identify -format '%w %h' $fn); nn="$(echo $fn | sed 's/xkcd-\([0-9]\+\)-.*/\1/')"; wget -q -O xkcd-${nn}.json http://xkcd.com/$nn/info.0.json; tt="$(sed 's/.*"title": "\([^"]*\)", .*/\1/' xkcd-${nn}.json)"; at="$(sed 's/.*alt": "\(.*\)", .*/\1/' xkcd-${nn}.json)"; convert -background white -fill black -font /usr/share/fonts/truetype/freefont/FreeSansBold.ttf -pointsize 26 -size ${xw}x -gravity Center caption:"$tt" tt.png; convert -background '#FFF9BD' -border 1x1 -bordercolor black -fill black -font /usr/share/fonts/truetype/freefont/FreeSans.ttf -pointsize 16 -size $(($xw - 2))x -gravity Center caption:"$at" at.png; th=$(identify -format '%h' tt.png); ah=$(identify -format '%h' at.png); convert -size ${xw}x$(($xh+$th+$ah+5)) "xc:white" tt.png -geometry +0+0 -composite $fn -geometry +0+$th -composite at.png -geometry +0+$(($th+$xh+5)) -composite ${fn%\.*}_cmp.png; echo -e "$fn $nn $xw $xh $th $ah \n$tt \n$at\n"; done
this assumes that all comics are saved as xkcd-[number]-[title].{png|jpg}.
it will then download the title and alt-text, create pictures from them, and put everything together in a new png-file.
it's not perfect, but it worked for nearly all my comics.
it uses the xkcd-json-interface.
though it's poorly written, it doesn't completely break on http://xkcd.com/859/
Parses /etc/group to "dot" format and pases it to "display" (imagemagick) to show a usefull diagram of users and groups (don't show empty groups).
parse "lsmod" output to "dot" format and pass it to "display". Without perl!
Do not use JPEG, GIF, or any other 'lossy' image encoding with Encryption
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.
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.
http://www.commandlinefu.com/commands/view/707/compress-images-using-convert-imagemagick-in-a-bulk
- Backup data before reszie as it over write original
-To preserve aspect ratio remove !
Create transparent image to use as icon, watermark for other images, etc.
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...