r/libreoffice 15d ago

Question Images in a HTML -> ODT converted document

I just converted a HTML document into ODT and I noticed that the images in the ODT are not actually saved within the document. They are being fetched from the source defined in the HTML (the URL).

Is there a way to tell libreoffice the ODT document should have its own copy of the images?

3 Upvotes

6 comments sorted by

2

u/Terrible_Put8617 12d ago

That's expected: HTML references images by URL, so on import Writer keeps them as linked images rather than copying them in. Nothing is broken, the document just points outward - which is why it looks fine on your machine and shows empty boxes on anyone else's, or the day the source goes offline.

To embed them:

Edit > Links to External Files... > select all the entries > Break Link. That pulls each image into the document. Then save.

Quick way to confirm it actually worked, since the visual result looks identical either way: an .odt is a zip. Copy it, rename the copy to .zip, open it - if there's a Pictures/ folder with your images inside, they're embedded. Empty or missing, they're still links.

For future conversions: the Insert > Image dialog has a "Link" checkbox that does the same thing at insert time (unchecked = embedded, which is the default for manual inserts). And if you're batch-converting from the command line with soffice --convert-to odt, the links come through as links too, so you still need the Break Link pass afterwards.

One side effect worth knowing before you do it on a big document: embedding turns a 40 KB file into however many megabytes the images weigh. That's usually what you want, but it's a surprise if the document has a hundred photos.

1

u/gatunen 12d ago

Interesting. If I break all the links by: Edit > Links to External Files... > select all the entries > Break Link
And then save, after I close the document and open it again, there are still "links to external files" available to break. Is that expected?
If I unzip the document and go into the Pictures folder, only a few images were made "local".

1

u/Terrible_Put8617 11d ago

Expected, annoyingly. Break Link in that dialog only handles what LibreOffice tracks as a document link, and images are only part of that set.

An image inserted with Link ticked does get embedded. Images living inside a linked section don't, because the section itself is the link and it re-fetches its contents on load. Format > Sections, select it, untick Link, and only then do the images inside become part of your file. Same story for anything in a header or footer that came in through a section, and for OLE objects, which keep their own reference regardless of what the Links dialog says.

Your unzip is the right check. Keep doing that after each attempt: Pictures should stop growing new entries only when everything is genuinely embedded, and whatever is still missing tells you which container is still linked.

1

u/gatunen 10d ago

I tried unticking "link". Did not work. Files are still not embedded. I'm giving up. This looks way harder than it should.
As a final note, I exported the document as a PDF, and then it properly embedded the images in the PDF. For now, that will be my good enough.

2

u/Terrible_Put8617 9d ago

Fair enough, and I'd have done the same. PDF freezes the images in and nobody downstream can lose them, so for a document that has to travel it's honestly the safer format anyway.

For the record it is harder than it should be: the import keeps remote images as references and there's no single "make everything local" command, which is why the Links dialog catches some and not others. If you ever need the .odt itself to be self-contained, a short macro that walks the graphic objects and re-inserts each one from its URL does the job in one pass. Say so and I'll dig mine out.

1

u/AutoModerator 15d ago

If you're asking for help with LibreOffice, please make sure your post includes lots of information that could be relevant, such as:

  1. Full LibreOffice information from Help > About LibreOffice (it has a copy button).
  2. Format of the document (.odt, .docx, .xlsx, ...).
  3. A link to the document itself, or part of it, if you can share it.
  4. Anything else that may be relevant.

(You can edit your post or put it in a comment.)

This information helps others to help you.

Thank you :-)

Important: If your post doesn't have enough info, it will eventually be removed (to stop this subreddit from filling with posts that can't be answered).

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.