The Shrinking size of animated gif
Alejandro Tejada
capellan2000 at gmail.com
Mon Oct 30 22:54:45 EDT 2017
Hi All,
Could you verify if always that we convert
an animaated gif in a series of png images
the resulting images are always smaller
than the 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 mail list server)
----------------------------------------------------------------
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
More information about the use-livecode
mailing list