Skip to content

✨ A high-performance, standalone tool for Typora to auto-convert local images to Base64/WebP when exporting HTML. πŸš€ Single-file portability, zero dependencies, support for HTML/Markdown syntax.

Notifications You must be signed in to change notification settings

selectarget/TyporaToBase64RS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Typora Image to Base64 (Rust)

δΈ­ζ–‡ζ–‡ζ‘£

A high-performance, standalone tool designed for Typora to automatically convert local images into Base64 strings when exporting HTML. This ensures your exported documents are single-file and portable, with no external image dependencies.

Features

  • πŸš€ Zero Dependency: Built with Rust, compiles to a single static binary (~1.7MB). No .NET or Java runtime required.
  • πŸ“¦ Smart Compression: Automatically compresses PNG/JPG images to WebP format (Quality 75) to significantly reduce HTML file size (often by 40-60%).
  • πŸ”— Smart Path Resolution: accurately finds images even if Typora doesn't copy assets folder (checks both HTML export location and original Source file location).
  • 🌏 Encoding Support: Auto-detects UTF-8 and GBK/Chinese encodings to prevent file corruption.

How it Works

  1. Scan: Reads the HTML file and uses Regex to locate image tags (supports both HTML <img src> and Markdown ![]() syntax).
  2. Dual Search Strategy:
    • Primary: Looks for the image relative to the exported HTML file.
    • Fallback: If not found, it intelligently checks the original Typora source directory (CWD). This ensures images are found even if the assets folder wasn't exported.
  3. Smart Conversion:
    • Compression: Static images (PNG/JPG/BMP) are re-encoded to WebP to save space.
    • Pass-through: Animated GIFs and SVGs are encoded as-is to preserve animation and vector quality.
  4. Embed: Replaces the image link in the HTML with the generated Base64 data string.
  5. Safety: The tool is Read-Only for your image files. It never modifies or deletes your source images.

Usage

1. Build or Download

If you have Rust installed:

cargo build --release

The executable will be at target/release/TyporaToBase64RS.exe.

2. Configure Typora

  1. Open Typora.

  2. Go to File -> Preferences -> Export.

  3. Select HTML in the list.

  4. In the "Run Command" (or Post-Export Hooks) section, enter:

    "path\to\TyporaToBase64RS.exe" "${outputPath}"

    Make sure to keep the double quotes around the path.

3. Export

Now, whenever you export to HTML, this tool will automatically run, convert your images, and you will get a fully self-contained HTML file.

License

MIT

About

✨ A high-performance, standalone tool for Typora to auto-convert local images to Base64/WebP when exporting HTML. πŸš€ Single-file portability, zero dependencies, support for HTML/Markdown syntax.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages