From 2cd6d416b2a5954892cced545abdce2afb2c31c6 Mon Sep 17 00:00:00 2001 From: eliempje Date: Sat, 12 Apr 2014 13:38:39 +0200 Subject: [PATCH] Bugfix: EPS thumbnail failed EPS thumbnail failed to resize correctly due to incorrect resolution argument (should be a function of the image size and bounding box). This is fixed in this commit. --- PIL/EpsImagePlugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py index 4d19c1f20..0857dae24 100644 --- a/PIL/EpsImagePlugin.py +++ b/PIL/EpsImagePlugin.py @@ -78,7 +78,8 @@ def Ghostscript(tile, size, fp, scale=1): orig_bbox = bbox size = (size[0] * scale, size[1] * scale) bbox = [bbox[0], bbox[1], bbox[2] * scale, bbox[3] * scale] - #print("Ghostscript", scale, size, orig_size, bbox, orig_bbox) + res = ( int((72 * size[0]) / (bbox[2]-bbox[0])), int((72 * size[1]) / (bbox[3]-bbox[1])) ) + #print("Ghostscript", scale, size, orig_size, bbox, orig_bbox, res) import tempfile, os, subprocess @@ -100,7 +101,7 @@ def Ghostscript(tile, size, fp, scale=1): command = ["gs", "-q", # quiet mode "-g%dx%d" % size, # set output geometry (pixels) - "-r%d" % (72*scale), # set input DPI (dots per inch) + "-r%dx%d" % res, # set input DPI (dots per inch) "-dNOPAUSE -dSAFER", # don't pause between pages, safe mode "-sDEVICE=ppmraw", # ppm driver "-sOutputFile=%s" % outfile, # output file