I have downloaded a Wikipedia dump for Farsi language as a .zim file. I can open it with Kiwix software and it works. The problem is that the font of official Farsi Wikipedia is Tahoma by default but local downloaded pages are in something else that is annoying and not as readable. Is it possible to extract the zim file and modify the stylesheet and compress it again?
3 Answers
Use zimdump to export all content of the ZIM to the filesystem. Refer to How to "uncompress" a ZIM file? to see how.
Perform your modifications on the HTML and CSS files.
Recompress using zimwriterfs:
docker run -v $(pwd):/app -w /app -it --rm --privileged --pid=host openzim/zimwriterfs
zimwriterfs --welcome=A/Main_Page --favicon=I/favicon.png --language=cho --title=mytitle --description=mydescription --creator=mycreator --publisher=mypublisher . my_project.zim
- 11,561
I had the same problems: I wanted to make some changes to a zim file, like cut index or making some changes on the main page. I studied how zim format is made and wrote some python scripts that do the job:
https://gitlab.com/Afrikalan/zim-tools/-/tree/master/zim-manipulation
The wikipediaIndexHasard.py is a script build to change the main page, it relies on zimDerivate.py from the same directory. You may change it to tweak the CSS instead of the main page.
- 1,921
- 4
- 19
- 34
Answering strictly to the question that appears in your question body:
Is it possible to extract the zim file and modify the stylesheet and compress it again?
The answer is: yes, it is possible.
Checking out the .ZIM File Format, one encounters the following paragraph:
ZIM stands for "Zeno IMproved", as it replaces the earlier Zeno file format. Its file compression uses LZMA2, as implemented by the xz-utils library. The openZIM project is sponsored by Wikimedia CH, and supported by the Wikimedia Foundation.
In order to achieve your goal, you will have to use the XZ Utils:
XZ Utils (previously LZMA Utils) is a set of free software command-line lossless data compressors, including LZMA and xz, for Unix-like operating systems and, from version 5.0 onwards, Microsoft Windows.
Their Web-Site will provide you with everything that you need on the subject.