Use run instead of popen so that things are closed correctly

Use run instead of popen so that things are closed correctly
This commit is contained in:
Matthew Leonberger 2017-09-24 20:43:41 +09:00
parent 9a34ee610b
commit f2db75cea9

View File

@ -18,12 +18,12 @@ def imagemagick(color_count, img):
else:
magick_command = ["convert"]
colors = subprocess.Popen([*magick_command, img, "-resize", "25%",
"+dither", "-colors", str(color_count),
"-unique-colors", "txt:-"],
stdout=subprocess.PIPE)
colors = subprocess.run([*magick_command, img, "-resize", "25%",
"+dither", "-colors", str(color_count),
"-unique-colors", "txt:-"],
stdout=subprocess.PIPE)
return colors.stdout.readlines()
return colors.stdout.splitlines()
def gen_colors(img, color_count):