code: def optimize_images(pelican):
      
      for dirpath, _, filenames in os.walk(pelican.settings['OUTPUT_PATH']):
          for name in filenames:
              if os.path.splitext(name)[1] in COMMANDS.keys():
                  optimize(dirpath, name)
docs: Optimized jpg and png images
  
      :param pelican: The Pelican instance