Metadata-Version: 2.4
Name: md-localize-images
Version: 0.1.0
Summary: Localize remote image references in Markdown and Obsidian notes.
Author: Andy Brandt
Project-URL: Homepage, https://github.com/andybrandt/md-image-localizer
Project-URL: Repository, https://github.com/andybrandt/md-image-localizer
Project-URL: Issues, https://github.com/andybrandt/md-image-localizer/issues
Keywords: markdown,obsidian,images,attachments,cli
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Information Technology
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: Pillow>=10.0
Requires-Dist: requests>=2.31
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"

# md-localize-images

`md-localize-images` scans Markdown files, downloads remote image references, stores them locally, and rewrites the image links.

The tool is intended for Obsidian vaults, but it also works with ordinary Markdown files. The default rewritten link style is Obsidian embed syntax:

```markdown
![[attachments/image.png]]
```

## Install for development

```bash
python -m pip install -e ".[dev]"
```

## Usage

Process one file:

```bash
md-localize-images --file path/to/note.md
```

Process a vault recursively:

```bash
md-localize-images --vault path/to/vault --recursive
```

Choose where downloaded images are stored:

```bash
md-localize-images --file note.md --images-dir attachments/imported-images
```

Use relative Markdown links instead of Obsidian links:

```bash
md-localize-images --file note.md --link-style relative
```

Run without writing files:

```bash
md-localize-images --vault . --recursive --dry-run
```

Create Markdown backups before modification:

```bash
md-localize-images --vault . --recursive --backup
```

Process raw HTML image tags as well as Markdown images:

```bash
md-localize-images --vault . --recursive --include-html-img
```

## Exit Codes

- `0`: success
- `1`: one or more downloads failed, but processing completed
- `2`: invalid command-line arguments
- `3`: filesystem or path configuration error

## Notes

- WebP images are saved as PNG files.
- Links inside fenced code blocks, indented code blocks, inline code spans, and HTML comments are not modified.
- Existing image files are not overwritten; a deterministic hash is added to avoid collisions.
- Repeated identical URLs are downloaded once per invocation.
- Phase one does not include a persistent cache.
