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

Support Windows with native PowerShell script and restructure code #8

Merged
merged 5 commits into from
Jun 18, 2021

Conversation

thanhph111
Copy link
Collaborator

@thanhph111 thanhph111 commented Jun 18, 2021

This PR replaces Pillow library with PowerShell version 5.1 compatible scripts for Windows 10, which pre-installed from Windows 10 version 1607. This PR uses some features only supported by PowerShell version 5.1. From PowerShell version 6, the clipboard only works with text so this add-on won't work on machines that have no PowerShell 5.1.

This approach has 2 advantages:

  • Reduce the size of the add-on and remove the dependency to the Pillow third-party package which is notorious for its frequent security vulnerabilities.
  • Several tests show that the PowerShell method handle better (still bad) transparent images when copying from Blender Clipboard cannot handle transparent pixels #12 and has a very slow processing speed.

I have also migrated the code to separate packages based on its support platform for ease of future maintenance.

Only work on PowerShell 5.1, which is preinstalled on Windows 10 version
1607 and up (until now - 21H2). From PowerShell 6, clipboard API works
only with text.

Although most Windows 10 computers today are code-compatible, need to
take a stable approach in the future.
This loses the files' history, use `git log --follow` for more details.
The process is quite slow and the `Error: Not freed memory blocks` shows
after closing 'Blender' (this is not the first time it appears, need to
retest on 'PIL' to determine what causes this error).
The old path doesn't work if add-on folder name different from
'ImagePaste'.

Also make the file name timestamp-based on Linux platform.
@thanhph111 thanhph111 merged commit ebeb16a into b-init:main Jun 18, 2021
@thanhph111 thanhph111 deleted the support-native-windows branch June 18, 2021 04:41
@thanhph111 thanhph111 mentioned this pull request Jun 18, 2021
thanhph111 added a commit that referenced this pull request Aug 6, 2021
- Ignore all files with extension `.blend`, `.blend1`, ..., `.blend32`.
  'Blender' only supports 32 version files.
- Ignore again `.pyd` files because we don't use 'Pillow' anymore (#8).
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 this pull request may close these issues.

1 participant