This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Gif animation should have a transparent background

Tags: None
(comma "," separated)
svenreinold
Registered Member
Posts
17
Karma
0
I created a 14 frames animation. It has no background so there should be transparency. It is displayed correctly in Krita but when i render the animation as a gif video or save it as an image the transparent background appeares black. Look here to see that: https://www.deviantart.com/svenreinold
The profile picture is the animation.
ahabgreybeard
Registered Member
Posts
1269
Karma
11
OS
It may be that the browser you use can't display a transparent background (it probably can't). Do you expect to see a checkerboard behind your animated image?

Does your local image viewer show a transparent background? Some can but some can't and they display transparency as black.

If you open the animated .gif in krita, it should show one frame with a transparent background. If so, the animated .gif is fine and it's the browser or viewer that can't display transparency. Also, if you open the animated .gif with GIMP, you should see all the layers with transparent background.
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
Actually, rendering an animated gif with krita uses a particular method (to do the gif-required color reduction as good as possible) that cannot handle transparency, so it is more that it just isn't possible.

You're better off rendering out the frames as pngs with transparency and then using a different program to turn it into gif.
ahabgreybeard
Registered Member
Posts
1269
Karma
11
OS
@TheraHedwig

I was totally unaware that krita can't produce an animated .gif with transparency. Now I realise that it can't since I just tried it.

If you examine palette.png, which is left behind after you render out to an animated .gif from krita, it has a transparent entry on the grid of palette colours (at the lower right) even if you have no transparency in any frame of the animation. This may be the standard transparency entry for a .gif palette.

I thought that krita produced all the .png intermediate output frames and then gave them to ffmpeg for rendering to video/.gif and that ffmpeg made the palette. So is it krita or ffmpeg that creates the palette and is it krita or ffmpeg that can't produce transparency?

P.S. is this related to the difficulty that krita has with .gif image output due to the use of the Qt library?
svenreinold
Registered Member
Posts
17
Karma
0
ahabgreybeard wrote:It may be that the browser you use can't display a transparent background (it probably can't). Do you expect to see a checkerboard behind your animated image?

Does your local image viewer show a transparent background? Some can but some can't and they display transparency as black.

If you open the animated .gif in krita, it should show one frame with a transparent background. If so, the animated .gif is fine and it's the browser or viewer that can't display transparency. Also, if you open the animated .gif with GIMP, you should see all the layers with transparent background.


It's not the browser, it's Krita that makes the black background. On deviant art there are Profile animations with transparency. The image displays correctly with the checkerboard pattern but when saved as a gif it makes it black.
svenreinold
Registered Member
Posts
17
Karma
0
TheraHedwig wrote:Actually, rendering an animated gif with krita uses a particular method (to do the gif-required color reduction as good as possible) that cannot handle transparency, so it is more that it just isn't possible.

You're better off rendering out the frames as pngs with transparency and then using a different program to turn it into gif.


Every gif image is in 256 colors with one of them transparent. I would use Blender to make a gif but that is not supported.
ahabgreybeard
Registered Member
Posts
1269
Karma
11
OS
You can use GIMP to make an animated .gif (with transparency). Each frame of the animation is a layer in GIMP and you can export the layer stack as an animated .gif. I can't remember if GIMP runs the animation starting at the top or the bottom of the layer stack but a simple test will tell you that.

However, from krita, you'll have to make sure that the .png output has transparency enabled by first exporting an image (or frame) and setting the options to store the alpha channel. Then, you can Render the animation as an Image Sequence which will produce a sequence of .png files with transparency that can be opened with GIMP. Use Open As Layers in GIMP and select all the .png images which will then be opened and placed as individual layers in a single GIMP image.
svenreinold
Registered Member
Posts
17
Karma
0
ahabgreybeard wrote:You can use GIMP to make an animated .gif (with transparency). Each frame of the animation is a layer in GIMP and you can export the layer stack as an animated .gif. I can't remember if GIMP runs the animation starting at the top or the bottom of the layer stack but a simple test will tell you that.

However, from krita, you'll have to make sure that the .png output has transparency enabled by first exporting an image (or frame) and setting the options to store the alpha channel. Then, you can Render the animation as an Image Sequence which will produce a sequence of .png files with transparency that can be opened with GIMP. Use Open As Layers in GIMP and select all the .png images which will then be opened and placed as individual layers in a single GIMP image.


