tabs -> 4 spaces
This commit is contained in:
@@ -19,18 +19,18 @@ import shlex
|
|||||||
|
|
||||||
def optimize_image(imgpath, imgformat, optimizeimg):
|
def optimize_image(imgpath, imgformat, optimizeimg):
|
||||||
if imgformat == 'png':
|
if imgformat == 'png':
|
||||||
if optimizeimg == "1" or optimizeimg == "2":
|
if optimizeimg == "1" or optimizeimg == "2":
|
||||||
# we can't do an atomic replace here because windows is terrible
|
# we can't do an atomic replace here because windows is terrible
|
||||||
# so instead, we make temp files, delete the old ones, and rename
|
# so instead, we make temp files, delete the old ones, and rename
|
||||||
# the temp files. go windows!
|
# the temp files. go windows!
|
||||||
subprocess.Popen(shlex.split("pngcrush " + imgpath + " " + imgpath + ".tmp"),
|
subprocess.Popen(shlex.split("pngcrush " + imgpath + " " + imgpath + ".tmp"),
|
||||||
stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
|
stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
|
||||||
os.remove(imgpath)
|
os.remove(imgpath)
|
||||||
os.rename(imgpath+".tmp", imgpath)
|
os.rename(imgpath+".tmp", imgpath)
|
||||||
|
|
||||||
if optimizeimg == "2":
|
if optimizeimg == "2":
|
||||||
subprocess.Popen(shlex.split("optipng " + imgpath), stderr=subprocess.STDOUT,
|
subprocess.Popen(shlex.split("optipng " + imgpath), stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
subprocess.Popen(shlex.split("advdef -z4 " + imgpath), stderr=subprocess.STDOUT,
|
subprocess.Popen(shlex.split("advdef -z4 " + imgpath), stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import logging
|
|||||||
import util
|
import util
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from optimizeimages import optimize_image
|
from optimizeimages import optimize_image
|
||||||
|
|
||||||
|
|
||||||
@@ -603,7 +604,7 @@ def render_worldtile(chunks, colstart, colend, rowstart, rowend, path, imgformat
|
|||||||
tileimg.save(imgpath)
|
tileimg.save(imgpath)
|
||||||
|
|
||||||
if optimizeimg:
|
if optimizeimg:
|
||||||
optimize_image(imgpath, imgformat, optimizeimg)
|
optimize_image(imgpath, imgformat, optimizeimg)
|
||||||
|
|
||||||
with open(hashpath, "wb") as hashout:
|
with open(hashpath, "wb") as hashout:
|
||||||
hashout.write(digest)
|
hashout.write(digest)
|
||||||
|
|||||||
Reference in New Issue
Block a user