+ self.build_cover()
+
+ def build_cover(self):
+ width, height = 216, 300
+ try:
+ xml = self.materialize(publishable=True).encode('utf-8')
+ info = BookInfo.from_bytes(xml)
+ cover = make_cover(info, width=width, height=height)
+ out = BytesIO()
+ ext = cover.ext()
+ cover.save(out)
+ self.cover.save(f'{self.slug}.{ext}', out, save=False)
+ type(self).objects.filter(pk=self.pk).update(cover=self.cover)
+ except:
+ type(self).objects.filter(pk=self.pk).update(cover='')