How can I safely remove thumbnails from .odt files?

Following up on a previous question of mine, I would like to know how to remove the large thumbnail from .odt files created in LibreOffice. I don’t find this feature useful at all; Trisquel doesn’t display them, and when I used Windows it didn’t identify the document well enough.

When I rename the .odt file to a .zip archive, extract its contents, delete either the thumbnail or the folder that contains it, and recompile the file (or whatever the proper term for that is) the resulting ODT is irreparably corrupted.

@horst – feel free to post suggestions that propose solutions as Answers (this way if they work, they may be marked as correct :slight_smile:

In the Folder META-INF is a file MANIFEST.XML and in it a reference to the thumbnail. Try to delete this reference to it. May be it works then.

Nope, irreparably corrupted. I’ve filed an enhancement bug request here.

So I renamed an ODT file to zip, opened if with file-roller (you could use 7z if you don’t have one), deleted Thumbnails directory from there, renamed zip back to ODT and opened it. Worked like a charm.

Then for sake of test I extracted the zip as directories, deleted Thumbnails, compressed again, renamed to ODT. And it worked fine. Just make sure your zip doesn’t have one extra directory after compressing.

Although this is the correct answer, kindly read my summary farther down the page for a more concise explanation of how to do this.

The thumbnail in Uglyface200’s example 33 kb text file is 18 kb. This does seem a bit excessive and may rate an enhancement request for thumbnail Yes/No or size.

I was able to replace the 18 kb thumbnail.png file in the unzipped odt with a smaller 1 kb version. Reconverting to odt format did not result in a corrupt file. The overall odt size was reduced from 33 kb to 15.5 kb. However if I edited the file
and saved it, the 18 kb thumbnail was recreated.

The fodt format does not include a thumbnail section. I saved the 33 kb odt file as a fodt file and compressed it separately, the gzipped file was 10 kb. This means an extra steps to open the gz archive and save the odt back to it. On my Debian system this was not a big deal. On the other hand a few extra ks don’t seem that big a deal anyway.

The thumbnail size depends on the content of the first page. When I inserted a blank first page in the 33 kb file and saved it I got a 15.4 kb file. The blank first page is not too convenient.

Neither of the files I uploaded was 33 kb. One was 12 kb and the other was 21.6 kb.

Right you are. My mistake. The Writer ODT.odt file was 21.6 kb. But when I saved it, it grew.

With some smaller, one-page files, the thumbnail doubles the file size. I think this is unacceptable and needs to be addressed, so I’ve filed an enhancement bug at https://bugs.freedesktop.org/show_bug.cgi?id=61320.

horst’s answer is the correct one. Please vote for his, and do not vote for this one, which is just a concise summary of the method.

To remove a thumbnail from a .odt file generated in LibreOffice, and drastically reduce that file’s size (by about 18 kb, depending on the file):

  1. Finish editing the file! As soon as you save it in LibreOffice, the thumbnail will be recreated and you will have to repeat this process.
  2. Right- or context-click on the file and select “rename”. Change the file extension to .zip. (On Windows 7, you may need to show the file extension to rename it, so open the Start menu, search for “Folder options” and open the result of that name, click the “View” tab, and uncheck “Hide extensions for known file types”.)
  3. Open the files in the .zip archive with an archive manager of your choice. If you’re using Windows, you may be able to use the plain file manager, but you might have to install the free and open-source program 7-Zip if you can’t open .zip files. I’m fairly sure that Mac OS and most Linux distributions ship with decompression software. Do not extract the folder’s contents.
  4. You should see several files and folders, the source code of the .odt file. Open the folder called “META-INF” and you will see a file called “manifest.xml”.
  5. Open this file with a plain text editor of your choice and delete the line that says <manifest:file-entry manifest:full-path="Thumbnails/thumbnail.png" manifest:media-type="image/png">.
  6. Return to the main folder of the extracted archive and delete the folder called “Thumbnails”.
  7. Close the archive manager. Rename the file’s extension to .odt as in step 2. Observe how its size has been drastically reduced.

I am glad to see that solutions are found to delete the thumbnails whenever it becomes necessary. Hopefully there is more practical solution coming up in the future.

w_whalley’s comment about the 18kB for the thumbnail made me thinking that the thumbnail size is only important when files are small. This means a 36 kB total file size contains 50% for the thumbnail,. But for a 180 kB it would only be 10 %.

Out of curiosity, I searched my data drice for odt-files to see what could be an effect on required HDD capacitiy and found - a bit to my surprise - a large amount of odt-files with a size far below 18kB. ( I don’t take w_whalleys’s 18 KB as an absolute value but as an approximate value).

What is the reason for the many small odt-files I have on my machine?

LibO: Version 3.6.5.2 (Build ID: 5b93205) / OS: XP Prof English, Asian language support package, SP3

You may wish to post this as a new question.