Lossless gif resized, size goes up

This picture bealow behaves badly with resizing.
What I wrote here was wrong, changing quality has no effect whatsoever, because it’s a lossless format. ut there is a resizing, so I would expect the size to go down, but it goes up. You can find the file here.

transcendance_tranquility
Output of mediainfo:

File size : 3.48 MiB
Image
Format : GIF
Format/Info : Graphics Interchange Format
Format profile : 89a
Width : 512 pixels
Height : 512 pixels
Compression mode : Lossless

 3.6M ├──􀅣  transcendance_tranquility.gif 
 1.1M ├──􀅣  transcendance_tranquility_hu6a45a5541c100ecb57e6befebaaf963a_3645068_200x0_resize_q100_lanczos_1.gif 
 4.8M ├──􀅣  transcendance_tranquility_hu6a45a5541c100ecb57e6befebaaf963a_3645068_400x0_resize_q100_lanczos_1.gif 
  17K └──􀅣  transcendance_tranquility_hu6a45a5541c100ecb57e6befebaaf963a_3645068_e72cfcef49f564dcace829ea0d9adac8.gif  
1 Like

Animated GIFs has a concept of both global and local colour palettes, which I guess could make a given encoder implementation (the one you used for the source GIF) more effective than the one we use (the one in Go’s stdlib).

1 Like

Then I’ll convert to avif or webp animated.
Issue solved, somewhat :upside_down_face:
ps: I messed up and erased my post, ahahah. ok no resizing, and out with gifs.

Conceptually that makes no sense. So the answer is… no.

As a gut check on the final file size…

1) Use Hugo to resize original.gif to 400x400. The resulting file size is 4,850,187.

2) Use ImageMagick to split original.gif into its component frames, producing 54 GIF images. The total file size is 6,000,142.

convert original.gif frame-%02d.gif

3) Use ImageMagick to create an animated GIF image from the 54 images we produced above. The resulting file size is 5,958,696.

convert -delay 1 -loop 0 -dispose previous *.gif new.gif

4) Use Hugo to resize new.gif to 400x400. The resulting file size is 4,850,187.

#1 and #4 produce the same file size.

That means hugo’s library and imagemagick are equivalent, ok, but does not explain why both manage to increase the size, be less efficient that this image’s native format or whatever. also, I tried gif2-webp, which is provided by google, and also converting to avif with ffmpeg. Everything increases the size, from double to triple…

If that bothers you, just stick with GIF.

Where did the file come from? Did you create it?

No, a friend found it on internet, on image boards. Its origin probably lost in the mists of time. Maybe predating internet and mankind, who knows.

OK, here’s what I think happened.

Once upon a time someone created the animated GIF. Each frame of the GIF is LZW compressed, per the GIF specification.

Then they “optimized” the animated GIF, using a local tool or one of the many, free online services. These apps optimize via LOSSY compression of each frame (reducing file size), then re-encode to LZW (LOSSLESS) per the GIF spec.

I used one these services to “optimize” the file created in Step 2 above, and the result was around 4 MB.

Okay, I converted with
gif2webp -q 100 -min_size -mt -loop_compatibility transcendance_tranquility.gif -o transcendance_tranquility.webP
and of course I get

error calling Resize: image “/home/drm/Images/memes/transcendance_tranquility.webp”: resize /Images/memes/transcendance_tranquility.webp: webp: invalid format

No comment… The same that happened with transparent webp and gimp once. except this time, cwebp fails because it’s animated.

before someone asks, the exif infos:

ExifTool Version Number : 12.60
File Name : transcendance_tranquility.webp
Directory : .
File Size : 4.4 MB
File Modification Date/Time : 2023:06:12 18:05:10+02:00
File Access Date/Time : 2023:06:12 18:01:55+02:00
File Inode Change Date/Time : 2023:06:12 18:05:10+02:00
File Permissions : -rw-r–r–
File Type : Extended WEBP
File Type Extension : webp
MIME Type : image/webp
WebP Flags : Animation
Image Width : 512
Image Height : 512
Background Color : 168 156 105 255
Animation Loop Count : inf
Duration : 1.62 s
Image Size : 512x512
Megapixels : 0.262

nothing special seemingly. I hope one day there will be one format to rule them all…