-
Notifications
You must be signed in to change notification settings - Fork 68
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
Flask库是否没办法使用这个工具呢? #254
Comments
应该是可以的你可以参考这个 |
我试了下手动打开Photoshop再运行,还是不行,这是我的测试代码,大佬能帮我看下吗?
我运行后进入http:https://127.0.0.1:5000 |
解决了,似乎因为flask是多线程的,使用pypsAPI时需要创建COM对象,为避免线程冲突和资源争夺,需要在使用前初始化一下com环境。直接运行好像因为python会自动回收处理COM环境而不受影响?修改代码如下:
这样就可以正常运行了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我试着用Flask构建网页窗口,并通过按钮经photoshop-python-api操控Photoshop。但用按钮操控时报错:photoshop.api.errors.PhotoshopPythonAPIError: Please check if you have Photoshop installed correctly.
不用flask构建的网页按钮则可以正常使用photoshop-python-api操控Photoshop。
以下是我的代码:
python:
from flask import Flask
from photoshop import Session
app = Flask(name)
@app.route('/tryButton', methods=['GET','POST'])
def tryButton():
with Session(r"C:\Users\out.psd", action="open") as app:
doc = app.active_document
if name == "main":
app.run(debug=True, host="0.0.0.0",port=5000)
return "File uploaded successfully"
Js:
tryButton.addEventListener('click', function() {
fetch('/tryButton', {
method: 'GET',
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.blob();
}).then(blob => {
HTML:
是否是flask的多线程造成的?请问有什么好的解决办法吗?
The text was updated successfully, but these errors were encountered: