Page 1 of 1

Convert tiff to jpeg is creating several images when having transparency

Posted: 2018-07-24T06:55:00-07:00
by MisterJpa
Hello,

I'm beggining with Image Magick and I'm currently trying to convert and resize a TIFF file to a JPEG file, usually smaller than the original one.
I have two assets : bag.tif and book.tif
Running :
convert bag.tiff -resize 1280x1280 bag.jpg
is correctly doing the conversion.

However, running
convert book.tiff -resize 1280x1280 book.tiff is creating two images :
- One with a black background instead of the transparency (ok, why not as jpeg doesn't handle transparency)
- A second one which is "zoomed" on the non transparent part of the image

Cf:
Image

My goal is that the command generate only one jpeg image (and if possible with a white background instead of a black one.

Can someone explain why I have to image with this command when there is transparency and if possible, could you please provide me a command that will work for both conversion (bag and book) ?

Many thanks in advance,
MisterJpa

Re: Convert tiff to jpeg is creating several images when having transparency

Posted: 2018-07-24T07:27:45-07:00
by snibgo
When asking questions, please always provide:
- the version number of IM you are using
- your platform
- links to your input image files

You say:
MisterJpa wrote:convert book.tiff -resize 1280x1280 book.tiff
Perhaps you intended to say the requested output is "book.jpg".

In your case, I suspect book.tiff contains two images, so you get two outputs. If you just want the first image, then use [0]. And you can flatten against any colour:

Code: Select all

convert book.tiff[0] -resize 1280x1280 -background White -layers Flatten book.jpg

Re: Convert tiff to jpeg is creating several images when having transparency

Posted: 2018-07-24T07:38:38-07:00
by MisterJpa
Hello @Snibgo,

Many thanks for your help.
The command that you provide is perfectly working in both case.

Sorry for the missing info at the beginning, I will provide them next time !