<p>This guide will show you how to manipulate images using the Linux <a href="https://www.lifewire.com/command-prompt-2625840" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="1">command line</a>.</p><p>You will find out how to resize an image both in terms of file size and in scale. You will also learn how to convert between multiple file types such as from <a href="https://www.lifewire.com/differences-between-jpeg-tiff-and-raw-493186" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="2">JPG</a> to <a href="https://www.lifewire.com/png-file-2622803" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="3">PNG</a> or <a href="https://www.lifewire.com/gif-file-4116104" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="4">GIF</a> to <a href="https://www.lifewire.com/tif-tiff-file-2622393" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="5">TIF</a>.</p><h3>The Convert Command</h3><p>The convert command is used to convert an image. The format is as follows:</p><p><code>convert [input options] input file [output options] output file.</code></p><h3>How to Resize an Image</h3><p>If you are going to include an image on a webpage and you want it to be a particular size then you could use some CSS to resize the image.</p><p>It is actually better though to upload the image as the correct size in the first place and insert it into the page.</p><p>This is of course just one example why you might want to <a href="https://www.lifewire.com/resize-pictures-before-inserting-1173273" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="6">resize an image</a>. </p><p>To resize an image use the following command</p><p><code>convert imagename.jpg -resize dimensions newimagename.jpg</code></p><p>For example, to convert an image to be 800x600 you would use the following command:</p><p><code>convert imagename.jpg -resize 800x600 newimagename.jpg</code></p><p>If by converting to the specified dimensions the <a href="https://www.lifewire.com/what-is-aspect-ratio-1846860" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="7">aspect ratio</a> will be messed up the image will be resized to the closest ratio.</p><p>To force the conversion to be the exact size, use the following command:</p><p><code>convert imagename.jpg -resize 800x600! newimagename.jpg</code></p><p>You don&#39;t have to specify the height and the width as part of the resize command. For example, if you want the width to be 800 and you don&#39;t care about the height you can use the following command:</p><p><code>convert imagename.jpg -resize 800 newimagename.jpg</code></p><p>To resize an image to be a specified height use the following command:</p><p><code>convert imagename,jpg -resize x600 newimagename.jpg</code></p><h3>How to Convert From One Image Format to Another</h3><p>If you have a JPG file and you wish to convert it to a PNG then you would use the following command:</p><p><code>convert image.jpg image.png</code></p><p>You can combine many different file formats. For example</p><p><code>convert image.png image.gif</code></p><p><code>convert image.jpg image.bmp</code></p><p><code>convert image.gif image.tif</code></p><h3>How to Adjust the File Size for an Image</h3><p>There are a number of ways to change the physical file size of an image. </p><ol><li>Change the aspect ratio (make it smaller)</li><li>Change the file format</li><li>Change the compression quality</li></ol><p>Reducing the size of the image will make the file size smaller. In addition, using a file format that includes compression such as JPG will enable you to reduce the physical file size.</p><p>Finally adjusting the quality will make the physical file size smaller.</p><p>The previous 2 sections showed you how to adjust the size and file type. To <a href="https://www.lifewire.com/the-effect-of-compression-on-photographs-493726" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="8">compress the image</a> try the following command:</p><p><code>convert imagename.jpg -quality 90 newimage.jpg</code></p><p>The quality is specified as a percentage. The lower the percentage the smaller the output file but obviously the final output quality is not as good.</p><h3>How to Rotate Images</h3><p>If you have taken a photo in portrait but you want it to be a landscape image you can rotate the image using the following command:</p><p><code>convert imagename.jpg -rotate 90 newimage.jpg</code></p><p>You can specify any angle for rotation.</p><p>For example, try this out:</p><p><code>convert imagename.jpg -rotate 45 newimage.jpg</code></p><h3>Convert Command Line Options</h3><p>There are dozens of command line options that can be used with the convert command as shown here:</p><p>Options are processed in command line order. Any option you specify on the command line remains in effect for the set of images that follows, until the set is terminated by the appearance of any option or <strong>-noop</strong>. Some options only affect the decoding of images and others only the encoding. The latter can appear after the final group of input images.</p><p>For a more detailed description of each option, see <a href="https://www.imagemagick.org/script/index.php" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="9"><em>ImageMagick</em></a>.</p><table border="1" cellpadding="1" cellspacing="1"><tbody><tr><td><strong>-adjoin</strong></td><td>join images into a single multi-image file</td></tr><tr><td><strong>-affine</strong></td><td>drawing transform matrix</td></tr><tr><td><strong>-antialias</strong></td><td>remove pixel aliasing</td></tr><tr><td><strong>-append</strong></td><td>append a set of images</td></tr><tr><td><strong>-average</strong></td><td>average a set of images</td></tr><tr><td><strong>-background</strong></td><td>the background color</td></tr><tr><td><strong>-blur</strong> <em>x</em></td><td>blur the image with a gaussian operator</td></tr><tr><td><strong>-border</strong> <em>x</em></td><td>surround the image with a border of color</td></tr><tr><td><strong>-bordercolor</strong></td><td>the border color</td></tr><tr><td><strong>-box</strong></td><td>set the color of the annotation bounding box</td></tr><tr><td><strong>-cache</strong></td><td>megabytes of memory available to the pixel cache</td></tr><tr><td><strong>-channel</strong></td><td>the type of channel</td></tr><tr><td><strong>-charcoal</strong></td><td>simulate a charcoal drawing</td></tr><tr><td><strong>-chop</strong> <em>x{&#43;-}{&#43;-}{%}</em></td><td>remove pixels from the interior of an image</td></tr><tr><td><strong>-clip</strong></td><td>apply the clipping path, if one is present</td></tr><tr><td><strong>-coalesce</strong></td><td>merge a sequence of images</td></tr><tr><td><strong>-colorize</strong></td><td>colorize the image with the pen color</td></tr><tr><td><strong>-colors</strong></td><td>preferred number of colors in the image</td></tr><tr><td><strong>-colorspace</strong></td><td>the type of colorspace</td></tr><tr><td><strong>-comment</strong></td><td>annotate an image with a comment</td></tr><tr><td><strong>-compose</strong></td><td>the type of image composition</td></tr><tr><td><strong>-compress</strong></td><td>the type of image compression</td></tr><tr><td><strong>-contrast</strong></td><td>enhance or reduce the image contrast</td></tr><tr><td><strong>-crop</strong> <em>x{&#43;-}{&#43;-}{%}</em></td><td>preferred size and location of the cropped image</td></tr><tr><td><strong>-cycle</strong></td><td>displace image colormap by amount</td></tr><tr><td><strong>-debug</strong></td><td>enable debug printout</td></tr><tr><td><strong>-deconstruct</strong></td><td>break down an image sequence into constituent parts</td></tr><tr><td><strong>-delay</strong> <em>&lt;1/100ths of a second&gt;</em></td><td>display the next image after pausing</td></tr><tr><td><strong>-density</strong> <em>x</em></td><td>vertical and horizontal resolution in pixels of the image</td></tr><tr><td><strong>-depth</strong></td><td>depth of the image</td></tr><tr><td><strong>-despeckle</strong></td><td>reduce the speckles within an image</td></tr><tr><td><strong>-display</strong></td><td>specifies the X server to contact</td></tr><tr><td><strong>-dispose</strong></td><td>GIF disposal method</td></tr><tr><td><strong>-dither</strong></td><td>apply Floyd/Steinberg error diffusion to the image</td></tr><tr><td><strong>-draw</strong></td><td>annotate an image with one or more graphic primitives</td></tr><tr><td><strong>-edge</strong></td><td>detect edges within an image</td></tr><tr><td><strong>-emboss</strong></td><td>emboss an image</td></tr><tr><td><strong>-encoding</strong></td><td>specify the font encoding</td></tr><tr><td><strong>-endian</strong></td><td>specify endianness (MSB or LSB) of output image</td></tr><tr><td><strong>-enhance</strong></td><td>apply a digital filter to enhance a noisy image</td></tr><tr><td><strong>-equalize</strong></td><td>perform histogram equalization to the image</td></tr><tr><td><strong>-fill</strong></td><td>color to use when filling a graphic primitive</td></tr><tr><td><strong>-filter</strong></td><td>use this type of filter when resizing an image</td></tr><tr><td><strong>-flatten</strong></td><td>flatten a sequence of images</td></tr><tr><td><strong>-flip</strong></td><td>create a &#34;mirror image&#34;</td></tr><tr><td><strong>-flop</strong></td><td>create a &#34;mirror image&#34;</td></tr><tr><td><strong>-font</strong></td><td>use this font when annotating the image with text</td></tr><tr><td><strong>-frame</strong> <em>x&#43;&#43;</em></td><td>surround the image with an ornamental border</td></tr><tr><td><strong>-fuzz</strong> <em>{%}</em></td><td>colors within this distance are considered equal</td></tr><tr><td><strong>-gamma</strong></td><td>level of gamma correction</td></tr><tr><td><strong>-gaussian</strong> <em>x</em></td><td>blur the image with a gaussian operator</td></tr><tr><td><strong>-geometry</strong> <em>x{&#43;-}{&#43;-}{%}{&#64;} {!}{&lt;}{&gt;}</em></td><td>preferred size and location of the Image window.</td></tr><tr><td><strong>-gravity</strong></td><td>direction primitive gravitates to when annotating the image.</td></tr><tr><td><strong>-help</strong></td><td>print usage instructions</td></tr><tr><td><strong>-implode</strong></td><td>implode image pixels about the center</td></tr><tr><td><strong>-intent</strong></td><td>use this type of rendering intent when managing the image color</td></tr><tr><td><strong>-interlace</strong></td><td>the type of interlacing scheme</td></tr><tr><td><strong>-label</strong></td><td>assign a label to an image</td></tr><tr><td><strong>-level</strong></td><td>adjust the level of image contrast</td></tr><tr><td><strong>-list</strong></td><td>the type of list</td></tr><tr><td><strong>-loop</strong></td><td>add Netscape loop extension to your GIF animation</td></tr><tr><td><strong>-map</strong></td><td>choose a particular set of colors from this image</td></tr><tr><td><strong>-mask</strong></td><td>Specify a clipping mask</td></tr><tr><td><strong>-matte</strong></td><td>store matte channel if the image has one</td></tr><tr><td><strong>-median</strong></td><td>apply a median filter to the image</td></tr><tr><td><strong>-modulate</strong></td><td>vary the brightness, saturation, and hue of an image</td></tr><tr><td><strong>-monochrome</strong></td><td>transform the image to black and white</td></tr><tr><td><strong>-morph</strong></td><td>morphs an image sequence</td></tr><tr><td><strong>-mosaic</strong></td><td>create a mosaic from an image sequence</td></tr><tr><td><strong>-negate</strong></td><td>replace every pixel with its complementary color</td></tr><tr><td><strong>-noise</strong></td><td>add or reduce noise in an image</td></tr><tr><td><strong>-noop</strong></td><td>NOOP (no option)</td></tr><tr><td><strong>-normalize</strong></td><td>transform image to span the full range of color values</td></tr><tr><td><strong>-opaque</strong></td><td>change this color to the pen color within the image</td></tr><tr><td><strong>-page</strong> <em>x{&#43;-}{&#43;-}{%}{!}{&lt;}{&gt;}</em></td><td>size and location of an image canvas</td></tr><tr><td><strong>-paint</strong></td><td>simulate an oil painting</td></tr><tr><td><strong>-pen</strong></td><td>specify the pen color for drawing operations</td></tr><tr><td><strong>-ping</strong></td><td>efficiently determine image characteristics</td></tr><tr><td><strong>-pointsize</strong></td><td>pointsize of the Postscript, OPTION1, or TrueType font</td></tr><tr><td><strong>-preview</strong></td><td>image preview type</td></tr><tr><td><strong>-process</strong></td><td>process a sequence of images</td></tr><tr><td><strong>-profile</strong></td><td>add ICM, IPTC, or generic profile to image</td></tr><tr><td><strong>-quality</strong></td><td>JPEG/MIFF/PNG compression level</td></tr><tr><td><strong>-raise</strong> <em>x</em></td><td>lighten or darken image edges</td></tr><tr><td><strong>-region</strong> <em>x{&#43;-}{&#43;-}</em></td><td>apply options to a portion of the image</td></tr><tr><td><strong>-resize</strong> <em>x{%}{&#64;}{!}{&lt;}{&gt;}</em></td><td>resize an image</td></tr><tr><td><strong>-roll</strong> <em>{&#43;-}{&#43;-}</em></td><td>roll an image vertically or horizontally</td></tr><tr><td><strong>-rotate</strong> <em>{&lt;}{&gt;}</em></td><td>apply Paeth image rotation to the image</td></tr><tr><td><strong>-sample</strong></td><td>scale image with pixel sampling</td></tr><tr><td><strong>-sampling_factor</strong> <em>x</em></td><td>sampling factors used by JPEG or MPEG-2 encoder and YUV decoder/encoder.</td></tr><tr><td><strong>-scale</strong></td><td>scale the image.</td></tr><tr><td><strong>-scene</strong></td><td>set scene number</td></tr><tr><td><strong>-seed</strong></td><td>pseudo-random number generator seed value</td></tr><tr><td><strong>-segment</strong> <em>x</em></td><td>segment an image</td></tr><tr><td><strong>-shade</strong> <em>x</em></td><td>shade the image using a distant light source</td></tr><tr><td><strong>-sharpen</strong> <em>x</em></td><td>sharpen the image</td></tr><tr><td><strong>-shave</strong> <em>x</em></td><td>shave pixels from the image edges</td></tr><tr><td><strong>-shear</strong> <em>x</em></td><td>shear the image along the X or Y axis</td></tr><tr><td><strong>-size</strong> <em>x{&#43;offset}</em></td><td>width and height of the image</td></tr><tr><td><strong>-solarize</strong></td><td>negate all pixels above the threshold level</td></tr><tr><td><strong>-spread</strong></td><td>displace image pixels by a random amount</td></tr><tr><td><strong>-stroke</strong></td><td>color to use when stroking a graphic primitive</td></tr><tr><td><strong>-strokewidth</strong></td><td>set the stroke width</td></tr><tr><td><strong>-swirl</strong></td><td>swirl image pixels about the center</td></tr><tr><td><strong>-texture</strong></td><td>name of texture to tile onto the image background</td></tr><tr><td><strong>-threshold</strong></td><td>threshold the image</td></tr><tr><td><strong>-tile</strong></td><td>tile image when filling a graphic primitive</td></tr><tr><td><strong>-transform</strong></td><td>transform the image</td></tr><tr><td><strong>-transparent</strong></td><td>make this color transparent within the image</td></tr><tr><td><strong>-treedepth</strong></td><td>tree depth for the color reduction algorithm</td></tr><tr><td><strong>-trim</strong></td><td>trim an image</td></tr><tr><td><strong>-type</strong></td><td>the image type</td></tr><tr><td><strong>-units</strong></td><td>the type of image resolution</td></tr><tr><td><strong>-unsharp</strong> <em>x</em></td><td>sharpen the image with an unsharp mask operator</td></tr><tr><td><strong>-use_pixmap</strong></td><td>use the pixmap</td></tr><tr><td><strong>-verbose</strong></td><td>print detailed information about the image</td></tr><tr><td><strong>-view</strong></td><td>FlashPix viewing parameters</td></tr><tr><td><strong>-wave</strong> <em>x</em></td><td>alter an image along a sine wave</td></tr><tr><td><strong>-write</strong></td><td>write an image sequence [<em>convert, composite</em>]</td></tr></tbody></table><p> </p><p>For more information read the <a href="https://linux.die.net/man/1/convert" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="10" rel="nofollow">manual page for the convert command</a>.</p>