I used Gimp for my 9 Million views video. And i don't want to use it anymore.
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
ahabgreybeard wrote:@TheraHedwig

I was totally unaware that krita can't produce an animated .gif with transparency. Now I realise that it can't since I just tried it.

If you examine palette.png, which is left behind after you render out to an animated .gif from krita, it has a transparent entry on the grid of palette colours (at the lower right) even if you have no transparency in any frame of the animation. This may be the standard transparency entry for a .gif palette.

I thought that krita produced all the .png intermediate output frames and then gave them to ffmpeg for rendering to video/.gif and that ffmpeg made the palette. So is it krita or ffmpeg that creates the palette and is it krita or ffmpeg that can't produce transparency?

P.S. is this related to the difficulty that krita has with .gif image output due to the use of the Qt library?

No, it is because we use the palette gen and palette use filters described here: http://blog.pkh.me/p/21-high-quality-gi ... fmpeg.html, and those just don't support transparency.

The issue with using Qt for animated gif, is that Qt just doesn't have support for animated gif. We can only write static gif with it. The problem is that the gif fileformat is a lot more complicated than what meets the eye.

The easiest for Sven is to either use ffmpeg directly for gif, use something like gimp for saving out the gif.
svenreinold
Registered Member
Posts
17
Karma
0
TheraHedwig wrote:
ahabgreybeard wrote:@TheraHedwig

I was totally unaware that krita can't produce an animated .gif with transparency. Now I realise that it can't since I just tried it.

If you examine palette.png, which is left behind after you render out to an animated .gif from krita, it has a transparent entry on the grid of palette colours (at the lower right) even if you have no transparency in any frame of the animation. This may be the standard transparency entry for a .gif palette.

I thought that krita produced all the .png intermediate output frames and then gave them to ffmpeg for rendering to video/.gif and that ffmpeg made the palette. So is it krita or ffmpeg that creates the palette and is it krita or ffmpeg that can't produce transparency?

P.S. is this related to the difficulty that krita has with .gif image output due to the use of the Qt library?

No, it is because we use the palette gen and palette use filters described here: http://blog.pkh.me/p/21-high-quality-gi ... fmpeg.html, and those just don't support transparency.

The issue with using Qt for animated gif, is that Qt just doesn't have support for animated gif. We can only write static gif with it. The problem is that the gif fileformat is a lot more complicated than what meets the eye.

The easiest for Sven is to either use ffmpeg directly for gif, use something like gimp for saving out the gif.


What do you mean use ffmpeg directly? Krita uses ffmpeg for making gif-animations. What do you mean with Ot? I didn't use G'mic. Why are you using this? Transparency in a gif is as common as colors in a painting. How will you make Logos or Icons without that?
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
Modern icons and logos are made with svg. Animated icons and logos are usually either turned into video files to be used in a video. When people upload to a social media site, these days animated gifs get turned into mp4 files.

The reason that we use this method is to avoid issues with gif files compressing the colors badly, because Krita has no internal structures for handling indexed color. GIMP does, if you want to make an indexed color palette gif with transparency, using GIMP is your best bet.
svenreinold
Registered Member
Posts
17
Karma
0
TheraHedwig wrote:Modern icons and logos are made with svg. Animated icons and logos are usually either turned into video files to be used in a video. When people upload to a social media site, these days animated gifs get turned into mp4 files.

The reason that we use this method is to avoid issues with gif files compressing the colors badly, because Krita has no internal structures for handling indexed color. GIMP does, if you want to make an indexed color palette gif with transparency, using GIMP is your best bet.


The weird thing is that the palette has a transparent color saved. What is that good for if it isn't used?
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
svenreinold wrote:
TheraHedwig wrote:Modern icons and logos are made with svg. Animated icons and logos are usually either turned into video files to be used in a video. When people upload to a social media site, these days animated gifs get turned into mp4 files.

The reason that we use this method is to avoid issues with gif files compressing the colors badly, because Krita has no internal structures for handling indexed color. GIMP does, if you want to make an indexed color palette gif with transparency, using GIMP is your best bet.


The weird thing is that the palette has a transparent color saved. What is that good for if it isn't used?

No idea why it is not used, you should ask the ffmpeg developers.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]