datauri

module
v0.0.0-...-8f01f07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2025 License: MIT

README

datauri

A friendly little CLI tool for turning files, URLs, or stdin into base64-encoded data URIs. Handy for web devs, tinkerers, and anyone who wants to embed images or files directly in HTML, CSS, or other text formats.

Features

  • Detects MIME type from file content or extension
  • Accepts input from a file, URL, or stdin (use - for stdin)
  • Lets you override or choose the MIME type if there's ambiguity
  • Outputs a valid data URI to stdout

Usage

# From a file
datauri my-image.png

# From a URL
datauri https://example.com/image.jpg

# From stdin
cat my-image.png | datauri -

Installation

With Go (requires Go 1.21+)
go install codeberg.org/chessmango/datauri/cmd/datauri@latest

This will put the datauri binary in your $GOBIN (usually ~/go/bin).

With mise
mise use -g ubi:codeberg.org/chessmango/datauri@latest

Changelog

See CHANGELOG.md for release notes (follows Keep a Changelog format).

CI

This project aims to use Woodpecker CI (Codeberg's preferred system) for building and releasing on tags. If you spot a CI badge here, it's working!


PRs, issues, and suggestions welcome. Have fun embedding!

Directories

Path Synopsis
cmd
datauri command
datauri provides a command-line tool for generating data URIs from files or URLs.
datauri provides a command-line tool for generating data URIs from files or URLs.
internal
compare
Package compare provides utilities for selecting and confirming MIME types, including logic to resolve conflicts between detected and file extension-based types.
Package compare provides utilities for selecting and confirming MIME types, including logic to resolve conflicts between detected and file extension-based types.
detect
Package detect provides logic for reading input and detecting MIME types.
Package detect provides logic for reading input and detecting MIME types.
encode
Package encode provides functions for encoding files as base64 data URIs.
Package encode provides functions for encoding files as base64 data URIs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL