Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick creating multiple files

I'm running the following:

convert '/var/www/Standard Features.tif' '/var/www/Standard Features.jpg'

and for some reason I'm getting 2 files being created:

-rw-r--r--  1 root   root    31809 Jan 27 23:53 Standard Features-0.jpg
-rw-r--r--  1 root   root    20899 Jan 27 23:53 Standard Features-1.jpg

Why does this happen and how can I make it stop? I can't seem to figure out why this is happening. I've tried changing options and everything, but nothing seems to work.

like image 833
Aram Papazian Avatar asked Jan 28 '13 06:01

Aram Papazian


2 Answers

convert in.tif -delete 0 out.jpg

or

convert in.tif -delete 1 out.jpg

You'll be trying to convert a multi-directory TIFF, which is translated to convert's image stacks. The -delete argument specifies stack indices to be deleted (when there is only one image left in the stack, only one image will be output).

Multi-directory TIFFs really do have multiple images, so you'd want to be careful about what you're actually discarding.

like image 135
sigynsurfeit Avatar answered Sep 22 '22 01:09

sigynsurfeit


TIFF files can have multiple pages. GIF files can have multiple frames and PDF files can have multiple layers. Converting such will produce multiple outputs, one for each page/frame/layer.

If you only want one page/layer/frame of an image in ImageMagick, then just add [x] to your input file name. For example if you just want the first page of a TIFF, then

convert image.tiff[0] out.jpg


See Selecting Frames

If you want a series of pages, use [3-27] for example.

If using ImageMagick 7, replace convert with magick.

like image 23
fmw42 Avatar answered Sep 23 '22 01:09

fmw42