7

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.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Aram Papazian
  • 2,453
  • 6
  • 38
  • 45

3 Answers3

6
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.

  • Would there be anyway to have the tiff file be merged/compressed or unlayered or something so that a multi-image tiff becomes 1 image before I run convert? (The issue is I have 400 files and more randomly coming in from a customer so I'd have no clear way to know which to discard) – Aram Papazian Jan 28 '13 at 21:06
  • 2
    If you're willing to assume they are aligned layers that can be flattened, you might be able to use `-flatten`. It might be useful to find out why they're even multi-directory TIFFs (this might be revealed by looking at the images produced by your original command). – sigynsurfeit Jan 29 '13 at 08:14
4

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.

fmw42
  • 46,825
  • 10
  • 62
  • 80
3

I found this to be more helpful in dealing with output as it doesn't require knowing how many files ImageMagick will generate. This is only useful if you want only the first image:

convert in.tif -delete 1--1 out.jpg

1 is the second image created (index at 0)

-1 is the last image created

So the 1--1 is a range from the second to the last created image. Your output will be out.jpg instead of out-0.jpg.

Zack
  • 69
  • 1
  • 3
  • 11