slhck / compress-pptx

Compress a PPTX file, converting all PNG/TIFF images to lossy JPEGs
Other
22 stars 5 forks source link

Windows compatibility? #8

Closed Zerrvr closed 1 year ago

Zerrvr commented 1 year ago

I have everything installed, but when I run it, it errors out with a "Winpath" issue. is there any way to make this work, or do I need to bite the bullet and learn linux?

slhck commented 1 year ago

Can you please post the entire error?

I don't have a Windows machine to test with but it should be cross platform compatible.

Zerrvr commented 1 year ago

PS C:\Users\runne> compress-pptx "W:\Shared With Me\VTT Stream Deck\vCMVOT3\Session 2\Session 2 PPT- VCMVOT.pptx" Extracting file ... Compressing 1 file(s) ... 0%| | 0/1 [00:00<?, ?it/s] concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 246, in _process_worker r = call_item.fn(*call_item.args, *call_item.kwargs) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 205, in _process_chunk return [fn(args) for args in chunk] File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 205, in return [fn(*args) for args in chunk] File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx\compress_pptx.py", line 41, in _compress_file run_command(cmd, verbose=args["verbose"]) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx\util.py", line 66, in run_command "error running command {}: ".format(" ".join(cmd)) + stderr.decode("utf-8") TypeError: sequence item 10: expected str instance, WindowsPath found """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\runne\AppData\Roaming\Python\Python310\Scripts\compress-pptx.exe__main.py", line 7, in File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx__main__.py", line 91, in main raise e File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx__main.py", line 87, in main ).run() File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx\compress_pptx.py", line 142, in run self._compress_files() File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\compress_pptx\compress_pptx.py", line 245, in _compress_files process_map(_compress_file, non_emf_files) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\contrib\concurrent.py", line 105, in process_map return _executor_map(ProcessPoolExecutor, fn, *iterables, *tqdm_kwargs) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\contrib\concurrent.py", line 51, in _executor_map return list(tqdm_class(ex.map(fn, iterables, chunksize=chunksize), **kwargs)) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\std.py", line 1182, in iter__ for obj in iterable: File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 570, in _chain_from_iterable_of_lists for element in iterable: File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 621, in result_iterator yield _result_or_cancel(fs.pop()) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 319, in _result_or_cancel return fut.result(timeout) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 458, in result return self.get_result() File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 403, in __get_result raise self._exception TypeError: sequence item 10: expected str instance, WindowsPath found

Zerrvr commented 1 year ago

I'm running it through Powershell as admin, if that matters

slhck commented 1 year ago

Something was wrong with the way paths were used here. I released a new version; can you please try this one?

pip3 install --upgrade compress-pptx
Zerrvr commented 1 year ago

So there was progress, we have a new error!

PS C:\Users\runne> compress-pptx "W:\Shared With Me\VTT Stream Deck\vCMVOT3\Session 1\Session 1 PPT- VCMVOT - Compress.pptx" Extracting file ... Compressing 26 file(s) ... 0%| | 0/26 [00:00<?, ?it/s] concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 246, in _process_worker r = call_item.fn(*call_item.args, *call_item.kwargs) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 205, in _process_chunk return [fn(args) for args in chunk] File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 205, in return [fn(*args) for args in chunk] File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx\compress_pptx.py", line 49, in _compress_file run_command(cmd, verbose=file["verbose"]) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx\util.py", line 65, in run_command raise RuntimeError( RuntimeError: error running command convert -quality 85 -background white -alpha remove -alpha off C:\Users\runne\AppData\Local\Temp\tmpexlc3eca\ppt\media\image101.png[0] C:/Users/runne/AppData/Local/Temp/tmpexlc3eca/ppt/media/image101-compressed.jpg: Invalid Parameter - 85

"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\Scripts\compress-pptx.exe__main.py", line 7, in File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx__main__.py", line 98, in main raise e File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx__main.py", line 94, in main ).run() File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx\compress_pptx.py", line 173, in run self._compress_files() File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\site-packages\compress_pptx\compress_pptx.py", line 286, in _compress_files process_map(_compress_file, non_emf_files, max_workers=self.num_cpus) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\contrib\concurrent.py", line 105, in process_map return _executor_map(ProcessPoolExecutor, fn, *iterables, *tqdm_kwargs) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\contrib\concurrent.py", line 51, in _executor_map return list(tqdm_class(ex.map(fn, iterables, chunksize=chunksize), **kwargs)) File "C:\Users\runne\AppData\Roaming\Python\Python310\site-packages\tqdm\std.py", line 1182, in iter__ for obj in iterable: File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 570, in _chain_from_iterable_of_lists for element in iterable: File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 621, in result_iterator yield _result_or_cancel(fs.pop()) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 319, in _result_or_cancel return fut.result(timeout) File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 458, in result return self.get_result() File "C:\Users\runne\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 403, in __get_result raise self._exception RuntimeError: error running command convert -quality 85 -background white -alpha remove -alpha off C:\Users\runne\AppData\Local\Temp\tmpexlc3eca\ppt\media\image101.png[0] C:/Users/runne/AppData/Local/Temp/tmpexlc3eca/ppt/media/image101-compressed.jpg: Invalid Parameter - 85

slhck commented 1 year ago

Okay, I believe this might be an issue with convert on your system. Is that the tool from ImageMagick? I suspect it's something else. Can you please run convert -h or similar to find out what that is?

Zerrvr commented 1 year ago

I have the most up to date windows binaries installed, and I made sure to install the "legacy commands"...

PS C:\Users\runne> convert -help Version: ImageMagick 7.1.1-19 Q16-HDRI x64 99da019:20230930 https://imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Channel-masks(64-bit) Cipher DPC HDRI Modules OpenCL OpenMP(2.0) Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib Compiler: Visual Studio 2022 (193532217)...

Zerrvr commented 1 year ago

I'm looking into this: https://legacy.imagemagick.org/Usage/windows/#convert_issue, may be my issue

slhck commented 1 year ago

Please see https://stackoverflow.com/a/9035861/435093.

I released a new version that uses the non-legacy commands, so it should be more portable.

Zerrvr commented 1 year ago

Victory! Works like a charm. Thank you so much for your help, and so fast, too!

slhck commented 1 year ago

Great, I'm glad it worked!