Check a thumbnail buffer before allocation
Encoded file size gives a poor estimate of decoded thumbnail memory. Account for output dimensions and scanline padding before allocating. A 400×200 image fits into 100×50 pixels. Three channels and four-byte alignment require 15,000 bytes, above the given budget.
Run the framework with your own input
Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-hoopoe.git
cd blyx-hoopoe
blyxc native-run project.blyx -- 400 200 100 100 3 4 14000API and return values
Returns [output width, output height, aligned stride, bytes, fits budget]. Includes one output buffer with one byte per channel. Decoder and encoder overhead are outside this estimate. Invalid input returns an empty vector.
| Argument | Accepted input |
|---|---|
| width | positive exact integer |
| height | positive exact integer |
| box_w | positive exact integer |
| box_h | positive exact integer |
| channels | positive exact integer |
| align | positive exact integer |
| memory | nonnegative exact integer |
Use the libraries independently
The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.
Try the program
Expected output
100 50 300 15000 0
Practice
Change width = 3.0, height = 2.0, box_w = 10.0, box_h = 10.0, memory = 24.0. Predict the result, then run the program.
Hint
Returns [output width, output height, aligned stride, bytes, fits budget]. Includes one output buffer with one byte per channel. Decoder and encoder overhead are outside this estimate.
Worked solution
The result vector is [3, 2, 12, 24, 1]. Compare its fields with the return layout in the API section.
Find
let width = 400.0;Replace with
let width = 3.0;Find
let height = 200.0;Replace with
let height = 2.0;Find
let box_w = 100.0;Replace with
let box_w = 10.0;Find
let box_h = 100.0;Replace with
let box_h = 10.0;Find
let memory = 14000.0;Replace with
let memory = 24.0;Output after the change
3 2 12 24 1
