Make an EPUB with Images Without Carrying Broken Links into Export

An abstract editorial 3D still life illustrating Make an EPUB with Images Without Carrying Broken Links into Export

Stop before export if even one stale path remains

The direct way to keep broken image links out of an EPUB is to make the old-path search a mandatory pre-export gate. The controlled sample intentionally contained one stale image reference. The run found that one occurrence, repaired exactly one occurrence, searched for the same stale path again, and exported only after the result reached zero.

A general preventive workflow checks the physical file, the source reference, the export plan, and the packaged resource in that order. Any mismatch stops the process at its own layer. Being able to start an export is not the same as having a manuscript that is ready to export.

Use one chapter, two images, and one deliberate fault

The sample contains one chapter and two images: images/figure01.png and images/figure02.jpg. The first reference starts in the correct state. The second intentionally points to ../old/figure02.jpg. The expected checkpoints are therefore one stale occurrence before repair, zero afterward, two packaged images, and zero missing resources.

Keeping the sample to one chapter isolates the prevention gate. With many chapters, it becomes harder to tell whether a count changed because the intended repair worked or because another chapter introduced a second problem. If a file is absent, return to the images folder. If a stale reference remains, return to the chapter source. If the plan is wrong, return to chapter selection. If inspection reports a missing resource, return to export and packaging.

Require four gates before treating the manuscript as ready

The first gate checks that figure01.png and figure02.jpg physically exist where the manuscript expects them. The second gate searches the source for the known stale path. A nonzero result means that export must stop.

The third gate is the plan. After repair, the selected files and chapter count must match the sample and the plan must be valid. The fourth gate is post-export inspection of image count, missing resources, navigation, and spine. The first three gates prevent a known defect from entering the package; the final gate checks that the prevention worked.

Repair one stale reference and prove the old path is gone

The search for ../old/figure02.jpg reported fileCount 1 and occurrenceCount 1. The match was on line 3 of chapters/01.md. Only that occurrence was replaced with ../images/figure02.jpg, producing replacedCount 1.

The same old-path search was then run again and returned fileCount 0 and occurrenceCount 0. That reverse search is the pass condition. A record that a new value was typed would not prove that the stale value disappeared everywhere. After the zero result, the plan reported fileCount 1, chapterCount 1, and valid true.

The package contained both images and no missing resource

The generated studio-392-260831.120000.epub was 5,286 bytes, and its recorded SHA-256 begins with 7b7035. Inspection reported entryCount 11, spineItemCount 4, imageCount 2, zero missing resources, nav.xhtml, NCX, one item in each navigation representation, valid true, and no issues. Those values match the one-chapter, two-image starting point.

A separate common baseline used two chapters, one image, horizontal layout, and version 1.2. It reported six spine items, zero missing resources, nav.xhtml, NCX, and valid true. That baseline supports the ordinary export route. The evidence that one stale path was removed before export comes from the title-specific search, replacement, and reverse search.

Keep visual and external checks outside this pass

The passed status applies to the dedicated copy: the known stale path reached zero, and the locally inspected package reported no missing resource. The run did not demonstrate automatic tracking of changes made in Finder or cloud storage. It did not assess image quality, KDP acceptance, hardware readers, or every reading application.

If the image looks wrong, return to the source asset. If an external service reports a problem, use its diagnostic as a separate return point. The manifest and spine roles follow the EPUB 3.3 specification, but local structural inspection should not be presented as an external rendering guarantee.

Use Rune Studio as one part of the prevention gate

Rune Studio publicly supports selecting Markdown manuscripts and generating EPUB 3 output. It also supports updating relative image and link references in txt, text, md, and markdown files, including references that contain ../. External URLs and page anchors are outside that update target.

This run verified explicit search, one targeted replacement, plan, export, and inspect operations on a dedicated copy. The existence of the product feature does not prove that every filesystem move was detected automatically. The preventive gate still depends on checking the returned counts before continuing.

Conclusion: require found one, repaired one, and old path zero

Before producing an EPUB with images, search for the known stale path. If one occurrence is found, repair exactly that occurrence and do not export until the same search returns zero. That compact rule is the center of this preventive workflow.

In the one-chapter, two-image sample, one stale reference was repaired, the old path reached zero, and the package contained both images with zero missing resources and valid structure. Use this as a pre-export gate, not as a post-failure diagnosis of every possible broken EPUB.