Python
ppt to image
이무쿤
2021. 9. 17. 10:05
반응형
import enchant
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE
def iter_picture_shapes(self, prs):
pictures = []
for slide in prs.slides:
group_shapes = [
shape for shape in slide.shapes
if shape.shape_type == MSO_SHAPE_TYPE().GROUP
]
for group_shape in group_shapes:
for shape in group_shape.shapes:
if shape.shape_type == MSO_SHAPE_TYPE().PICTURE:
pictures.append(shape)
for shape in slide.shapes:
if shape.shape_type == MSO_SHAPE_TYPE().PICTURE:
pictures.append(shape)
# print("사진 개수 : " + str(len(pictures)))
return pictures
def extract_img_from_ppt(self, ppt):
image_list = []
for picture in self.iter_picture_shapes(Presentation(ppt)):
image = picture.image
image_bytes = image.blob
image_list.append(image_bytes)
ppt로부터 모든 image 추출
반응형