Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'width' is not defined when the exported image is wmf format. #23

Closed
kxxt opened this issue Dec 20, 2021 · 1 comment · Fixed by #24
Closed

NameError: name 'width' is not defined when the exported image is wmf format. #23

kxxt opened this issue Dec 20, 2021 · 1 comment · Fixed by #24

Comments

@kxxt
Copy link
Contributor

kxxt commented Dec 20, 2021

Error:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pptx2md\__main__.py", line 123, in <module>
    main()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pptx2md\__main__.py", line 119, in main
    parse(prs, out)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pptx2md\parser.py", line 175, in parse
    process_picture(shape)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pptx2md\parser.py", line 137, in process_picture
    out.put_image(os.path.splitext(img_outputter_path)[0]+'.png', width)
NameError: name 'width' is not defined

pptx2md/pptx2md/parser.py

Lines 118 to 139 in 6d904dc

def process_picture(shape):
if g.disable_image:
return
global picture_count
global out
pic_name = g.file_prefix + str(picture_count)
pic_ext = shape.image.ext
if not os.path.exists(g.img_path):
os.makedirs(g.img_path)
output_path = g.path_name_ext(g.img_path, pic_name, pic_ext)
common_path = os.path.commonpath([g.out_path, g.img_path])
img_outputter_path = os.path.relpath(output_path, common_path)
with open(output_path, 'wb') as f:
f.write(shape.image.blob)
picture_count += 1
if pic_ext == 'wmf':
if not g.disable_wmf:
Image.open(output_path).save(os.path.splitext(output_path)[0]+'.png')
out.put_image(os.path.splitext(img_outputter_path)[0]+'.png', width)
else:
out.put_image(img_outputter_path, g.max_img_width)

width is undefined.

I can open a pull request to fix this.

@ssine
Copy link
Owner

ssine commented Dec 22, 2021

version 1.0.1 published for this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants