A go library for reading and creating ISO9660 images

iso9660

GoDoc

A package for reading and creating ISO9660, forked from https://github.com/kdomanski/iso9660.

Requires Go 1.13 or newer.

Joliet and Rock Ridge extensions are not supported.

Examples

Extracting an ISO

package main

import (
  "log"

  "github.com/KarpelesLab/iso9660/isoutil"
)

func main() {
  f, err := os.Open("/home/user/myImage.iso")
  if err != nil {
    log.Fatalf("failed to open file: %s", err)
  }
  defer f.Close()

  if err = isoutil.ExtractImageToDirectory(f, "/home/user/target_dir"); err != nil {
    log.Fatalf("failed to extract image: %s", err)
  }
}

Creating an ISO

package main

import (
  "log"
  "os"

  "github.com/KarpelesLab/iso9660"
)

func main() {
  writer, err := iso9660.NewWriter()
  if err != nil {
    log.Fatalf("failed to create writer: %s", err)
  }

  // set volume name
  writer.Primary.VolumeIdentifier = "testvol"

  err = writer.AddLocalFile("/home/user/myFile.txt", "folder/MYFILE.TXT")
  if err != nil {
    log.Fatalf("failed to add file: %s", err)
  }

  outputFile, err := os.OpenFile("/home/user/output.iso", os.O_WRONLY | os.O_TRUNC | os.O_CREATE, 0644)
  if err != nil {
    log.Fatalf("failed to create file: %s", err)
  }

  err = writer.WriteTo(outputFile)
  if err != nil {
    log.Fatalf("failed to write ISO image: %s", err)
  }

  err = outputFile.Close()
  if err != nil {
    log.Fatalf("failed to close output file: %s", err)
  }
}

Streaming an ISO via HTTP

It is possible to stream a dynamically generated file on request via HTTP in order to include files or customize configuration files:

import (
  "http"
  "log"

  "github.com/KarpelesLab/iso9660"
)

func ServeHTTP(rw http.RequestWriter, req *http.Request) {
  writer, err := iso9660.NewWriter()
  if err != nil {
    log.Fatalf("failed to create writer: %s", err)
  }

  // set volume name
  writer.Primary.VolumeIdentifier = "LIVE IMAGE"

  if syslinux, err := iso9660.NewItemFile("/pkg/main/sys-boot.syslinux.core/share/syslinux/isolinux.bin"); err == nil {
    writer.AddBootEntry(&iso9660.BootCatalogEntry{BootInfoTable: true}, isolinux, "isolinux/isolinux.bin")
    writer.AddLocalFile("/pkg/main/sys-boot.syslinux.core/share/syslinux/linux.c32", "isolinux/linux.c32")
    writer.AddLocalFile("/pkg/main/sys-boot.syslinux.core/share/syslinux/ldlinux.c32", "isolinux/ldlinux.c32")
  }

  writer.AddLocalFile("kernel.img", "isolinux/kernel.img")
  writer.AddLocalFile("initrd.img", "isolinux/initrd.img")
  writer.AddLocalFile("root.squashfs", "root.img")
  writer.AddFile(getSyslinuxConfig(), "isolinux/isolinux.cfg")

  rw.Header().Set("Content-Type", "application/x-iso9660-image")
  writer.WriteTo(rw)
}
Owner
Similar Resources

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

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
Comments
  • why not udf?

    why not udf?

    Using udftools:

    dd if=/dev/zero of=/home/karpeleslab/image.udf bs=1M count=10
    mkudffs /home/karpeleslab/image.udf
    mkdir -p /mnt/udfmnt
    mount -o loop -t udf /home/karpeleslab/image.udf /mnt/udfmnt
    copy whatever here
    umount /mnt/udfmnt
    

    Using genisoimage with udf switch to create a udf-formatted iso image:

    genisoimage -udf -o /home/karpeleslab/udfimage.iso SOMESOURCEDIR
    

    Don't forget to mention how to burn those images:

    wodim -eject -tao  speed=2 dev=/dev/sr1 -v -data /home/karpeleslab/udfimage.iso
    growisofs -dvd-compat -Z /dev/sr1=/home/karpeleslab/udfimage.iso
    
Related tags
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Dec 30, 2022
Go cross-platform glfw library for creating an OpenGL context and receiving events.

glfw Package glfw experimentally provides a glfw-like API with desktop (via glfw) and browser (via HTML5 canvas) backends. It is used for creating a G

Sep 27, 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
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
Read and write Netpbm images from Go programs

netpbm Introduction netpbm is a package for the Go programming language that implements image decoders and encoders for the Netpbm image formats. The

Dec 29, 2022
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 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
Paprika is a toolbox for creating short clips from multiple png files.
Paprika is a toolbox for creating short clips from multiple png files.

Paprika Paprika is a toolbox for creating short clips from multiple png files. Requirements This program is mainly a wrapper around ffmpeg. As such, y

Feb 16, 2022
Code for creating GIF replays of games played on Woogles.io.

woogles-game-gifs Code for creating GIF replays of games played on Woogles.io. Requirements Go is required to run the gif generator. To install, refer

Jan 31, 2022