remove transparent background in GIF

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
molecule
Posts: 5
Joined: Sat Apr 03, 2010 3:48 pm

remove transparent background in GIF

Post by molecule »

I some gifs that have transparent background and I'd like to remove transparency and set background to white (or some other color).

Is it possible to do this? Would the process be the same for PNG as well?

As it is, I write html that centers image in generous borders, take a screenshot, and trim back to original size. (arghh!)

Thanks ...
User avatar
xnview
Author of XnView
Posts: 46255
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: remove transparent background in GIF

Post by xnview »

you can change that in 'edit palette'
Pierre.
molecule
Posts: 5
Joined: Sat Apr 03, 2010 3:48 pm

Re: remove transparent background in GIF

Post by molecule »

Hi Pierre,

Thanks.

I believe the GIF is 8 bit BW (256 greyscale).

When I open the gif for editing, there is no background. The standard XnView background (mid-grey) "shows thru." A few "blurry" scratchings(?) show thru. They become dark lines on a white background when the gif is displayed in a browser.

In XnView, when I first open Image > Edit palette, the "enable transparency" box is checked, and the selected background is RBB 0,0,0.

(I don't know if it matters, but under edit > background color ... the background color is white RGB 255,255,255.)

Using Edit palette, when I select a transparency color, preferably white (or any shade of grey), and then deselect the "enable transparency" box, the background always reverts to black.

Is there a way to turn transparency off and change the background to white (or some other color) as if it was displaying in a browser?

Thanks,

Bert
cday
XnThusiast
Posts: 4397
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: remove transparent background in GIF

Post by cday »

molecule wrote:Is there a way to turn transparency off and change the background to white (or some other color) as if it was displaying in a browser?
When the image is open with Image > Edit palette... selected, could you try double-clicking on the indicated colour, selecting white from the colour chooser that appears, and then deselecting Enable transparency ...

If that doesn't work could you upload a sample image?
molecule
Posts: 5
Joined: Sat Apr 03, 2010 3:48 pm

Re: remove transparent background in GIF

Post by molecule »

double clicking a color on the color palatte opens the color picker -- deselecting transparency has the results as before.

attached is an upload of the gif ...
tyring to remove transparency and show white background
tyring to remove transparency and show white background
edit -- when uploaded the "normal" grey (i.e. transparent) background is converted to black

thanks
cday
XnThusiast
Posts: 4397
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: remove transparent background in GIF

Post by cday »

molecule wrote:attached is an upload of the gif ... steiner_bees_00test.gif

edit -- when uploaded the "normal" grey (i.e. transparent) background is converted to black
Yes, the image as uploaded lacks transparency when downloaded and opened? :(

Could you try placing the image file in a ZIP (or RAR) archive and uploading that, and then check if transparency is maintained when it is downloaded and opened?

I don't normally work with transparency but my suggestion above worked with a test image I downloaded, XnTriq is the transparency expert... :D
cday
XnThusiast
Posts: 4397
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: remove transparent background in GIF

Post by cday »

Possibly overtaken by events...

The image of the file you uploaded, when clicked on, displays the image with the original gray background, and that file can be saved and opened in XnView.

I then followed the steps in my first post, noting that the top right [black?] square in the displayed palette [?] was just-visibly marked with a surrounding square; I then double-clicked the square and set the colour to white, then deselected transparency.
steiner_bees_00test_(clicked-on)_processed.gif
Is that the result you need, or am I misunderstanding something?
User avatar
XnTriq
Moderator & Librarian
Posts: 6512
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: remove transparent background in GIF

Post by XnTriq »

molecule wrote:when uploaded the "normal" grey (i.e. transparent) background is converted to black
cday wrote:XnTriq is the transparency expert... :D
You already hit the nail on the head with your previous post, cday 8)
  1. Open steiner_bees_00test.gif in XnView.
  2. Go to Image » Edit Palette..., deactivate Enable transparency and confirm with OK.
  3. Go to View » Display Colour Information: The mouse cursor changes to an eye-dropper.
  4. Move the cursor over the background area: The palette index (and RGB values etc.) of the background color are displayed in the tooltip.
  5. Go to Image » Edit Palette... once again, find the background color (ie. Index = 0 / RGB = 0,0,0) and double-click on it to bring up the color picker.
  6. Change the color to white (RGB = 255,255,255) and save your image.
cday
XnThusiast
Posts: 4397
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: remove transparent background in GIF

Post by cday »

XnTriq wrote:
  1. Open steiner_bees_00test.gif in XnView.
  2. Go to Image » Edit Palette..., deactivate Enable transparency and confirm with OK.
  3. Go to View » Display Colour Information: The mouse cursor changes to an eye-dropper.
  4. Move the cursor over the background area: The palette index (and RGB values etc.) of the background color are displayed in the tooltip.
  5. Go to Image » Edit Palette... once again, find the background color (ie. Index = 0 / RGB = 0,0,0) and double-click on it to bring up the color picker.
  6. Change the color to white (RGB = 255,255,255) and save your image.
Isn't the transparency colour indicated directly when Image > Edit palette... is opened, as seen more clearly for this GIF:
Image_Edit palette....png
Image_Edit palette....png (6.65 KiB) Viewed 2837 times
In steiner_bees_00test.gif the rectangle around the top left colour was barely visible. :(

The procedure I followed was:
  1. Open steiner_bees_00test.gif in XnView.
  2. Go to Image » Edit Palette... ;
  3. Double-click on the indicated transparency colour;
  4. Select the desired new colour;
  5. Deselect Transparency and save the image.
User avatar
XnTriq
Moderator & Librarian
Posts: 6512
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: remove transparent background in GIF

Post by XnTriq »

cday wrote:Isn't the transparency colour indicated directly when Image > Edit palette... is opened, as seen more clearly for this GIF:
:shock: Thanks for pointing that out to me! I had noticed this border before, but I failed to realize that it indicates which color is set to transparent.
molecule
Posts: 5
Joined: Sat Apr 03, 2010 3:48 pm

Re: remove transparent background in GIF

Post by molecule »

thank you everyone!

I see my mistake ... in the Edit Palette dialog, I had clicked on the color that I had desired (white 255,255,255), instead of the transparency color with the little box around it (black 0,0,0) that had already been selected.

This time, I use Edit Palette once, carefully scan the palette for the already selected transparency color (black), double click on it and pick my new color (white), and then deselect enable transparency. Voila!

Wonderful!

Thanks guys!

Bert
Post Reply