How to remove transparency from a TIF and replace with white background

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Roman80
Posts: 25
Joined: 2017-08-03T21:26:15-07:00
Authentication code: 1151

Re: How to remove transparency from a TIF and replace with white background

Post by Roman80 »

I got this information about the Photoshop TIF:
That is expected behaviour. A tiff does not officially support transparency (Photoshop introduced a multi-layered tiff format at some point), but does support alpha channels. This alpha channel is present in the channel palette, and can be used to generate a layer mask, for example.
With that info, is it possible to remove the transparency background?

Regards
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to remove transparency from a TIF and replace with white background

Post by snibgo »

Roman80 wrote:With that info, is it possible to remove the transparency background?
Photoshop puts it there, and apparently only Photoshop can read it. If you want to remove it (rather than simply ignore it), Photoshop seems the best option.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to remove transparency from a TIF and replace with white background

Post by fmw42 »

Your original test.tif has background transparency in two layers and does not have any alpha channel.There is also a layer group called "Zeichenfläche 1". I am not sure why ImageMagick nor the other tools cannot read the background transparency, but it might be due to the fact that you have a layer group. I am not sure ImageMagick knows about tiff layer groups. But that is my guess.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to remove transparency from a TIF and replace with white background

Post by fmw42 »

I removed the grouping and deleted one of the two layers and saved again to TIFF, but it still does not show transparency. Are these "smart layers"? If so, perhaps that is the issue. ImageMagick probably cannot handle any thing but simple pages or perhaps layers as TIFF files.
Roman80
Posts: 25
Joined: 2017-08-03T21:26:15-07:00
Authentication code: 1151

Re: How to remove transparency from a TIF and replace with white background

Post by Roman80 »

The C program that I showed (flatcol.c) uses argv[3] as the colour.
But it does also not work for TIF files and also not with your modified CPP program.

Regards
Roman80
Posts: 25
Joined: 2017-08-03T21:26:15-07:00
Authentication code: 1151

Re: How to remove transparency from a TIF and replace with white background

Post by Roman80 »

fmw42 wrote: 2018-05-22T13:29:46-07:00 I removed the grouping and deleted one of the two layers and saved again to TIFF, but it still does not show transparency. Are these "smart layers"? If so, perhaps that is the issue. ImageMagick probably cannot handle any thing but simple pages or perhaps layers as TIFF files.
I only opened Photoshop, draw 2 squares, set a transparent background and saved it as TIF.
Nothing special

Regards
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to remove transparency from a TIF and replace with white background

Post by snibgo »

Roman80 wrote:But it does also not work for TIF files and also not with your modified CPP program.
Both programs work fine with TIFF files made by ImageMagick. Those files have an alpha channel.

They don't work on the TIFF file you linked because that doesn't have an alpha channel.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to remove transparency from a TIF and replace with white background

Post by fmw42 »

Your problem is that you did not check SAVE TRANSPARENCY in the Options dialog when you saved your file. I opened your file and reserved it checking that box and now it shows transparency when opened and when converted to PNG.

Image
Roman80
Posts: 25
Joined: 2017-08-03T21:26:15-07:00
Authentication code: 1151

Re: How to remove transparency from a TIF and replace with white background

Post by Roman80 »

snibgo wrote: 2018-05-23T04:59:37-07:00
Roman80 wrote:But it does also not work for TIF files and also not with your modified CPP program.
Both programs work fine with TIFF files made by ImageMagick. Those files have an alpha channel.

They don't work on the TIFF file you linked because that doesn't have an alpha channel.
This is not correct, they have an alpha channel and I found a solution.
The Image has a profile which a special Photoshop profile.
If I remove the profile "tiff:37724" it is working with the example programs.

@fmw42: Thanks for the hint

Regards
Post Reply