Converter for Telegram stickers and animations into various formats.
Go to file
eugene ad939717ad refactor 2025-09-10 20:08:33 +03:00
cmd refactor 2025-09-10 20:08:33 +03:00
tgs refactor 2025-09-10 20:08:33 +03:00
webm refactor 2025-09-10 20:08:33 +03:00
webp refactor 2025-09-10 20:08:33 +03:00
.gitignore init commit 2025-09-05 22:14:40 +03:00
Makefile package refactor 2025-09-08 21:37:35 +03:00
README.md refactor 2025-09-10 20:08:33 +03:00
go.mod init commit 2025-09-05 22:14:40 +03:00
go.sum init commit 2025-09-05 22:14:40 +03:00
tgs.go refactor 2025-09-10 20:08:33 +03:00
types.go package refactor 2025-09-08 21:37:35 +03:00
webm.go package refactor 2025-09-08 21:37:35 +03:00
webp.go refactor 2025-09-10 20:08:33 +03:00

README.md

Telegram sticker converter

Required system binaries

  • ffmpeg 7.1.1

Build requirements

  • Go 1.24

Supported formats

  • TGS
  • WEBP
  • WEBM

Supported transformations

Input Output formats
TGS PNG (first frame, all frames, N frame, frame range)
JPEG (first frame, all frames, N frame, frame range)
WEBP (first frame, all frames, N frame, frame range)
Lottie JSON
GIF
WEBM
MP4
WEBP PNG
JPEG
WEBM MP4
GIF
PNG (first frame, all frames, N frame, frame range)
JPEG (first frame, all frames, N frame, frame range)
WEBP (first frame, all frames, N frame, frame range)

Examples

Extract frame from TGS

package main
import (
	"context"
	"os"

	converter "github.com/yazmeyaa/telegram_sticker_converter"
	"github.com/yazmeyaa/telegram_sticker_converter/tgs"
)


func main() {
	conv := tgs.NewConverter()

	r, err := os.Open("./sticker.tgs")
	defer r.Close()
	w, err := os.Create("./sticker.png")
	defer w.Close()
	opts := converter.TGSTransformOptions{
		Format:       converter.FormatPNG,
		Frame:        converter.FrameN,
		FrameIndex:   10,
		ResizeWidth:  1024,
		ResizeHeight: 1024,
	}
	if err := conv.Transform(context.Background(), r, w, opts); err != nil {
		panic(err)
	}
}

Convert TGS to video

package main
import (
	"context"
	"os"

	converter "github.com/yazmeyaa/telegram_sticker_converter"
	"github.com/yazmeyaa/telegram_sticker_converter/tgs"
)


func main() {
	conv := tgs.NewConverter()

	r, err := os.Open("./sticker.tgs")
	defer r.Close()
	w, err := os.Create("./sticker.mp4")
	defer w.Close()
	opts := converter.TGSTransformOptions{
		Format:       converter.FormatMP4,
		ResizeWidth:  1024,
		ResizeHeight: 1024,
	}
	if err := conv.Transform(context.Background(), r, w, opts); err != nil {
		panic(err)
	}
}

Convert TGS to frames array (ZIP)

package main
import (
	"context"
	"os"

	converter "github.com/yazmeyaa/telegram_sticker_converter"
	"github.com/yazmeyaa/telegram_sticker_converter/tgs"
)


func main() {
	conv := tgs.NewConverter()

	r, err := os.Open("./sticker.tgs")
	defer r.Close()
	w, err := os.Create("./sticker.zip")
	defer w.Close()
	opts := converter.TGSTransformOptions{
		Format:       converter.FormatPNG,
        Frame:        converter.FrameAll,
		ResizeWidth:  1024,
		ResizeHeight: 1024,
	}
	if err := conv.Transform(context.Background(), r, w, opts); err != nil {
		panic(err)
	}
}