PIL is showing all the previous frames in the giftransparent background in gif using Python ImageioWhy doesn't my Imagemagick convert consider the loop parameter?What are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?How to upgrade all Python packages with pip?How do I list all files of a directory?Find all files in a directory with extension .txt in PythonHow to write PIL image filter for plain pgm format?Transparent PNG in PIL turns out not to be transparentInstalling PIL with pipPIL Image.save() function fails in Blender pythonQuality and file size issues with animated gifs and PIL/Pillow?Convert PNG to black and white GIF with gd or imagemagick

Automatically anti-predictably assemble an alliterative aria

How can dragons propel their breath attacks to a long distance

Anatomically Correct Carnivorous Tree

Is Germany still exporting arms to countries involved in Yemen?

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

Missouri raptors have wild hairdos

Why did I need to *reboot* to change my group membership

How do employ ' ("prime") in math mode at the correct depth?

Tikz draw contour without some edges, and fill

LWC1513: @salesforce/resourceUrl modules only support default imports

Where to find every-day healthy food near Heathrow Airport?

Why was Endgame Thanos so different than Infinity War Thanos?

On studying Computer Science vs. Software Engineering to become a proficient coder

Why are solar panels kept tilted?

Why does my circuit work on a breadboard, but not on a perfboard? I am new to soldering

Rounding a number extracted by jq to limit the decimal points

Are there any established rules for splitting books into parts, chapters, sections etc?

Labeling matrices/rectangles and drawing Sigma inside rectangle

Can someone explain homicide-related death rates?

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

Area under the curve - Integrals (Antiderivatives)

What information do scammers need to withdraw money from an account?

Is the expression "To think you would stoop so low" often misused?

Does gravity affect the time evolution of a QM wave function?



PIL is showing all the previous frames in the gif


transparent background in gif using Python ImageioWhy doesn't my Imagemagick convert consider the loop parameter?What are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?How to upgrade all Python packages with pip?How do I list all files of a directory?Find all files in a directory with extension .txt in PythonHow to write PIL image filter for plain pgm format?Transparent PNG in PIL turns out not to be transparentInstalling PIL with pipPIL Image.save() function fails in Blender pythonQuality and file size issues with animated gifs and PIL/Pillow?Convert PNG to black and white GIF with gd or imagemagick






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















pillow version:5.4.1


The problem is I can see all the frames in the gif.



Expectation: in the lifecycle of a gif having 5 frames each frames should be visible for a fraction of time and at the end of gif only 5th frame should be visible.



Actual: In my case at the end of the gif I can see all the frames 1-2-3-4-5.



There are 5 frames in the gif animation and all the frames are in gif format(static) I also tried with png files too but I am getting the same result.



All my frames are with transparent background.



from PIL import Image

frame_list = []
frame_list.append("object_1.gif")
frame_list.append("object_2.gif")
frame_list.append("object_3.gif")
frame_list.append("object_4.gif")
frame_list.append("object_5.gif")

images = []
for n in frame_list:
frame = Image.open(n)
images.append(frame)

images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,
loop=0)


If anyone encountered the same issue please let me know what am I doing wrong?



enter image description here



With the below code using imageio it's working but I am loosing transparency and its very slow compare PIL



images = []
for filename in names:
images.append(imageio.imread(filename))
imageio.mimsave('anitest.gif', images,duration=0.3)









share|improve this question
























  • It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

    – Mark Setchell
    Mar 23 at 12:56











  • I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

    – Coral
    Mar 23 at 12:58












  • Can you share the GIF?

    – Mark Setchell
    Mar 23 at 12:59











  • Added the gif ! I have increased the loop just to show what is going wrong.

    – Coral
    Mar 23 at 13:13












  • I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

    – Mark Setchell
    Mar 23 at 13:19


















2















pillow version:5.4.1


The problem is I can see all the frames in the gif.



