It declares that a GIF file usually has a .gif extension and uses
little-endian integer encoding. The file itself starts with two
blocks: first comes header and then comes logical_screen:
This .ksy file can be compiled
into gif.cpp / Gif.cs / gif.go
/ Gif.java / Gif.js / gif.lua
/ gif.nim / Gif.pm / Gif.php
/ gif.py / gif.rb and
then one can instantly load a .gif file and access, for example, its
width and height.
std::ifstream ifs("path/to/some.gif", std::ifstream::binary);
kaitai::kstream ks(&ifs);
gif_t g = gif_t(&ks);
std::cout << "width = " << g.logical_screen()->image_width() << std::endl;
std::cout << "height = " << g.logical_screen()->image_height() << std::endl;
Gif g = Gif.FromFile("path/to/some.gif");
Console.WriteLine("width = " + g.LogicalScreen.ImageWidth);
Console.WriteLine("height = " + g.LogicalScreen.ImageHeight);
file, err := os.Open("path/to/some.gif")
g := NewGif()
err = g.Read(kaitai.NewStream(file), nil, g)
fmt.Printf("width = %d\n", g.LogicalScreen.ImageWidth)
fmt.Printf("height = %d\n", g.LogicalScreen.ImageHeight)
Gif g = Gif.fromFile("path/to/some.gif");
System.out.println("width = " + g.logicalScreen().imageWidth());
System.out.println("height = " + g.logicalScreen().imageHeight());
var g = new Gif(new KaitaiStream(someArrayBuffer));
console.log("width = " + g.logicalScreen.imageWidth);
console.log("height = " + g.logicalScreen.imageHeight);
local g = Gif:from_file("path/to/some.gif")
print("width = " .. g.logical_screen.image_width)
print("height = " .. g.logical_screen.image_height)
let g = Gif.fromFile("path/to/some.gif")
echo "width = " & $g.logicalScreen.imageWidth
echo "height = " & $g.logicalScreen.imageHeight
my $g = Gif->from_file("path/to/some.gif");
print("width = ", $g->logical_screen()->image_width(), "\n");
print("height = ", $g->logical_screen()->image_height(), "\n");
$g = Gif::fromFile("path/to/some.gif");
print("width = " . $g->logicalScreen()->imageWidth() . "\n");
print("height = " . $g->logicalScreen()->imageHeight() . "\n");
g = Gif.from_file("path/to/some.gif")
print("width = %d" % (g.logical_screen.image_width))
print("height = %d" % (g.logical_screen.image_height))
g = Gif.from_file("path/to/some.gif")
puts "width = #{g.logical_screen.image_width}"
puts "height = #{g.logical_screen.image_height}"
let bytes = fs::read("path/to/some.gif").unwrap();
let io = BytesReader::from(bytes);
let g: OptRc<Gif> = Gif::read_into(&io, None, None).unwrap();
println!("width = {}", *g.logical_screen().image_width());
println!("height = {}", *g.logical_screen().image_height());