mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix bug in handling of images that could causes errors.
This commit is contained in:
parent
d0af243f96
commit
275b59a2e7
@ -70,11 +70,12 @@ def fit_image(width, height, pwidth, pheight):
|
|||||||
corrf = pheight/float(height)
|
corrf = pheight/float(height)
|
||||||
width, height = floor(corrf*width), pheight
|
width, height = floor(corrf*width), pheight
|
||||||
if width > pwidth:
|
if width > pwidth:
|
||||||
corrf = (pwidth)/float(width)
|
corrf = pwidth/float(width)
|
||||||
width, height = pwidth, floor(corrf*height)
|
width, height = pwidth, floor(corrf*height)
|
||||||
if height > pheight:
|
if height > pheight:
|
||||||
corrf = pheight/float(height)
|
corrf = pheight/float(height)
|
||||||
width, height = floor(corrf*width), pheight
|
width, height = floor(corrf*width), pheight
|
||||||
|
|
||||||
return scaled, int(width), int(height)
|
return scaled, int(width), int(height)
|
||||||
|
|
||||||
|
|
||||||
@ -207,6 +208,7 @@ class HTMLConverter(object):
|
|||||||
self.links = deque() #: <a href=...> elements
|
self.links = deque() #: <a href=...> elements
|
||||||
self.processed_files = []
|
self.processed_files = []
|
||||||
self.extra_toc_entries = [] #: TOC entries gleaned from semantic information
|
self.extra_toc_entries = [] #: TOC entries gleaned from semantic information
|
||||||
|
self.image_memory = []
|
||||||
self.id_counter = 0
|
self.id_counter = 0
|
||||||
self.unused_target_blocks = [] #: Used to remove extra TextBlocks
|
self.unused_target_blocks = [] #: Used to remove extra TextBlocks
|
||||||
self.link_level = 0 #: Current link level
|
self.link_level = 0 #: Current link level
|
||||||
@ -834,7 +836,6 @@ class HTMLConverter(object):
|
|||||||
if fmt == 'JPG':
|
if fmt == 'JPG':
|
||||||
fmt = 'JPEG'
|
fmt = 'JPEG'
|
||||||
return fmt
|
return fmt
|
||||||
|
|
||||||
original_path = path
|
original_path = path
|
||||||
if self.rotated_images.has_key(path):
|
if self.rotated_images.has_key(path):
|
||||||
path = self.rotated_images[path].name
|
path = self.rotated_images[path].name
|
||||||
@ -855,6 +856,7 @@ class HTMLConverter(object):
|
|||||||
|
|
||||||
def scale_image(width, height):
|
def scale_image(width, height):
|
||||||
pt = PersistentTemporaryFile(suffix='.'+encoding.lower())
|
pt = PersistentTemporaryFile(suffix='.'+encoding.lower())
|
||||||
|
self.image_memory.append(pt) # Neccessary, trust me ;-)
|
||||||
try:
|
try:
|
||||||
im.resize((int(width), int(height)), PILImage.ANTIALIAS).save(pt, encoding)
|
im.resize((int(width), int(height)), PILImage.ANTIALIAS).save(pt, encoding)
|
||||||
pt.close()
|
pt.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user