mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
764fcca0ad
commit
1eba9df0a2
@ -6,10 +6,9 @@ www.standardmedia.co.ke
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from calibre import strftime, __appname__, __version__
|
from calibre import strftime, __appname__, __version__
|
||||||
import calibre.utils.PythonMagickWand as pw
|
|
||||||
from ctypes import byref
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from calibre.constants import preferred_encoding
|
from calibre.constants import preferred_encoding
|
||||||
|
from calibre.utils.magick import Image
|
||||||
|
|
||||||
class NationKeRecipe(BasicNewsRecipe):
|
class NationKeRecipe(BasicNewsRecipe):
|
||||||
|
|
||||||
@ -95,19 +94,9 @@ class NationKeRecipe(BasicNewsRecipe):
|
|||||||
self.cover_img_path = None
|
self.cover_img_path = None
|
||||||
|
|
||||||
def prepare_cover_image(self, path_to_image, out_path):
|
def prepare_cover_image(self, path_to_image, out_path):
|
||||||
with pw.ImageMagick():
|
img = Image()
|
||||||
img = pw.NewMagickWand()
|
img.open(path_to_image)
|
||||||
if img < 0:
|
img.save(out_path)
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickReadImage(img, path_to_image):
|
|
||||||
severity = pw.ExceptionType(0)
|
|
||||||
msg = pw.MagickGetException(img, byref(severity))
|
|
||||||
raise IOError('Failed to read image from: %s: %s'
|
|
||||||
%(path_to_image, msg))
|
|
||||||
if not pw.MagickWriteImage(img, out_path):
|
|
||||||
raise RuntimeError('Failed to save image to %s'%out_path)
|
|
||||||
pw.DestroyMagickWand(img)
|
|
||||||
|
|
||||||
|
|
||||||
def default_cover(self, cover_file):
|
def default_cover(self, cover_file):
|
||||||
'''
|
'''
|
||||||
|
@ -6,11 +6,10 @@ www.standardmedia.co.ke
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from calibre import strftime, __appname__, __version__
|
from calibre import strftime, __appname__, __version__
|
||||||
import calibre.utils.PythonMagickWand as pw
|
|
||||||
from ctypes import byref
|
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from calibre.constants import preferred_encoding
|
from calibre.constants import preferred_encoding
|
||||||
|
from calibre.utils.magick import Image
|
||||||
|
|
||||||
class StandardMediaKeRecipe(BasicNewsRecipe):
|
class StandardMediaKeRecipe(BasicNewsRecipe):
|
||||||
|
|
||||||
@ -88,19 +87,9 @@ class StandardMediaKeRecipe(BasicNewsRecipe):
|
|||||||
self.cover_img_path = None
|
self.cover_img_path = None
|
||||||
|
|
||||||
def prepare_cover_image(self, path_to_image, out_path):
|
def prepare_cover_image(self, path_to_image, out_path):
|
||||||
with pw.ImageMagick():
|
img = Image()
|
||||||
img = pw.NewMagickWand()
|
img.open(path_to_image)
|
||||||
if img < 0:
|
img.save(out_path)
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickReadImage(img, path_to_image):
|
|
||||||
severity = pw.ExceptionType(0)
|
|
||||||
msg = pw.MagickGetException(img, byref(severity))
|
|
||||||
raise IOError('Failed to read image from: %s: %s'
|
|
||||||
%(path_to_image, msg))
|
|
||||||
if not pw.MagickWriteImage(img, out_path):
|
|
||||||
raise RuntimeError('Failed to save image to %s'%out_path)
|
|
||||||
pw.DestroyMagickWand(img)
|
|
||||||
|
|
||||||
|
|
||||||
def default_cover(self, cover_file):
|
def default_cover(self, cover_file):
|
||||||
'''
|
'''
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user