Publisher's Synopsis
# Convert the PNG image to JPEG for compatibility with Word
from PIL import Image
png_image_path = "/mnt/data/Ebook_cover_design_for_a_cryptocurrency_book._Titl.png"
jpg_image_path = "/mnt/data/TRON_Ebook_Cover.jpg" with Image.open(png_image_path) as img:
rgb_img = img.convert("RGB")
rgb_img.save(jpg_image_path, "JPEG") # Now create the .docx with the JPEG cover
doc = Document()
doc.add_picture(jpg_image_path, width=Inches(6))
doc.add_heading(ebook_content["Title"], level=0) for chapter_title, chapter_text in ebook_content["Chapters"].items():
doc.add_heading(chapter_title, level=1)
doc.add_paragraph(chapter_text.strip()) # Save final ebook with cover
final_ebook_with_cover = "/mnt/data/TRON_Crypto_Explained_Final_Edition_With_Cover.docx"
doc.save(final_ebook_with_cover) final_ebook_with_cover