Yes there is indeed a real good trick for your problem 
And you don’t need any external libraries. 
But it only works for pptx files, not for older ppt files!
Because pptx files are technically zip files under the hood, so you can just unzip them and pick out the image files. Here are some code snippets to give you an idea how that can be accomplished:
import zipfile
from pathlib import Path
List all image files in pptx file
# load pptx file
with zipfile.ZipFile('test.pptx') as ziparchive:
# filter all image files (png, jpg, gif...) from zip archive in pptx
images = [f for f in ziparchive.namelist() if f.endswith(('.png', '.jpg', '.gif', '.jpeg', '.bmp', '.tiff', '.tif', '.svg'))]
# show only list of image files:
print(images)
Extract all image files to subdir and keeping file structure
# load pptx file
with zipfile.ZipFile('test.pptx') as ziparchive:
# filter all image files (png, jpg, gif...) from zip archive in pptx
images = [f for f in ziparchive.namelist() if f.endswith(('.png', '.jpg', '.gif', '.jpeg', '.bmp', '.tiff', '.tif', '.svg'))]
for img in images:
print(img)
# extract image files from zip archive, it keeps the file structure
ziparchive.extract(member=img, path='test')
Extract all image files to subdir and flatten the file structure
# load pptx file
with zipfile.ZipFile('test.pptx') as ziparchive:
# filter all image files (png, jpg, gif...) from zip archive in pptx
images = [f for f in ziparchive.namelist() if f.endswith(('.png', '.jpg', '.gif', '.jpeg', '.bmp', '.tiff', '.tif', '.svg'))]
subdir = Path('test')
subdir.mkdir(exist_ok=True) # create directory if not exists
for img in images:
# extract image files from zip archive, it flattens out the file structure:
img_file_export_path = subdir.joinpath(Path(img).name)
print(img_file_export_path)
with open(img_file_export_path, 'wb') as f:
f.write(ziparchive.read(img))
You have to adjust the examples of course to your needs…