Snapshot of discord/lilliput: 2.1k★, C++, Image Tools. Resize images and animated GIFs in Go
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
As of October 2026, discord/lilliput is no longer used at Discord and is
unmaintained. There will be no further releases, including for security
vulnerabilities. Issues and pull requests are not being reviewed.
We are working on a Rust implementation and will link it here when it is
public. We are not committing to a date, and this notice does not depend on
it.
This repository is not in scope for Discord's security bug bounty program.
See SECURITY.md for how to report a vulnerability in this code.
The code remains under the MIT license. Forking is encouraged, and we are
happy to link a community-maintained fork from this README. See
#303 for details.
lilliput resizes images in Go.
Lilliput relies on mature, high-performance C libraries to do most of the work of
decompressing, resizing and compressing images. It aims to do as little memory
allocation as possible and especially not to create garbage in Go. As a result,
it is suitable for very high throughput image resizing services.
Lilliput supports resizing JPEG, PNG, WebP (both static and animated), AVIF (both static and animated), and animated GIFs. It can also convert between these formats.
Lilliput also has some support for getting the first frame from MOV and WEBM
videos.
Lilliput presently only supports OSX ARM64 and Linux.
Example
Lilliput comes with a fully working example that runs on the command line. The
example takes a user supplied filename and prints some basic info about the file.
It then resizes and transcodes the image (if flags are supplied) and saves the
resulting file.
To use the example, go get github.com/discord/lilliput and then run
go build from the examples/ directory.
License
Lilliput is released under MIT license (see LICENSE). Additionally, lilliput ships with other
libraries, each provided under its own license. See third-party-licenses for
more info.
Usage
First, import "github.com/discord/lilliput".
Decoder
Lilliput is concerned with in-memory images, so the decoder requires image
data to be in a []byte buffer.
Create a new Decoder object from the compressed image contained by buf.
This will return an error when the magic bytes of the buffer don't match
one of the supported image types.
Read and return the image's header. The header contains the image's metadata.
Returns error if the image has a malformed header. An image with a malformed
header cannot be decoded.
func (d lilliput.Decoder) Description() string
Returns a string describing the image's type, e.g. "JPEG" or "PNG".
Fully decodes the image and writes its pixel data to f. Returns an error
if the decoding process fails. If the image contains multiple frames,
then each call returns a subsequent frame. io.EOF is returned when the image
does not contain any more data to be decoded.
Users of lilliput generally should not call DecodeTo and should instead
use an ImageOps object.
func (d lilliput.Decoder) Close()
Closes the decoder and releases resources. The Decoder object must have
.Close() called when it is no longer in use.
ImageOps
Lilliput provides a convenience object to handle image resizing and encoding from an
open Decoder object. The ImageOps object can be created and then reused, which reduces memory
allocations. Generally, users should prefer the ImageOps object over manually controlling
the resize and encode process.
Transform the compressed image contained in a Decoder object into the desired output type. The decoder must not
have DecodeTo() called on it already. However, it is ok to call decoder.Header() if you would like to check
image properties before transforming the image. Returns an error if the resize or encoding process fails.
The resulting compressed image will be written into dst. The returned []byte
slice will point to the same region as dst but with a different length, so that you can tell where the image ends.
Fields for lilliput.ImageOptions are as follows
FileType: file extension type, e.g. ".jpeg"
Width: number of pixels of width of output image
Height: number of pixels of height of output image
ResizeMethod: one of lilliput.ImageOpsNoResize or lilliput.ImageOpsFit. Fit behavior
is the same as Framebuffer.Fit() -- it performs a cropping resize that does not stretch the image.
NormalizeOrientation: If true, Transform() will inspect the image orientation and
normalize the output so that it is facing in the standard orientation. This will undo
JPEG EXIF-based orientation.
EncodeOptions: Of type map[int]int, same options accepted as Encoder.Encode(). This
controls output encode quality.
func (o *lilliput.ImageOps) Clear()
Clear out all pixel data contained in ImageOps object from any previous operations.
This function does not need to be called between Transform() calls. The user may choose
to do this if they want to remove image data from memory.
func (o *lilliput.ImageOps) Close()
Close the ImageOps object and release resources. The ImageOps object must have .Close() called when it is no longer in use.
ImageHeader
This interface returns basic metadata about an image. It is created by
calling Decoder.Header().
Returns the metadata-based orientation of the image. This function can
be called on all image types but presently only detects orientation in
JPEG images. An orientation value of 1 indicates default orientation.
All other values indicate some kind of rotation or mirroring.
PixelType
func (p lilliput.PixelType) Depth() int
Returns the number of bits per pixel.
func (p lilliput.PixelType) Channels() int
Returns the number of channels per pixel, e.g. 3 for RGB or 4 for RGBA.
Framebuffer
This type contains a raw array of pixels, decompressed from an image.
In general, you will want to use the ImageOps object instead of operating on
Framebuffers manually.
Rotate and/or mirror framebuffer according to orientation value. If you
pass the orientation value given by the image's ImageHeader, then the
resulting image has its orientation normalized to the
default orientation.
Perform a resize into dst of f according to given dimensions. This function does not
preserve the source's aspect ratio if the new dimensions have a different ratio. The
resize can fail if the destination is not large enough to hold the new image.
Perform a cropping resize into dst of f according to given dimensions. This function
does preserve the source's aspect ratio. The image will be cropped along one axis if
the new dimensions have a different ratio than the source. The cropping will occur equally
on the edges, e.g. if the source image is too tall for the new ratio, then the destination will
have rows of pixels from the top and bottom removed. Returns error if the destination is
not large enough to contain the resized image.
func (f *lilliput.Framebuffer) Close()
Closes the framebuffer and releases resources. The Framebuffer object must have .Close() called when it is no longer in use.
Encoder
The Encoder takes a Framebuffer and writes the pixels into a compressed format.
Create a new Encoder object that writes to dst. extension should be a file extension-like string,
e.g. ".jpeg" or ".png". decodedBy should be the Decoder used to decompress the image, if any.
decodedBy may be left as nil in most cases but is required when creating a .gif encoder. That is,
.gif outputs can only be created from source GIFs.
func (e lilliput.Encoder) Encode(buffer lilliput.Framebuffer, opts map[int]int) ([]byte, error)
Encodes the Framebuffer supplied into the output dst given when the Encoder was created. The
returned []byte will point to the same buffer as dst but can be a shorter slice, so that if dst
has 50MB of capacity but the image only occupies 30KB, you can tell where the image data ends. This
function returns an error if the encoding process fails.
opts is optional and may be left nil. It is used to control encoder behavior
e.g. map[int]int{lilliput.JpegQuality: 80} to set JPEG outputquality to 80.
Valid keys/values for opts are
JpegQuality (1 - 100)
PngCompression (0 - 9)
WebpQuality (0 - 100).
AvifQuality (0 - 100)
func (e lilliput.Encoder) Close()
Close the Encoder and release resources. The Encoder object must have .Close() called when it is no longer in use.
Building Dependencies
Go does not provide any mechanism for arbitrary building of dependencies, e.g. invoking
make or cmake. In order to make lilliput usable as a standard Go package, prebuilt
static libraries have been provided for all of lilliput's dependencies on Linux and
OSX. In order to automate this process, lilliput ships with build scripts alongside
compressed archives of the sources of its dependencies. These build scripts are provided
for OSX and Linux.
The most recent commit recorded on discord/lilliput was 17 days ago, based on the GitHub push timestamp. The repository has 128 forks — one of the better signals of community interest.
How does discord/lilliput compare to other Image Tools projects?
discord/lilliput is tracked by TopGit in the Image Tools category, with 2.1k GitHub stars and written in C++. Browse the Image Tools topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does discord/lilliput have?
discord/lilliput has 2.1k GitHub stars — refresh the page for the live number, or check github.com/discord/lilliput. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is discord/lilliput open source?
TopGit's metadata for discord/lilliput does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What is discord/lilliput?
discord/lilliput (discord/lilliput) is a C++ project on GitHub. From the project's own README: Resize images and animated GIFs in Go
Where do I read more about discord/lilliput?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/discord/lilliput is the definitive source.
Read full README in the tab above.
Want a second opinion on lilliput?
Ask an AI that can read this page — one click and you get its take on lilliput.