Abstract
- Why we needed to implement GIF resizing in pure Go (5 min)
-- Self Introduction
-- Introducing traQ (https://github.com/traPtitech/traQ), a web application I had maintained
-- Explain why we wanted to get rid of ImageMagick
--- Wanted to replace base image with distroless due to security concerns, but blocked by ImageMagick library installation
--- Docker image size was large (over 600MiB), but we don't utilize most of the library
- (1) Basic resizing implementation (5 min)
-- Image resizing with the `golang.org/x/image/draw` package
-- Basic structure of `*(image/gif).GIF` struct
-- Implementation: https://github.com/logica0419/proposals/blob/main/GopherCon2024/step1.go
- (2) Handling frame optimization (5 min)
-- What is frame optimization?
-- How frame optimization affects the`*(image/gif).GIF` struct
--- Each frame is trimmed
--- Frame size differs in each frame
-- Calculating frame size for each frame
--- Calculate the resize ratio for width & height
--- Calculate the resized frame size for each frame
-- Implementation: https://github.com/logica0419/proposals/blob/main/GopherCon2024/step2.go
- (3) Handling black glitchy noise (10 min)
-- Simple explanation of image resizing algorithm and its implementation in Go
-- Problem of transparent pixel handling
-- Frame stacking before resizing
-- Implementation: https://github.com/logica0419/proposals/blob/main/GopherCon2024/step3.go
- (4) Handling frame disposal (10 min)
-- GIF frame disposal specification
--- None: keep stacked frame to the next frame
--- Background: fill the canvas with background color after the current frame rendering
--- Previous: put back canvas to the previous condition
-- Handling frame disposal in Go
--- After-resize processing for the temporary canvas
-- Implementation: https://github.com/logica0419/proposals/blob/main/GopherCon2024/step4.go
- Conclusion (10 min)
-- Summary of the implementation
-- A little explanation of parallelization of resizing
--- The resizing step is the slowest
--- Frame stacking can't be parallelized (must be in order)
--- Wrapping only resizing step with goroutine
-- Effect on our app
--- Docker image shrinks down (40~50% in size)
--- Able to move on to distroless
--- Performance improvement (x3 faster in same CPU usage)
--- Able to select the resizing kernel
-- Introducing resigif (https://github.com/logica0419/resigif) library as a result of work.