<pre data-lang="cpp" data-label="c++">#include &lt;stb.h&gt;

int main() {
    stb::image img = stb::image::open("in.png");        // throws stb::error subclasses

    stb::image small = img.resize(320, 240, "cubic");   // filter by name
    stb::image part  = img.crop(10, 10, 200, 100);      // editing returns a new image
    stb::image turned = img.rotate90();                 // counter-clockwise
    stb::image gray  = img.convert(1);                  // 1..4 channels

    small.write("small.jpg");                           // format from the extension
    stb::font f = stb::font::open("font.ttf");
    stb::text_bitmap t = f.render("hello", 32);         // t.bitmap is a 1-channel image
    t.bitmap.write("hello.png");
}</pre>
