{{pkg.description}}
Similar to the NetPBM formats, the Portable FloatMap image format is extremely simple, uncompressed and mainly interesting for development purposes & interchange (e.g. for use with Intel's Open Image Denoise CLI tools).
{{meta.status}}
{{repo.supportPackages}}
{{repo.relatedPackages}}
{{meta.blogPosts}}
{{pkg.install}}
{{pkg.size}}
{{pkg.deps}}
{{repo.examples}}
{{pkg.docs}}
The package only provides 2 functions:
asPFM(img: IntBuffer | FloatBuffer, littleEndian?: boolean, linearRGB?: boolean): Uint8Array
: Serializes an image to PFM and returns result as byte arrayreadPFM(buf: Uint8Array, linearRGB?: boolean): FloatBuffer
: Parses byte array as PFM image and returns it asFloatBuffer
import { intBuffer, RGB888 } from "@thi.ng/pixel";
import { asPFM } from "@thi.ng/pixel-io-pfm";
import { writeFileSync } from "node:fs";
// create 2x2 image
const img = intBuffer(2, 2, RGB888);
// set all 4 pixels (in order: red, green, blue, yellow)
img.data.set([0xff0000, 0x00ff00, 0x0000ff, 0xffff00]);
// serialize image to PFM byte array and write to file
// (format conversion to FLOAT_RGB is done automatically & non-destructively)
writeFileSync("export/rgby.pfm", asPFM(img));