Expectation: in the lifecycle of a gif having 5 frames each frames should be visible for a fraction of time and at the end of gif only 5th frame should be visible.



Actual: In my case at the end of the gif I can see all the frames 1-2-3-4-5.



There are 5 frames in the gif animation and all the frames are in gif format(static) I also tried with png files too but I am getting the same result.



All my frames are with transparent background.



from PIL import Image

frame_list = []
frame_list.append("object_1.gif")
frame_list.append("object_2.gif")
frame_list.append("object_3.gif")
frame_list.append("object_4.gif")
frame_list.append("object_5.gif")

images = []
for n in frame_list:
frame = Image.open(n)
images.append(frame)

images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,
loop=0)


If anyone encountered the same issue please let me know what am I doing wrong?



enter image description here



With the below code using imageio it's working but I am loosing transparency and its very slow compare PIL



images = []
for filename in names:
images.append(imageio.imread(filename))
imageio.mimsave('anitest.gif', images,duration=0.3)









share|improve this question
























  • It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

    – Mark Setchell
    Mar 23 at 12:56











  • I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

    – Coral
    Mar 23 at 12:58












  • Can you share the GIF?

    – Mark Setchell
    Mar 23 at 12:59











  • Added the gif ! I have increased the loop just to show what is going wrong.

    – Coral
    Mar 23 at 13:13












  • I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

    – Mark Setchell
    Mar 23 at 13:19














2












2








2








pillow version:5.4.1


The problem is I can see all the frames in the gif.



Expectation: in the lifecycle of a gif having 5 frames each frames should be visible for a fraction of time and at the end of gif only 5th frame should be visible.



Actual: In my case at the end of the gif I can see all the frames 1-2-3-4-5.



There are 5 frames in the gif animation and all the frames are in gif format(static) I also tried with png files too but I am getting the same result.



All my frames are with transparent background.



from PIL import Image

frame_list = []
frame_list.append("object_1.gif")
frame_list.append("object_2.gif")
frame_list.append("object_3.gif")
frame_list.append("object_4.gif")
frame_list.append("object_5.gif")

images = []
for n in frame_list:
frame = Image.open(n)
images.append(frame)

images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,
loop=0)


If anyone encountered the same issue please let me know what am I doing wrong?



enter image description here



With the below code using imageio it's working but I am loosing transparency and its very slow compare PIL



images = []
for filename in names:
images.append(imageio.imread(filename))
imageio.mimsave('anitest.gif', images,duration=0.3)









share|improve this question
















pillow version:5.4.1


The problem is I can see all the frames in the gif.



Expectation: in the lifecycle of a gif having 5 frames each frames should be visible for a fraction of time and at the end of gif only 5th frame should be visible.



Actual: In my case at the end of the gif I can see all the frames 1-2-3-4-5.



There are 5 frames in the gif animation and all the frames are in gif format(static) I also tried with png files too but I am getting the same result.



All my frames are with transparent background.



from PIL import Image

frame_list = []
frame_list.append("object_1.gif")
frame_list.append("object_2.gif")
frame_list.append("object_3.gif")
frame_list.append("object_4.gif")
frame_list.append("object_5.gif")

images = []
for n in frame_list:
frame = Image.open(n)
images.append(frame)

images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,
loop=0)


If anyone encountered the same issue please let me know what am I doing wrong?



enter image description here



With the below code using imageio it's working but I am loosing transparency and its very slow compare PIL



images = []
for filename in names:
images.append(imageio.imread(filename))
imageio.mimsave('anitest.gif', images,duration=0.3)






python python-imaging-library gif






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 14:27









martineau

71.3k1093189




71.3k1093189










asked Mar 23 at 12:48









CoralCoral

4,35233237




