Linux Commands Examples

A great documentation place for Linux commands

convert

between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, resample, and much more.


see also : join

Synopsis

convert [input-option] input-file [output-option] output-file


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source
            
convert -type Grayscale
0
source
            
eval 'convert '$@
0
source

How to convert Word (doc) to PDF in linux?

If you're running X then you can do it through Open Office. Since you're about to object to doing it manually, remember there's some nice macro scripts in Open Office so you can automate it. You can do something similar with AbiWord (AbiWord --to=pdf).

If you've not got X then there is antiword, but that just extracts the text - doesn't do any formatting or graphics. There's also wvWare which I've used to bulk extract images from doc files, but I've never tried using it to convert doc files to pdfs.

Oh and .docx files may well need something different, but since they're just zipped xml files it shouldn't be too difficult to do something useful with them. For bulk extracting images you just unzip them and copy the images directory, but I've never needed to convert them in Linux.

0
source

How to convert a 1 page PDF to a 2 page per sheet PDF?

There are freeware & open source command line tools available to convert pdfs to reader's spreads, booklet spreads etc.

I lost the app I was using, so no help there, but a from a quick search I see a program called pdfshuffler ( http://sourceforge.net/projects/pdfshuffler/ ) which might be what you need. Has a gui, so not likely to be automagical, but it is a front-end for another tool...

0
source

How do I convert a DjVu document to PDF in Linux using only command line tools?

djvu2pdf should fit the bill, it's a small script that makes use of the djvulibre toolset. If not, there are other methods that require multiple command-line tools.

0
source

Converting a PDF to black & white with ghostscript

I am not sure if the following suggestion will work... but it may be worth to try out:

  1. convert the PDF to PostScript using the simple pdf2ps utility
  2. convert that PostScript back to PDF while using a re-defined /setrgbcolor PostScript operator

These are the commands:

First

  pdf2ps color.pdf color.ps

This gives you color.ps as output.

Second

gs \
-o bw-from-color.pdf \
-sDEVICE=pdfwrite \
-c "/setrgbcolor{0 mul 3 1 roll 0 mul 3 1 roll 0 mul 3 1 roll 0 mul add add setgray}def" \
-f color.ps
0
source

Burn AVI file to DVD on Linux

Convert Xvid or Avi to DVD Format in Ubuntu,
also the Ubuntuforums thread Convert AVI to DVD ISO.
Also read through the comments for more references (like, DeVeDe).

Here is one more article I located recently when trying to backup an Audio CD:
The Ultimate Guide To Manage Your Audio/Video Files In Linux
a nice reference for multiple related tools.

0
source

Timezone conversion by command line

This example is from http://www.pixelbeat.org/cmdline.html#dates

It gives the local time corresponding to 9AM on the west coast of the US, accounting for differing day light savings transitions.

date --date='TZ="America/Los_Angeles" 09:00 next Fri'

Use tzselect to get the TZ. The PST format is ambiguous. IST = Indian Standard Time and Irish Summer Time for example.

0
source

Linux PDF version converter

Found this in the ubuntu forums :

 # gs -sDEVICE=pdfwrite -dCompatibilityLevel=<VERSION> -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Just tested this and it works fine, I'll post some output now.

[14:08:41]lee@barlow:~/superuser # pdfinfo org_1-4.pdf 
Title:          CV 2009
Producer:       Prince 7.0 alpha 16 (www.princexml.com)
Tagged:         no
Pages:          3
Encrypted:      no
Page size:      595 x 842 pts (A4)
File size:      51793 bytes
Optimized:      no
PDF version:    1.4
[14:08:59]lee@barlow:~/superuser # gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out_1.5.pdf org_1-4.pdf
[14:09:35]lee@barlow:~/superuser # pdfinfo out_1.5.pdf 
Producer:       GPL Ghostscript 8.64
CreationDate:   Wed Aug 19 14:09:34 2009
ModDate:        Wed Aug 19 14:09:34 2009
Tagged:         no
Pages:          3
Encrypted:      no
Page size:      595 x 842 pts (A4)
File size:      60658 bytes
Optimized:      no
PDF version:    1.5
0
source

Is there a way to convert SWF animations to movie files on Linux?

You can try to use edit.py:

apt-get install pyvnc2swf
apt-file search edit.py
pyvnc2swf: /usr/share/pyvnc2swf/edit.py

Then convert it by outputing:

/usr/share/pyvnc2swf/edit.py -o output.flv original.swf

Then if you need to convert it once more to another format use ffmpeg (can convert to many popular video format):

ffmpeg -i output.flv output.avi
0
source

convert a bunch of bmp files to jpeg on linux

You are likely to have ImageMagick installed on Ubuntu.
That can do,

convert filename.bmp filename.jpg

update:

The mogrify (answered by hyperslug and referred by cjm) is also a good option.

Use the mogrify program to resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
This tool is similiar to convert except that the original image file is overwritten
(unless you change the file suffix with the -format option) with any changes you request.

0
source

AVI to iPhone Converter for Linux OS?

By iPhone, I assume you mean mpeg4. There's a lot of command line tools that can achieve that. The main ones are ffmpeg and mplayer/mencoder.

You can also have a look at this Nautilus script.

0
source

Command line video conversion tools

I use ffmpeg

It's open-source and cross platform, and used by a majority if not most of the existing encoders/converters out there.

0
source

How to calculate proper amount of inode/block sizes for a linux filesystem

You'll need an inode for each file, the size of the inode will define the number of direct blocks it can reach before requiring another inode and enough blocks to handle the files.

So, in your case, the minimum number of inodes will be the 3.000.000+. If you use the default value, you'll get 12 direct blocks. So, with a block size of 1kB you'd get what you need.

Obviously you can reduce the inode size and increase the block size to increase the number of inodes. This will get you less space available, but more files in the same filesystem.

0
source

GIF to FLV software on GNU/Linux (or cross-platform)

Try doing this in console:

convert image.gif 'frame%02d.png'
ffmpeg -r RATE -i 'frame%02d.png' movie.flv

Replace RATE with needed framerate, e.g. 2 for 2 frames per second.

You'll need two packages: imagemagick and ffmpeg.

0
source

Convert DDS to PNG using linux command line

ImageMagick reads but doesn't write DDS. And of course it reads and writes PNG.

From identify -list format:

...
DDS* DDS r-- Microsoft DirectDraw Surface
...
PNG* PNG rw- Portable Network Graphics (libpng 1.2.37)
...

To convert a file (leaving the original intact):

convert test.dds test.png

To convert a directory full:

for file in *.dds
do
    convert "$file" "$(basename "$file" .dds).png"
done

description

Image Settings:
-adjoin join images into a single multi-image file
-affine matrix affine transform matrix
-antialias remove pixel-aliasing
-authenticate value decrypt image with this password
-background color background color
-bias value add bias when convolving an image
-black-point-compensation
use black point compensation
-blue-primary point chromaticity blue primary point
-bordercolor color border color
-caption string assign a caption to an image
-cdl filename color correct with a color decision list
-channel type apply option to select image channels
-colors value preferred number of colors in the image
-colorspace type alternate image colorspace
-comment string annotate image with comment
-compose operator set image composite operator
-compress type type of pixel compression when writing the image
-decipher filename convert cipher pixels to plain pixels
-define format:option
define one or more image format options
-delay value display the next image after pausing
-density geometry horizontal and vertical density of the image
-depth value image depth
-direction type render text right-to-left or left-to-right
-display server get image or font from this X server
-dispose method layer disposal method
-dither method apply error diffusion to image
-encipher filename convert plain pixels to cipher pixels
-encoding type text encoding type
-endian type endianness (MSB or LSB) of the image
-family name render text with this font family
-features distance analyze image features (e.g. contrast, correlation)
-fill color color to use when filling a graphic primitive
-filter type use this filter when resizing an image
-flatten flatten a sequence of images
-font name render text with this font
-format "string" output formatted image characteristics
-fuzz distance colors within this distance are considered equal
-gravity type horizontal and vertical text placement
-green-primary point chromaticity green primary point
-intent type type of rendering intent when managing the image color
-interlace type type of image interlacing scheme
-interpolate method pixel color interpolation method
-kerning value set the space between two letters
-label string assign a label to an image
-limit type value pixel cache resource limit
-loop iterations add Netscape loop extension to your GIF animation
-mask filename associate a mask with the image
-matte store matte channel if the image has one
-mattecolor color frame color
-monitor monitor progress
-orient type image orientation
-origin geometry image origin
-page geometry size and location of an image canvas (setting)
-ping efficiently determine image attributes
-pointsize value font point size
-preview type image preview type
-quality value JPEG/MIFF/PNG compression level
-quiet suppress all warning messages
-red-primary point chromaticity red primary point
-regard-warnings pay attention to warning messages
-sampling-factor geometry
horizontal and vertical sampling factor
-scene value image scene number
-seed value seed a new sequence of pseudo-random numbers
-size geometry width and height of image
-statistic type geometry
replace each pixel with corresponding statistic from the neighborhood
-stretch type render text with this font stretch
-stroke color graphic primitive stroke color
-strokewidth value graphic primitive stroke width
-style type render text with this font style
-support factor resize support: > 1.0 is blurry, < 1.0 is sharp
-synchronize synchronize image to storage device
-taint declare the image as modified
-texture filename name of texture to tile onto the image background
-tile-offset geometry
tile offset
-treedepth value color tree depth
-transparent-color color
transparent color
-undercolor color annotation bounding box color
-units type the units of image resolution
-verbose print detailed information about the image
-view FlashPix viewing transforms
-virtual-pixel method
virtual pixel access method
-weight type render text with this font weight
-white-point point chromaticity white point

Image Operators:
-adaptive-blur geometry
adaptively blur pixels; decrease effect near edges
-adaptive-resize geometry
adaptively resize image with data dependent triangulation
-adaptive-sharpen geometry
adaptively sharpen pixels; increase effect near edges
-annotate geometry text
annotate the image with text
-auto-orient automatically orient image
-black-threshold value
force all pixels below the threshold into black
-blur geometry reduce image noise and reduce detail levels
-border geometry surround image with a border of color
-charcoal radius simulate a charcoal drawing
-chop geometry remove pixels from the image interior
-clip clip along the first path from the 8BIM profile
-clip-mask filename associate a clip mask with the image
-clip-path id clip along a named path from the 8BIM profile
-colorize value colorize the image with the fill color
-color-matrix matrix apply color correction to the image
-contrast enhance or reduce the image contrast
-contrast-stretch geometry
improve contrast by ’stretching’ the intensity range
-convolve coefficients
apply a convolution kernel to the image
-cycle amount cycle the image colormap
-despeckle reduce the speckles within an image
-draw string annotate the image with a graphic primitive
-edge radius apply a filter to detect edges in the image
-emboss radius emboss an image
-enhance apply a digital filter to enhance a noisy image
-equalize perform histogram equalization to an image
-evaluate operator value
evaluate an arithmetic, relational, or logical expression
-extent geometry set the image size
-extract geometry extract area from image
-fft implements the discrete Fourier transform (DFT)
-flip flip image vertically
-floodfill geometry color
floodfill the image with color
-flop flop image horizontally
-frame geometry surround image with an ornamental border
-function name apply a function to the image
-gamma value level of gamma correction
-gaussian-blur geometry
reduce image noise and reduce detail levels
-geometry geometry preferred size or location of the image
-identify identify the format and characteristics of the image
-ift implements the inverse discrete Fourier transform (DFT)
-implode amount implode image pixels about the center
-lat geometry local adaptive thresholding
-layers method optimize or compare image layers
-level value adjust the level of image contrast
-linear-stretch geometry
improve contrast by ’stretching with saturation’ the intensity range
-median geometry apply a median filter to the image
-mode geometry make each pixel the ’predominant color’ of the neighborhood
-modulate value vary the brightness, saturation, and hue
-monochrome transform image to black and white
-morphology method kernel
apply a morphology method to the image
-motion-blur geometry
simulate motion blur
-negate replace each pixel with its complementary color
-noise geometry add or reduce noise in an image
-normalize transform image to span the full range of colors
-opaque color change this color to the fill color
-ordered-dither NxN
add a noise pattern to the image with specific amplitudes
-paint radius simulate an oil painting
-polaroid angle simulate a Polaroid picture
-posterize levels reduce the image to a limited number of color levels
-print string interpret string and print to console
-profile filename add, delete, or apply an image profile
-quantize colorspace reduce colors in this colorspace
-radial-blur angle radial blur the image
-raise value lighten/darken image edges to create a 3-D effect
-random-threshold low,high
random threshold the image
-region geometry apply options to a portion of the image
-render render vector graphics
-repage geometry size and location of an image canvas
-resample geometry change the resolution of an image
-resize geometry resize the image
-roll geometry roll an image vertically or horizontally
-rotate degrees apply Paeth rotation to the image
-sample geometry scale image with pixel sampling
-scale geometry scale the image
-segment values segment an image
-selective-blur geometry
selectively blur pixels within a contrast threshold
-sepia-tone threshold
simulate a sepia-toned photo
-set property value set an image property
-shade degrees shade the image using a distant light source
-shadow geometry simulate an image shadow
-sharpen geometry sharpen the image
-shave geometry shave pixels from the image edges
-shear geometry slide one edge of the image along the X or Y axis
-sigmoidal-contrast geometry
lightness rescaling using sigmoidal contrast enhancement
-sketch geometry simulate a pencil sketch
-solarize threshold negate all pixels above the threshold level
-splice geometry splice the background color into the image
-spread amount displace image pixels by a random amount
-strip strip image of all profiles and comments
-swirl degrees swirl image pixels about the center
-threshold value threshold the image
-thumbnail geometry create a thumbnail of the image
-tile filename tile image when filling a graphic primitive
-tint value tint the image with the fill color
-transform affine transform image
-transparent color make this color transparent within the image
-transpose flip image vertically and rotate 90 degrees
-transverse flop image horizontally and rotate 270 degrees
-trim trim image edges
-type type image type
-unique-colors discard all but one of any pixel color
-unsharp geometry sharpen the image
-vignette geometry soften the edges of the image in vignette style
-wave geometry alter an image along a sine wave
-white-threshold value
force all pixels above the threshold into white

Image Sequence Operators:
-affinity filename transform image colors to match this set of colors
-append append an image sequence top to bottom (use +append for left to right)
-clut apply a color lookup table to the image
-coalesce merge a sequence of images
-combine combine a sequence of images
-composite composite image
-crop geometry cut out a rectangular region of the image
-deconstruct break down an image sequence into constituent parts
-evaluate-sequence operator
evaluate an arithmetic, relational, or logical expression
-flatten flatten a sequence of images
-fx expression apply mathematical expression to an image channel(s)
-hald-clut apply a Hald color lookup table to the image
-morph value morph an image sequence
-mosaic create a mosaic from an image sequence
-process arguments process the image with a custom image filter
-separate separate an image channel into a grayscale image
-smush geometry smush an image sequence together
-write filename write images to this file

Image Stack Operators:
-clone indexes clone an image
-delete indexes delete the image from the image sequence
-duplicate count,indexes
duplicate an image one or more times
-insert index insert last image into the image sequence
-swap indexes swap two images in the image sequence

Miscellaneous Options:
-debug events display copious debugging information
-help print program options
-log format format of debugging information
-list type print a list of supported option arguments
-version print version information

Use any setting or operator as an output-option. Only a limited number of setting are input-option. They include: -antialias, -caption, -density, -define, -encoding, -font, -pointsize, -size, and -texture as well as any of the miscellaneous options.

By default, the image format of ’file’ is determined by its magic number. To specify a particular image format, precede the filename with an image format name and a colon (i.e. ps:image) or specify the image type as the filename suffix (i.e. image.ps). Specify ’file’ as ’-’ for standard input or output.

copyright

Copyright (C) 1999-2012 ImageMagick Studio LLC. Additional copyrights and licenses apply to this software, see file:///usr/share/doc/imagemagick/www/license.html or http://www.imagemagick.org/script/license.php

overview

The convert program is a member of the ImageMagick(1) suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

For more information about the convert command, point your browser to file:///usr/share/doc/imagemagick/www/convert.html or http://www.imagemagick.org/script/convert.php.


see also

ImageMagick

How can this site be more helpful to YOU ?


give  feedback