René's URL Explorer Experiment


Title: PillowWriter GIF duration and loop · Issue #19169 · matplotlib/matplotlib · GitHub

Open Graph Title: PillowWriter GIF duration and loop · Issue #19169 · matplotlib/matplotlib

X Title: PillowWriter GIF duration and loop · Issue #19169 · matplotlib/matplotlib

Description: Current PillowWriter functionality does not allow me to specify the duration for each of the gif frames and it is not possible to not have the gif loop. Additionally, I frequently get a ValueError: buffer is not large enough when animati...

Open Graph Description: Current PillowWriter functionality does not allow me to specify the duration for each of the gif frames and it is not possible to not have the gif loop. Additionally, I frequently get a ValueError:...

X Description: Current PillowWriter functionality does not allow me to specify the duration for each of the gif frames and it is not possible to not have the gif loop. Additionally, I frequently get a ValueError:...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19169

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PillowWriter GIF duration and loop","articleBody":"\u003c!--\r\nWelcome! Thanks for thinking of a way to improve Matplotlib.\r\n\r\n\r\nBefore creating a new feature request please search the issues for relevant feature requests.\r\n--\u003e\r\n\r\n### Current PillowWriter functionality does not allow me to specify the duration for each of the gif frames and it is not possible to not have the gif loop.\r\nAdditionally, I frequently get a **ValueError: buffer is not large enough** when animating multi axes figures. (Not sure if this is a common problem).\r\n\r\nAnimation to help introduce a visual story can be quite beneficial to understanding and for that I would like to be able to not loop the gif and \"pause\" the gif via different durations for all frames.\r\n\r\n\u003c!--\r\nProvide a clear and concise description of the problem this feature will solve. \r\n\r\nFor example:\r\n* I'm always frustrated when [...] because [...]\r\n* I would like it if [...] happened when I [...] because [...]\r\n* Here is a sample image of what I am asking for [...]\r\n--\u003e\r\n\r\n### Proposed Solution\r\n\r\n1) add duration=None, loop=0 arguments to setup() and to a PillowWriter specific saving context_manager.\r\nTo not loop we can specify loop=None and then we specifically need to not pass the loop argument to save() in finish().\r\n\r\n2) What is the difference between Image.frombuffer and Image.open(buf)? I find that Image.open(buf) solves my problem of the ValueError: buffer is not large enough.\r\nIt seems to take more time for me though. (about +33%)\r\n\r\n3) removed unused variable assignment: renderer = self.fig.canvas.get_renderer() from grab_frame()\r\n\r\n```\r\nclass PillowWriter(AbstractMovieWriter):\r\n    @classmethod\r\n    def isAvailable(cls):\r\n        return True\r\n\r\n    def setup(self, fig, outfile, dpi=None, duration=None, loop=None):\r\n        super().setup(fig, outfile, dpi=dpi)\r\n        self.duration = duration\r\n        self.loop = loop\r\n        self._frames = []\r\n\r\n    def grab_frame(self, **savefig_kwargs):\r\n        buf = BytesIO()\r\n        self.fig.savefig(\r\n            buf, **{**savefig_kwargs, \"dpi\": self.dpi})\r\n        self._frames.append(Image.open(buf))\r\n\r\n    def finish(self):\r\n        duration = self.duration or int(1000 / self.fps)\r\n\r\n        # to not loop at all we need to avoid passing the loop argument to save\r\n        if self.loop is None:\r\n            self._frames[0].save(\r\n                self.outfile, save_all=True, append_images=self._frames[1:],\r\n                duration=duration)\r\n        else:\r\n            self._frames[0].save(\r\n                self.outfile, save_all=True, append_images=self._frames[1:],\r\n                duration=duration, loop=self.loop)\r\n\r\n    @contextlib.contextmanager\r\n    def saving(self, fig, outfile, dpi, duration=None, loop=0, *args, **kwargs):\r\n        \"\"\"\r\n        Context manager to facilitate writing the movie file.\r\n        ``*args, **kw`` are any parameters that should be passed to `setup`.\r\n        \"\"\"\r\n        # This particular sequence is what contextlib.contextmanager wants\r\n        self.setup(fig, outfile, dpi, duration, loop, *args, **kwargs)\r\n        try:\r\n            yield self\r\n        finally:\r\n            self.finish()\r\n```\r\n\r\n\r\n### Additional context and prior art\r\n\r\nendless looping for gifs was introduced here:\r\nhttps://github.com/matplotlib/matplotlib/pull/11789\r\n\r\nDocumentation would have to be updated I suppose.\r\nIf this seems like a useful improvement to the PillowWriter I could go ahead and create a PR.","author":{"url":"https://github.com/znstrider","@type":"Person","name":"znstrider"},"datePublished":"2020-12-23T14:23:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/19169/matplotlib/issues/19169"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1fe0e9fd-86d5-39e9-f9a2-a94a1185cdee
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE36C:F32D9:3DC8B49:57A06E6:6A56AC3B
html-safe-nonce3c4132c2e760c2699183e418bc79121c07840e6e944f3dca00494e0cb49f21d9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzZDOkYzMkQ5OjNEQzhCNDk6NTdBMDZFNjo2QTU2QUMzQiIsInZpc2l0b3JfaWQiOiI4OTIzNTM3OTYyMjI4NDI3ODM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacbcf2c4fc249dd6a7ae0d8d9499fbcc34cc199ca4552d9d909adf9c51184d32ed
hovercard-subject-tagissue:773828249
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/19169/issue_layout
twitter:imagehttps://opengraph.githubassets.com/27ae2df55b68feda4e794efc5ec4d150d6d22f7ad2bceeaf38befe02d50baa58/matplotlib/matplotlib/issues/19169
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/27ae2df55b68feda4e794efc5ec4d150d6d22f7ad2bceeaf38befe02d50baa58/matplotlib/matplotlib/issues/19169
og:image:altCurrent PillowWriter functionality does not allow me to specify the duration for each of the gif frames and it is not possible to not have the gif loop. Additionally, I frequently get a ValueError:...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameznstrider
hostnamegithub.com
expected-hostnamegithub.com
None13efe7fe8ecc41eda1078cbde8206041ed92bc54e29bcb737e9353dd9c407aad
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5466ebe023a0abf876a1e6c5d7602ee8f5e6a02b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/19169#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F19169
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F19169
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/19169
Reloadhttps://github.com/matplotlib/matplotlib/issues/19169
Reloadhttps://github.com/matplotlib/matplotlib/issues/19169
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/19169
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/19169
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 410 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
PillowWriter GIF duration and loophttps://github.com/matplotlib/matplotlib/issues/19169#top
New featurehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22New%20feature%22
https://github.com/znstrider
znstriderhttps://github.com/znstrider
on Dec 23, 2020https://github.com/matplotlib/matplotlib/issues/19169#issue-773828249
#11789https://github.com/matplotlib/matplotlib/pull/11789
New featurehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22New%20feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.