Update python-fu-removebg with using subproccess
os.system => subprocess
This commit is contained in:
@@ -12,6 +12,7 @@ from gi.repository import Gio
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
import os, sys, string, tempfile, platform
|
||||
import subprocess
|
||||
|
||||
def N_(message): return message
|
||||
def _(message): return GLib.dgettext(None, message)
|
||||
@@ -83,17 +84,22 @@ class PythonRemoveBG(Gimp.PlugIn):
|
||||
AlphaMatting = config.get_property('AlphaMatting')
|
||||
asMask = config.get_property('asMask')
|
||||
selModel = config.get_choice_id("Model")
|
||||
aeValue = config.get_property('aeValue')
|
||||
|
||||
removeTmpFile = True
|
||||
osName = platform.system()
|
||||
|
||||
exportSep = str(os.sep)
|
||||
tdir = tempfile.gettempdir()
|
||||
print(tdir)
|
||||
jpgFile = "%s%sTemp-gimp-0000.jpg" % (tdir, exportSep)
|
||||
pngFile = "%s%sTemp-gimp-0000.png" % (tdir, exportSep)
|
||||
jpgFileF = "Temp-gimp-0000.jpg"
|
||||
jpgFile = os.path.join(tdir,jpgFileF)
|
||||
|
||||
pngFileF = "Temp-gimp-0000.png"
|
||||
pngFile = os.path.join(tdir,pngFileF)
|
||||
|
||||
|
||||
x1 = 0
|
||||
y1 = 0
|
||||
|
||||
option = ""
|
||||
|
||||
Gimp.context_pop()
|
||||
@@ -124,8 +130,10 @@ class PythonRemoveBG(Gimp.PlugIn):
|
||||
|
||||
if AlphaMatting:
|
||||
option = "-a -ae %d" % (aeValue)
|
||||
cmd = '""%s" i -m %s %s "%s" "%s""' % (aiExe, tupleModel[selModel], option, f.get_path(), pngFile)
|
||||
os.system(cmd)
|
||||
cmd = '%s i -m %s %s "%s" "%s"' % (aiExe, tupleModel[selModel], option, f.get_path(), pngFile)
|
||||
print(cmd)
|
||||
|
||||
subprocess.run(cmd)
|
||||
|
||||
file_exists = os.path.exists(pngFile)
|
||||
if file_exists:
|
||||
|
||||
Reference in New Issue
Block a user