b-init / ImagePaste

A simple Blender addon to grab images from your clipboard and paste as a reference image in viewport or onto the image editor.
GNU General Public License v3.0
246 stars 9 forks source link

Add support for Mac OS #6

Closed williamchange closed 3 years ago

williamchange commented 3 years ago

I am able to get most of the features working on mac OS, with pasteboard being the only needed dependency for path data.

Everything else is handled with applescript (osascript) which is built-in on macs.

Tested on Mac OS Big Sur 11.4 on Macbook Pro 15" 2018, with Blender versions 2.83.16, 2.92, 2.93.0 (LTS), and 3.0 (current master).

What's working(so far):

Pasting doesn't work when copied from Safari because clipboard stored website link instead of image data.

https://user-images.githubusercontent.com/830253/122382163-ffed5300-cfac-11eb-9bc1-b3eaa5168a8c.mp4

thanhph111 commented 3 years ago

Great job. I'm really looking forward to this PR. I'll review the code as soon as possible.

However, I'm going to restructure the repo to make it easier for future contributions, it is PR #7 and then I plan to split the code into separate modules. I hope we can make some changes before merging this PR to main. Tell me what you think.

By the way, may I ask why did you decide to use pasteboard? Is it good to use a set of more native commands like pbcopy and pbpaste? I'm not familiar with macOS so the questions might be a bit silly for you, please excuse me.

Finally, thanks a lot for your contributions.

thanhph111 commented 3 years ago

I see a lot of improvements here. When you're satisfied with new changes, you could re-request me and I will come back asap. Take it easy, OK? :smile:

williamchange commented 3 years ago

By the way, may I ask why did you decide to use pasteboard? Is it good to use a set of more native commands like pbcopy and pbpaste? I'm not familiar with macOS so the questions might be a bit silly for you, please excuse me.

Finally, thanks a lot for your contributions.

Thanks.

The current implementation is mostly motivated from pillow 's grabclipboard function which uses applescript to access the clipboard.

I also looked into those commands, but they seemed to only handle text, and copying multiple images(from Finder) I was only able to grab the first filename using pbpaste. The same goes for applescript which only yields the first result(as file name or path) when multiple images are copied (see https://stackoverflow.com/a/3485101), though it worked well when dealing with copying/pasting image data.

so pasteboard is here to only deal with translating copied image files from Finder to absolute paths.

thanhph111 commented 3 years ago

Thanks for the useful information. So for now, the only remaining problem is that it doesn't work with clipboard received from the Safari browser?

Both the Windows and Linux version I'm working on always have issues when handle transparent images. Have you test a transparent image with a gradient shadow like this (both copy to Blender and copy from Blender)?

williamchange commented 3 years ago

Thanks for the useful information. So for now, the only remaining problem is that it doesn't work with clipboard received from the Safari browser?

Yes, Safari was not working when I first opened this PR but I can confirm this works now:

https://user-images.githubusercontent.com/830253/122557665-6e4f1580-d080-11eb-825c-c0ea5e9a1042.mp4

Both the Windows and Linux version I'm working on always have issues when handle transparent images. Have you test a transparent image with a gradient shadow like this (both copy to Blender and copy from Blender)?

Yeah transparency worked out fine for me both ways:

https://user-images.githubusercontent.com/830253/122556675-24b1fb00-d07f-11eb-9eac-36200ede93aa.mp4

thanhph111 commented 3 years ago

Great! I think it's perfect now. Thank you for your effort and patience. Hope to see you in the next contributions.

williamchange commented 3 years ago

All good! Thanks for your work.