title: fpdf single output with multiple images
body: <p>How do you output all images in a directory to the same pdf output using fpdf.  I can get the last file in the folder to output as a pdf or output multiple pdfs for each image, but not all images in the same pdf like a catalog.  I'm sure it is the for loop but can't sort it out properly.</p>
  
  <pre><code>from fpdf import FPDF
  from PIL import Image
  import glob
  import os
  
  
  # set here
  image_directory = '/home/User/Desktop/images/'
  extensions = ('*.jpg','*.jpeg','*.png','*.gif')
  
  
  # set 0 if you want to fit pdf to image
  # unit : pt
  margin = 10
  
  imagelist=[]
  for ext in extensions:
      imagelist.extend(glob.glob(os.path.join(image_directory,ext)))
  
  pdf = FPDF(unit="pt", format=[width + 2*margin, height + 2*margin])
  pdf.add_page()
  cover = Image.open(imagePath)
  width, height = cover.size
  
  for imagePath in imagelist:
      pdf.image(imagePath, margin, margin)
      destination = os.path.splitext(imagePath)[0]
  pdf.output(destination + ".pdf", "F")
  </code></pre>