New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/hexaflex/pnm

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hexaflex/pnm

  • v0.0.0-20200810192450-e891a41ac33b
  • Source
  • Go
  • Socket score

Version published
Created
Source

pnm

This package implements an encoder and decoder for PNM image formats. It can be used with Go's image library. It covers all formats as defined by the 'P1' to 'P6' specifications.

File formats

Each format differs in what colors it is designed to represent:

  • PBM is for bitmaps (black and white, no grays).
  • PGM is for grayscale.
  • PPM is for "pixmaps" which represent full RGB color.

Each file starts with a two-byte magic number (in ASCII) that identifies the type of file it is (PBM, PGM, and PPM) and its encoding (ASCII or binary). The magic number is a capital P followed by a single-digit number.

Magic NumberTypeEncoding
P1bitmapASCII
P2graymapASCII
P3pixmapASCII
P4bitmapBinary
P5graymapBinary
P6pixmapBinary

The ASCII formats allow for human readability and easy transfer to other platforms (so long as those platforms understand ASCII), while the binary formats are more efficient both in file size and in ease of parsing, due to the absence of whitespace.

In the binary formats, PBM uses 1 bit per pixel, PGM uses 8 bits per pixel, and PPM uses 24 bits per pixel: 8 for red, 8 for green, 8 for blue.

Usage

go get github.com/hexaflex/pnm


import "image"
import _ "github.com/hexaflex/pnm"

...
img, format, err := image.Decode("myfile.pnm)
...

References

  • Netpbm

License

Unless otherwise stated, all of the work in this project is subject to a 3-clause BSD license. Its contents can be found in the enclosed LICENSE file.

FAQs

Package last updated on 10 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc