Converting tif image white background to transparent png file format using image magick

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?".
Post Reply
venkat2022
Posts: 2
Joined: 2017-09-27T06:54:00-07:00
Authentication code: 1151

Converting tif image white background to transparent png file format using image magick

Post by venkat2022 » 2017-09-27T07:05:41-07:00

I am trying to convert white color backgrounded tif image type to transparent background png image type using below image magick command in alfresco 5.1.

magick convert source_file.tif -fuzz 20% -transparent white converted_file.png

But the above command is not working for all images. For many of images, the foreground color also changing to transparent partially .and for some images, the background is still showing white after conversion also.

please help me of finding a generic imagemagick command which will change only background color without disturbing the image colour .

Note: I tried with multiple fuzz values like 1% to 20% but not at all helping me.

Source image file is a layered image

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

Re: Converting tif image white background to transparent png file format using image magick

Post by snibgo » 2017-09-27T07:32:24-07:00

venkat22 wrote:please help me of finding a generic imagemagick command which will change only background color without disturbing the image colour .
The command will be easy, once you define "background".

Cleary, "nearly white" isn't a good definition for you.

Some people find that "nearly white, and connected by other nearly-white pixels to the top-left corner" is a good definition, so they use a flood-fill.
snibgo's IM pages: im.snibgo.com

venkat2022
Posts: 2
Joined: 2017-09-27T06:54:00-07:00
Authentication code: 1151

Re: Converting tif image white background to transparent png file format using image magick

Post by venkat2022 » 2017-09-29T01:23:39-07:00

Thankyou for your reply snibgo .

Can you provide command if the image background is full white for multi layered tif images ?

Post Reply