Friday, February 2, 2018

GIMP How to make existing gif background transparent


I have the following gif, how to make the grey background transparent if not white?


enter image description here



Answer



It depends if the light gray things are shadows or not.


They are shadows



Then a transparent background is not doable for this particular GIF. When you want a transparent background, you want to be able to show the picture over any background. In the picture above the shadows would be implemented as partially opaque pixels, that would slightly darken the pixels of the background. But in a GIF, there are no partially opaque pixels, they are fully opaque or fully transparent, so you can't have shadows. You can however change the background:


Prerequisites: Download and install:



Then:



  • Remove the optimizations: Filters>Animation>Unoptimize. This create a new image, you can close the source one.

  • Change image to full RGB: Image>Mode>RGB

  • Colors>Color to Alpha All layers and remove the background (color-pick, it should be #EEEEEE). Dark grey can darken to black, but don't panic.

  • Add a layer filled with white (or your new background color). Make it invisible

  • Image>Interleave layers>Interleave single layer (sprite mode) and select the white layer. This will create a new image, use Filters>Animation>Playback to check it.


  • Filters>Animation>Optimize (for GIF)

  • Export as GIF, don't forget to tick the animation checkbox, and to force all frames to 40ms (the optimization sets a longer interval)


keep partially opaque shadows


They aren't shadows


So the light gray things will remain opaque, and we want to remove the background but prevent Color-to-alpha to change the light gray things into be partially opaque pixels. For a single layer, that means Select the background,Select>Growby two pixels, andColors>Color to Alpha` but this will be long for 68 layers. However there is a script that makes this a bit faster if used right:


Prerequisites: Download and install:




  • ofn-erase-background





  • Remove the optimizations: Filters>Animation>Unoptimize. This create a new image, you can close the source one.



  • Change image to full RGB: Image>Mode>RGB

  • Set Gimp background color from the background color of your image (#eeeeee)

  • Set the tools to the "By Color" selector.

  • Click in a corner of the top layer, this should select the background

  • Layer>Erase background should make the background transparent.

  • Warm your fingers and do 67 times:


    • Click a layer in the Layer list

    • Clear near a corner in the image

    • Ctr-F to reexecute Layer>Erase background



  • Filters>Animation>Playback to check

  • Filters>Animation>Optimize (for GIF)

  • Export as GIF, don't forget to tick the animation checkbox, and to force all frames to 40ms (the optimization sets a longer interval)



opaque shadows


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...