4,35233237












  • It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

    – Mark Setchell
    Mar 23 at 12:56











  • I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

    – Coral
    Mar 23 at 12:58












  • Can you share the GIF?

    – Mark Setchell
    Mar 23 at 12:59











  • Added the gif ! I have increased the loop just to show what is going wrong.

    – Coral
    Mar 23 at 13:13












  • I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

    – Mark Setchell
    Mar 23 at 13:19


















  • It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

    – Mark Setchell
    Mar 23 at 12:56











  • I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

    – Coral
    Mar 23 at 12:58












  • Can you share the GIF?

    – Mark Setchell
    Mar 23 at 12:59











  • Added the gif ! I have increased the loop just to show what is going wrong.

    – Coral
    Mar 23 at 13:13












  • I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

    – Mark Setchell
    Mar 23 at 13:19

















It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

– Mark Setchell
Mar 23 at 12:56





It may be your browser, try using a different program to view it... stackoverflow.com/a/40442936/2836621

– Mark Setchell
Mar 23 at 12:56













I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

– Coral
Mar 23 at 12:58






I did not check it on browser but after your suggestion I checked it on browser but I am getting the same result.

– Coral
Mar 23 at 12:58














Can you share the GIF?

– Mark Setchell
Mar 23 at 12:59





Can you share the GIF?

– Mark Setchell
Mar 23 at 12:59













Added the gif ! I have increased the loop just to show what is going wrong.

– Coral
Mar 23 at 13:13






Added the gif ! I have increased the loop just to show what is going wrong.

– Coral
Mar 23 at 13:13














I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

– Mark Setchell
Mar 23 at 13:19






I can see what the problem is - it is not clearing between the frames so the "disposal" is not set correctly. I am experimenting with save(..., disposal=N)

– Mark Setchell
Mar 23 at 13:19













1 Answer
1






active

oldest

votes


















4














I think the "disposal" is not being set correctly. Try with:



images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,disposal=2,
loop=0)


enter image description here






share|improve this answer


















  • 1





    omg I missed the disposal argument, thanks a lot !

    – Coral
    Mar 23 at 13:28











  • Cool - good luck with your project!

    – Mark Setchell
    Mar 23 at 14:00











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313887%2fpil-is-showing-all-the-previous-frames-in-the-gif%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














I think the "disposal" is not being set correctly. Try with:



images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,disposal=2,
loop=0)


enter image description here






share|improve this answer


















  • 1





    omg I missed the disposal argument, thanks a lot !

    – Coral
    Mar 23 at 13:28











  • Cool - good luck with your project!

    – Mark Setchell
    Mar 23 at 14:00















4














I think the "disposal" is not being set correctly. Try with:



images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,disposal=2,
loop=0)


enter image description here






share|improve this answer


















  • 1





    omg I missed the disposal argument, thanks a lot !

    – Coral
    Mar 23 at 13:28











  • Cool - good luck with your project!

    – Mark Setchell
    Mar 23 at 14:00













4












4








4







I think the "disposal" is not being set correctly. Try with:



images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,disposal=2,
loop=0)


enter image description here






share|improve this answer













I think the "disposal" is not being set correctly. Try with:



images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,disposal=2,
loop=0)


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 23 at 13:22









Mark SetchellMark Setchell

95k787198




95k787198







  • 1





    omg I missed the disposal argument, thanks a lot !

    – Coral
    Mar 23 at 13:28











  • Cool - good luck with your project!

    – Mark Setchell
    Mar 23 at 14:00












  • 1





    omg I missed the disposal argument, thanks a lot !

    – Coral
    Mar 23 at 13:28











  • Cool - good luck with your project!

    – Mark Setchell
    Mar 23 at 14:00







1




1





omg I missed the disposal argument, thanks a lot !

– Coral
Mar 23 at 13:28





omg I missed the disposal argument, thanks a lot !

– Coral
Mar 23 at 13:28













Cool - good luck with your project!

– Mark Setchell
Mar 23 at 14:00





Cool - good luck with your project!

– Mark Setchell
Mar 23 at 14:00



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313887%2fpil-is-showing-all-the-previous-frames-in-the-gif%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript