[SBNOutput] Use jpg instead of png.

This commit is contained in:
Li Fanxi 2010-10-11 00:49:11 +08:00
parent 29e133c61a
commit 3ec09a3b40
2 changed files with 6 additions and 11 deletions

View File

@ -160,7 +160,7 @@ class SNBOutput(OutputFormatPlugin):
mergeLast = False
lastName = None
for item in s:
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_IMAGES, PNG_MIME
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_IMAGES
if m.hrefs[item.href].media_type in OEB_DOCS:
if not item.href in outputFiles:
log.debug('File %s is unused in TOC. Continue in last chapter' % item.href)
@ -203,14 +203,9 @@ class SNBOutput(OutputFormatPlugin):
if m.hrefs[item.href].media_type in OEB_IMAGES:
log.debug('Converting image: %s ...' % item.href)
content = m.hrefs[item.href].data
if m.hrefs[item.href].media_type != PNG_MIME:
# Convert & Resize image
self.HandleImage(content, os.path.join(snbiDir, ProcessFileName(item.href)))
else:
outputFile = open(os.path.join(snbiDir, ProcessFileName(item.href)), 'wb')
outputFile.write(content)
outputFile.close()
# Convert & Resize image
self.HandleImage(content, os.path.join(snbiDir, ProcessFileName(item.href)))
# Package as SNB File
snbFile = SNBFile()
snbFile.FromDir(tdir)

View File

@ -23,10 +23,10 @@ def ProcessFileName(fileName):
fileName = fileName.replace("#", "_")
# Make it lower case
fileName = fileName.lower()
# Change extension from jpeg to jpg
# Change all images to jpg
root, ext = os.path.splitext(fileName)
if ext in [ '.jpeg', '.jpg', '.gif', '.svg' ]:
fileName = root + '.png'
fileName = root + '.jpg'
return fileName