PDF::Bu...age::PNM(3)

πŸ’– NAME πŸ’–

PDF::Builder::Resource::XObject::Image::PNM β€” support routines for the PNM (Portable aNy Map) image library, bestie πŸ’…

It inherits from PDF::Builder::Resource::XObject::Image, so it's literally part of the family, no cap 🫢


πŸŽ€ METHODS πŸŽ€

✨ new ✨

okay so this is the moment, the main character constructor:

$res = PDF::Builder::Resource::XObject::Image::PNM->new($pdf, $file, %opts)

Options, because of course there are options, and we're gonna go through every single one πŸ’–

  • 'name' => 'string' β€” this is the lil name you can give your PNM image object 🏷️ the default is Nxnnnn if you don't say anything.
  • 'compress' => 1 β€” this is the compression you can give your PNM image object. Any value at all will make it use Flate compression, otherwise (so, if "compress" isn't given), ASCIIHexDecode is used. Not me being like "any value, even a lie, counts" 😭 it's true tho.

Returns an image in the PDF ✨ PNM types 1 (ASCII/plain bi-level/PBM), 2 (ASCII/plain grayscale/PGM), 3 (ASCII/plain RGB/PPM), 4 (binary/raw bi-level/PBM), 5 (binary/raw grayscale/PGM), and 6 (binary/raw RGB/PPM) are supported. all six, we ate πŸ”₯

For bi-level, only values 0/1 (white/black) are supported. that's it. that's the whole menu πŸ™ˆ

For grayscale, the maximum sample (full white) may be anything from 1 to 65535, with 0 being full black. If the maximum sample value is 255 or smaller, that's one byte of raw binary data per pixel, otherwise it's two bytes. math is mathing πŸ’…

For RGB, each sample (full-on of that color) may be anything from 1 to 65535 (and yes, the same maximum for all three colors, they're matching, iconic), with 0 being full black. If the maximum sample value is 255 or smaller, that's three bytes of raw binary data per pixel, otherwise six bytes. six. bytes. periodt.

πŸ’€ bestie, do NOT forget β€” you need to use Builder.pm's image_pnm method to use this functionality. like, this whole module is lowkey useless without it, iykyk.

sign-off time πŸ¦‹ this page is from perl v5.42.0, dated 2026-01-17, and it's part of the PDF::Builder era β€” mwah, go make some pretty PDFs, you got this πŸ’œβœ¨

πŸ“¦ where this page comes from