Skip to content

Commit

Permalink
Use check_call(), add workaround for broken pngnq
Browse files Browse the repository at this point in the history
Also -f pngnq to write files, in case something didn't work
last render.
  • Loading branch information
CounterPillow committed May 6, 2014
1 parent 8817972 commit 03561dc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions overviewer_core/optimizeimages.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def optimize(self, img):
raise NotImplementedError("I can't let you do that, Dave.")

def fire_and_forget(self, args):
subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
subprocess.check_call(args)

def check_availability(self):
path = os.environ.get("PATH").split(os.pathsep)
Expand All @@ -46,7 +46,7 @@ def cleanup(self, img):
os.rename(img + ".tmp", img)

def fire_and_forget(self, args, img):
subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
subprocess.check_call(args)
self.cleanup(img)

class PNGOptimizer:
Expand Down Expand Up @@ -76,8 +76,13 @@ def optimize(self, img):
else:
extension = ".png.tmp"

NonAtomicOptimizer.fire_and_forget(self, [self.binaryname, "-s", str(self.sampling),
"-Q", self.dither, "-e", extension, img], img)
args = [self.binaryname, "-s", str(self.sampling), "-f", "-e", extension, img]
# Workaround for poopbuntu 12.04 which ships an old broken pngnq
if self.dither != "n":
args.insert(1, "-Q")
args.insert(2, self.dither)

NonAtomicOptimizer.fire_and_forget(self, args, img)

class pngcrush(NonAtomicOptimizer, PNGOptimizer):
binaryname = "pngcrush"
Expand Down

0 comments on commit 03561dc

Please sign in to comment.