Read and write Netpbm images from Go programs

netpbm

Build Status Go Report Card GoDoc

Introduction

netpbm is a package for the Go programming language that implements image decoders and encoders for the Netpbm image formats. The package supports all of the following:

  • All of the Netpbm image formats:

    • PBM (portable bitmap): black and white only
    • PGM (portable graymap): grayscale
    • PPM (portable pixmap): color
    • PAM (portable arbitrary map): alpha
  • Both "raw" (binary) and "plain" (ASCII) files

  • Both 8-bit and 16-bit color channels

  • Any maximum per-color-channel value (up to what the given number of bits can represent)

  • Full compatibility with Go's image package

    • Implements the image.Image interface
    • Additionally defines Opaque, PixOffset, Set, and Subimage methods (and color-model-specific variants of At and Set), like most of Go's standard image types
  • Automatic promotion of image formats, if desired

That last feature means that a program that expects to read a grayscale image can also be given a black-and-white image, and a program that expects to read a color image can also be given either a grayscale or a black-and-white image.

Installation

Instead of manually downloading and installing netpbm from GitHub, the recommended approach is to ensure your GOPATH environment variable is set properly then issue a

go get github.com/spakin/netpbm

command.

Usage

netpbm works just like the standard image/gif, image/jpeg, and image/png packages in that

import (
    _ "github.com/spakin/netpbm"
)

will enable image.Decode to import Netpbm image formats.

Various package-specific functions, types, interfaces, and methods are available only with a normal (not "_") import. A normal import is needed both to export Netpbm images and to exert more precise control over the Netpbm variants that are allowed to be imported. See the netpbm API documentation for details.

Author

Scott Pakin, [email protected]

Similar Resources

Convert images to computer generated art using delaunay triangulation.

Convert images to computer generated art using delaunay triangulation.

▲ Triangle is a tool for generating triangulated image using delaunay triangulation. It takes a source image and converts it to an abstract image comp

Dec 29, 2022

Emoji images for Ebiten

Emoji images for Ebiten

Ebiten Emoji Alpha version: The API is not stable yet Package emoji provides Emoji images for Ebiten. Usage func (*YourGame) Draw(screen *ebiten.Image

Dec 11, 2022

An experiment in rendering images with Slack custom emojis.

An experiment in rendering images with Slack custom emojis.

emojimage An experiment in rendering images with Slack custom emojis. Example Usage 1. Initializing your workspace First, you'll need to upload 1,332

Mar 12, 2022

a tool to output images as RGB ANSI graphics on the terminal

a tool to output images as RGB ANSI graphics on the terminal

imgcat Tool to output images in the terminal. Built with bubbletea install homebrew brew install trashhalo/homebrew-brews/imgcat prebuilt packages Pr

Dec 28, 2022

Image compression codec for 16 bit medical images

MIC - Medical Image Codec This library introduces a lossless medical image compression codec MIC for 16 bit images which provides compression ratio si

Dec 26, 2021

Small project to convert images to grayscale

This is a small http server that will read images from a provided path, convert the image to gray, and then serve back the converted image Usage You c

Nov 5, 2021

Cryptseaside generates seaside images using Unix nanoseconds as the seed value.

Cryptseaside generates seaside images using Unix nanoseconds as the seed value.

Cryptseaside Welcome to the Cryptseaside project. Cryptseaside generates seaside images using Unix nanoseconds as the seed value.

Nov 12, 2021

Repaint images by sorting pixels by colour

Repaint images by sorting pixels by colour

Every Frame A Painting Sorts pixels in an image by colour and redraws the image

Jan 5, 2022

Provides a method to create thumbnails from provided images.

Thumbnail Generation Package for Go This package provides method to create thumbnails from provided images. Installation Use to go command: $ go get g

Aug 31, 2022
Comments
  • no output when using format PNM

    no output when using format PNM

    i get nothing read and no error, (although i see in the code it is trying to send to stderr a message, it doesn't seem to be output, for me anyway.)

    seems to me that when PNM option then it should use the images netbpm format (if one of these), then use PAM as nil option does.

  • hard work to use when trying to 'encode' from just an image interface.

    hard work to use when trying to 'encode' from just an image interface.

    i have tried to add the netpbm formats support to an existing format converter program.

    but i am finding the design of having the format specified in the EncodeOptions and not by having individual calls, as in the Std.Lib., a problem;

    if a user wants to convert to a specified format, i need to set it in the EncodeOptions, but i can't because i need a MaxValue value as, i understand, would by provided internally by the nil option.(using the sources value or a default value for others.)

    i could do this; check for a netpbm type, use its MaxValue, otherwise set a default value, but this seems like unnecessary duplication.

    note: this is also a problem with using comment and plain, again you need the MaxValue.

    but there seems to be a clean solution;

    when EncodeOptions.MaxValue == 0 then set it the same way as when EncodeOption is nil.

Related tags
Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket

Features Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket Environment Variables IMAGE_SIZES - formax 200x20

Feb 2, 2022
Fast and secure standalone server for resizing and converting remote images

imgproxy imgproxy is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, sp

Jan 1, 2023
Resize images and animated GIFs in Go

Lilliput relies on mature, high-performance C libraries to do most of the work of decompressing, resizing and compressing images. It aims to do as little memory allocation as possible and especially not to create garbage in Go. As a result, it is suitable for very high throughput image resizing services.

Jan 3, 2023
A go library for reading and creating ISO9660 images

iso9660 A package for reading and creating ISO9660, forked from https://github.com/kdomanski/iso9660. Requires Go 1.13 or newer. Joliet and Rock Ridge

Mar 4, 2021
A cross-platform tool to convert images into ascii art and print them on the console
A cross-platform tool to convert images into ascii art and print them on the console

A cross-platform tool to convert images into ascii art and print them on the console

Dec 30, 2022
Cloud function + website for resizing, cropping and bordering images for pragalicious.com

Cloud function + website for resizing, cropping and bordering images for pragalicious.com

Jan 23, 2022
Pure Golang Library that allows simple LSB steganography on images
Pure Golang Library that allows simple LSB steganography on images

Steganography Lib Steganography is a library written in Pure go to allow simple LSB steganography on images. It is capable of both encoding and decodi

Dec 22, 2022
Reproducing images with geometric primitives.
Reproducing images with geometric primitives.

Primitive Pictures Reproducing images with geometric primitives. How it Works A target image is provided as input. The algorithm tries to find the sin

Dec 31, 2022
An iterative algorithm to generate high quality triangulated images.
An iterative algorithm to generate high quality triangulated images.

Triangula uses a modified genetic algorithm to triangulate images. It works best with images smaller than 3000px and with fewer than 3000 points, typically producing an optimal result within a couple of minutes.

Jan 8, 2023
Generate high-quality triangulated art from images.
Generate high-quality triangulated art from images.

An iterative algorithm to generate high quality triangulated images.

May 26, 2021