Commit 26303ade authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'feature/thabloid-better-image-quality' into 'master'

Improve Thabloid image quality

See merge request !749
parents ad3d05cd 7a8576b3
......@@ -42,11 +42,11 @@ class Thabloid(models.Model):
def page_url(self, page=None, second_page=None):
if page is None:
page = '%03d.jpg'
page = '%03d.png'
elif second_page is None:
page = '{:03}.jpg'.format(page)
page = '{:03}.png'.format(page)
else:
page = '{:03}-{:03}.jpg'.format(page, second_page)
page = '{:03}-{:03}.png'.format(page, second_page)
dst, ext = os.path.splitext(self.file.name)
return os.path.join(os.path.dirname(dst), 'pages',
os.path.basename(dst), page)
......@@ -97,8 +97,8 @@ class Thabloid(models.Model):
filename = (os.path.splitext(
os.path.basename(spread_left))[0] + '-' +
os.path.splitext(os.path.basename(spread_right))[0] +
'.jpg')
result.save(os.path.join(dirname, filename), 'JPEG', quality=90)
'.png')
result.save(os.path.join(dirname, filename), 'PNG')
os.remove(spread_left)
os.remove(spread_right)
......@@ -120,7 +120,8 @@ class Thabloid(models.Model):
['gs', '-o', dst,
# '-g2100x2970', '-dPDFFitPage',
'-g1050x1485', '-dPDFFitPage',
'-sDEVICE=jpeg', '-f', src],
'-dTextAlphaBits=4',
'-sDEVICE=png16m', '-f', src],
stdout=subprocess.DEVNULL
)
if wait:
......
......@@ -35,14 +35,14 @@ class TestThabloid(TestCase):
def test_page_urls(self):
self.assertEqual(
self.thabloid.cover,
'public/thabloids/pages/thabloid-1998-1999-1/001.jpg')
'public/thabloids/pages/thabloid-1998-1999-1/001.png')
self.assertEqual(
self.thabloid.page_url(2, 3),
'public/thabloids/pages/thabloid-1998-1999-1/002-003.jpg')
'public/thabloids/pages/thabloid-1998-1999-1/002-003.png')
# check if it's actual zeropadding and not just '00' + i
self.assertEqual(
self.thabloid.page_url(20),
'public/thabloids/pages/thabloid-1998-1999-1/020.jpg')
'public/thabloids/pages/thabloid-1998-1999-1/020.png')
@staticmethod
def _pdf_exist(pdf):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment