본문 바로가기

Python

ppt to image

반응형
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 추출 

반응형

'Python' 카테고리의 다른 글

python to spring controller file 전송  (0) 2021.08.09
python REST request  (0) 2021.06.29
Python으로 XML-RPC 서버 구축  (0) 2021.06.24
pip SSL 인증 오류  (0) 2021.04.16
Python Pandas Cannot import QUOTE_MINIMAL  (0) 2020.08.11