1

I have inherited a legacy project containing some 20+ APNG files that are considered instrumental to the design of the site. However, for whatever reason, Safari plays these APNG files twice where every other browser I have tested them in plays them only once because they were created with the loop count (num_plays) set to 1. This is standard because 0 means loop forever.

I understand APNG may be considered a thing of the past at this point; but, assuming I cannot change this part of the project, do I have any means of getting Safari to play the animations only once as designed? Or am I looking at some rancid Safari only fallback?

Here is an example of one of the images: enter image description here

Thanks!

greg-tumolo
  • 698
  • 1
  • 7
  • 30
Kai Qing
  • 18,793
  • 5
  • 39
  • 57

2 Answers2

0

If all of the images contain as few colors as the example, you could convert them to animated GIFs without loss of quality to avoid a Safari-only fallback (at which you are, indeed, looking without the conversion).

greg-tumolo
  • 698
  • 1
  • 7
  • 30
  • That would fall under the category of "rancid safari only fallback" - which incidentally is what I am doing but it is hideous beyond hideous with the jaggy nature of gifs and having no alpha support. I wrote an animation library instead and it sort of does the job but its no answer to my question so I won't post it here. Thanks though. – Kai Qing Jun 19 '20 at 17:48
  • I should mention it's not obvious on stack overflow that these apngs have a transparent background. The red wave is the only part of the image and that is hugely distorted in gif format. – Kai Qing Jun 19 '20 at 17:49
  • I meant "Use animated GIFs in all browsers.", which would fall under the category of "rancid" in all browsers. – greg-tumolo Jun 19 '20 at 18:59
  • Does your animation library convert an APNG to a PNG[], the elements of which are displayed sequentially by way of canvas.drawImage()? – greg-tumolo Jun 19 '20 at 19:03
  • 1
    No I split them into frames and run a src swap on an image using requestanimationframe. It works but it's not totally there yet. – Kai Qing Jun 19 '20 at 19:06
0

You should modify the frame control chunk of the last frame by setting delay_num to 65535 and delay_den to 1 so that the first frame does not display again for 65535 s = 18.2 h!

greg-tumolo
  • 698
  • 1
  • 7
  • 30