The Shrinking size of animated gif

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

The Shrinking size of animated gif

Post by capellan » Sat Nov 04, 2017 4:42 am

Hi All,

Could you verify if always that we convert an animated gif in a series of png images, the resulting png images are always smaller than original animated gif?

Here is the recipe:

1) Create a new stack

2) create a button and paste this script into the button: (check for broken lines in the forum text editor)

Code: Select all

on mouseUp

-- first, delete all previous images
   repeat with i = the number of controls of this card down to 1
      if word 1 of the long  name of control i of this card is "image" then
delete control i of this card
   end repeat

   answer file "Choose an animated gif..."
   import paint from file it
   try
      put the framecount of img 1 into k
      repeat with m = 1 to k
         set the currentframe of img 1 to m
         create image
         set the width of it to the width of img 1
         set the height of it to the height of img 1
         set the imagedata of it to the imagedata of img 1
         set the alphadata of it to the alphadata of img 1
      end repeat

      repeat with i = 1 to the number of controls of this card
         put the long name of control i of this card into q
         if word 1 of q is "image" then
            put the size of q & comma after n
         end if
      end repeat

      delete last char of n -- a comma
      put item 1 of n into tAnimatedGifSize
      delete item 1 of n
      put sum(n) into tPngImagesSize

      if tAnimatedGifSize > tPngImagesSize then
         put "Animated gif is " & (tAnimatedGifSize - tPngImagesSize) && "bytes larger than png images"
      else
         -- sum of sizes of png images is larger
         -- than size of animated gif
         put "Png images are " & (tPngImagesSize - tAnimatedGifSize) && "bytes larger than animated gif"
      end if
   end try
end mouseUp
3) Click the button and import an animated gif

Post your results in this thread,
Thanks a lot in advance!

Al

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: The Shrinking size of animated gif

Post by jmburnod » Sat Nov 04, 2017 10:00 am

Hi Al,
I used this animated gif 133X137
http://www.gif-anime.org/im/gif/alien/h ... umour8.gif
with this result (LC 8.1.6): Png images are 452 bytes larger than animated gif
Fortunately width and height are egal :D
Best regards
Jean-Marc
https://alternatic.ch

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: The Shrinking size of animated gif

Post by bogs » Sat Nov 04, 2017 3:39 pm

capellan wrote:
Sat Nov 04, 2017 4:42 am
Could you verify if always that we convert an animated gif in a series of png images, the resulting png images are always smaller than original animated gif?
Well, not 'always', but 'sometimes'. I ran these through in the order you see, Lc 6.5.2 -
Image
The first one is a single frame gif -
Image
The next few vary in complexity and size. The largest was the first of the 2 minions laughing.
ImageImageImageImageImage
Hope that helps :)
Image

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: The Shrinking size of animated gif

Post by capellan » Sat Nov 04, 2017 4:18 pm

Yes, this helps a lot. :D
I think that there is a pattern, probably as a result of
delta encoding used by animated gif file format.
Animated gif are not as simple as they look...

http://www6.uniovi.es/gifanim/conserva.htm

http://www6.uniovi.es/gifanim/gifmake.htm

Al

Post Reply

Return to “Games”