Tk Source Code

View Ticket
Login
Ticket UUID: f285ddcd2322fd6d042efec1f2562d3817f9fe95
Title: GIF format not handled correctly
Type: Bug Version:
Submitter: dkf Created on: 2022-06-03 08:50:57
Subsystem: 42. Photo Image|GIF Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2022-10-05 16:23:30
Resolution: None Closed By: nobody
    Closed on:
Description:

See this SO question for context.

It should not blank the areas outside the update area.

We ought to perform the animation as a core feature (if enabled, at least in 8.7) reading the inter-frame delays and setting timers. That would handle non-uniform timings too (vital for modern GIFs).

User Comments: oehhar added on 2022-10-05 16:23:30:

The solution to get the animated information by the image metadata is in TIP 632. It is in Tk 8.7.

Here are the references:

The bug is not closed, as this is not the requested functionality of running animated gifs automatically.

Thank you all, Harald


oehhar added on 2022-06-11 13:41:25:

Thank you, Francois, for your contribution.

The informations "Delay time", "user interaction" (never seen this) and "disposal method" are required on the script level to play an animation correctly with script-level commands.

This is, what is provided by the branch. In addition, the changed bounding box is provided, what is not required for the test image, as the pixel outside of it are transparent. I am not sure, if this is generally the case. That's why I have added this output.

This is the easiest step to solve the issue.

There might be others thinkable:

  • make the -index option aware of the composition and return the image at this revel with all compositions. In this case for the example, all preceeding images should be merged together first.
  • you mentioned to add animation as general Tk core feature. Here, I can not help or say, if this is feasable. No knowledge of the relevant Tk parts. But I would appreciate to do this (in the future).

The solution in the ticket assume values for "delay time" and "disposal method". With the change, at least, the exact values may be used.

Thank you, Harald


fvogel added on 2022-06-10 18:07:35:
Reading the metadata as you seem to have succeeded to seems indeed to be a first step. What I think Donal proposed is to let Tk do the animation entirely automatically (that's what I understand from "reading the inter-frame delays and setting timers"). Next step would therefore be using Tcl_CreateTimerHandler() calls to schedule animation steps I guess.

That said, the original question at SF seems to have received a satisfactory Tcl level answer.

oehhar added on 2022-06-10 08:44:35:

The update region is now also returned by checkin [7094979c], if not the whole image.

Here is a result with the sample image from the ticket:

% getmeta 0
{delay time} 10 {disposal method} {do not dispose}
% getmeta 1
{update region} {894 717 1 1} {delay time} 10 {disposal method} {do not dispose}
% getmeta 2
{update region} {894 717 1 1} {delay time} 10 {disposal method} {do not dispose}
% getmeta 3
{update region} {894 717 1 1} {delay time} 10 {disposal method} {do not dispose}
% getmeta 4
{update region} {87 25 45 31} {delay time} 10 {disposal method} {do not dispose}
% getmeta 5
{update region} {94 29 21 27} {delay time} 10 {disposal method} {do not dispose}
% getmeta 6
{update region} {99 35 18 23} {delay time} 10 {disposal method} {do not dispose}
8 % getmeta 7
{update region} {87 28 188 160} {delay time} 10 {disposal method} {do not dispose}

So, the first image initiates the whole image. Any following frame just updates parts of it.

I want to stop here and get any comment, if this may be added to Tk. I will send a quero on the core list.

Thank you all, Harald


oehhar added on 2022-06-10 07:26:15:

I made some tests. I think, the updated region is also required as meta data to render it properly. I may add this to the code today.


oehhar added on 2022-06-09 16:18:55:

Could you please test branch [rfe-f285ddcd-animated-gif-metadata] starting with checkin [e81e3493] ?

Using your sample image, I get the following metadata output for all indexes:

set file [file join [file dirname [info script]] nb1Ts.gif]
proc getmeta {index} {
	catch {image destroy i1}
	image create photo i1 -file $::file -format "gif -index $index"
	return [i1 cget -metadata]
}

% getmeta 1
{delay time} 10 {disposal method} {do not dispose}

Would this be suitable for you?

The metadata output now contains the keys (if specified)

  • "delay time": time in 10ms unit
  • "disposal method": one of "do not dispose", "restore to background color", "restore to previous"
  • "user interaction": value "1" if given

Is there additional information required? I can imagine, that the updated bounding-box may be helpful. This may be added.

I would appreciate any feed-back.

Thank you, Harald


oehhar added on 2022-06-03 12:28:25:

Hi Donal, great that you care. I can only say, that all those options are not handled currently. One possibility would be, to return the additional parameters and flags as metadata in the metadata dict. Then, the script level may decide about overlay or replace and about the timing.

What do you think ?

Thank you and take care, Harald


Attachments: