Expand description
How to use from C
gifski *g = gifski_new(&(GifskiSettings){
.quality = 90,
});
gifski_set_file_output(g, "file.gif");
for(int i=0; i < frames; i++) {
// added frames will be sorted by the `i` index
int res = gifski_add_frame_rgba(g, i, width, height, buffer, 5);
if (res != GIFSKI_OK) break;
}
int res = gifski_finish(g);
if (res != GIFSKI_OK) return;It’s safe and efficient to call gifski_add_frame_* in a loop as fast as you can get frames,
because it blocks and waits until previous frames are written.
To cancel processing, make progress callback return 0 and call gifski_finish(). The write callback
may still be called between the cancellation and gifski_finish() returning.
To build as a library:
cargo build --release --libit will create target/release/libgifski.a (static library)
and target/release/libgifski.so/dylib or gifski.dll (dynamic library)
Static is recommended.
To build for iOS:
rustup target add aarch64-apple-ios
cargo build --release --lib --target aarch64-apple-iosit will build target/aarch64-apple-ios/release/libgifski.a (ignore the warning about cdylib).
Structs§
- ARGB8
- Gifski
Handle - Opaque handle used in methods. Note that the handle pointer is actually
Arc<GifskiHandleInternal>, butArc::into_rawis nice enough to point past the counter. - Gifski
Handle Internal - Gifski
Settings - Settings for creating a new encoder instance. See
gifski_new
Functions§
- gifski_
add_ ⚠fixed_ color - Adds a fixed color that will be kept in the palette at all times.
- gifski_
add_ ⚠frame_ argb - Same as
gifski_add_frame_rgba, except it expects components in ARGB order. - gifski_
add_ ⚠frame_ png_ file - Insert a new frame at the position of
frame_number. - gifski_
add_ ⚠frame_ rgb - Same as
gifski_add_frame_rgba, except it expects RGB components (3 bytes per pixel). - gifski_
add_ ⚠frame_ rgba - Insert a new frame at the position of
frame_number. - gifski_
add_ ⚠frame_ rgba_ stride - Same as
gifski_add_frame_rgba, but with bytes per row arg. - gifski_
finish ⚠ - The last step:
- gifski_
new ⚠ - Call to start the process
- gifski_
set_ ⚠error_ message_ callback - Get a callback when an error occurs. This is intended mostly for logging and debugging, not for user interface.
- gifski_
set_ ⚠extra_ effort - If
true, encoding will be significantly slower, but may look a bit better. - gifski_
set_ ⚠file_ output - Start writing to the
destination. This has to be called before any frames are added. - gifski_
set_ ⚠lossy_ quality - Quality 1-100 of gifsicle compression. Lower values add noise. Defaults to
settings.quality. - gifski_
set_ ⚠motion_ quality - Quality 1-100 of temporal denoising. Lower values reduce motion. Defaults to
settings.quality. - gifski_
set_ ⚠progress_ callback - Get a callback for frame processed, and abort processing if desired.
- gifski_
set_ ⚠write_ callback - Start writing via callback (any buffer, file, whatever you want). This has to be called before any frames are added. This call will not block.