Skip to content

Commit 38ebeac

Browse files
committed
Use SHA1 for image file name
1 parent d40bba3 commit 38ebeac

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

pptx2md/parser.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444

4545
logger = logging.getLogger(__name__)
4646

47-
picture_count = 0
48-
4947

5048
def is_title(shape):
5149
if shape.is_placeholder and (shape.placeholder_format.type == PP_PLACEHOLDER.TITLE or
@@ -148,10 +146,7 @@ def process_picture(config: ConversionConfig, shape, slide_idx) -> Union[ImageEl
148146
if config.disable_image:
149147
return None
150148

151-
global picture_count
152-
153-
file_prefix = ''.join(os.path.basename(config.pptx_path).split('.')[:-1])
154-
pic_name = file_prefix + f'_{picture_count}'
149+
pic_name = shape.image.sha1
155150
if shape.image.filename:
156151
pic_ext = shape.image.filename.split('.')[-1]
157152
else:
@@ -164,7 +159,6 @@ def process_picture(config: ConversionConfig, shape, slide_idx) -> Union[ImageEl
164159
img_outputter_path = os.path.relpath(output_path, common_path)
165160
with open(output_path, 'wb') as f:
166161
f.write(shape.image.blob)
167-
picture_count += 1
168162

169163
# normal images
170164
if config.disable_wmf or (pic_ext != 'wmf' and pic_ext != 'emf'):

0 commit comments

Comments
 (0)