本文整理匯總了Python中PyQt5.Qt.QImageReader.supportedImageFormats方法的典型用法代碼示例。如果您正苦於以下問題:Python QImageReader.supportedImageFormats方法的具體用法?Python QImageReader.supportedImageFormats怎麽用?Python QImageReader.supportedImageFormats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.Qt.QImageReader
的用法示例。
在下文中一共展示了QImageReader.supportedImageFormats方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_qt
# 需要導入模塊: from PyQt5.Qt import QImageReader [as 別名]
# 或者: from PyQt5.Qt.QImageReader import supportedImageFormats [as 別名]
def test_qt(self):
from PyQt5.Qt import QImageReader, QNetworkAccessManager, QFontDatabase
from calibre.utils.img import image_from_data, image_to_data, test
# Ensure that images can be read before QApplication is constructed.
# Note that this requires QCoreApplication.libraryPaths() to return the
# path to the Qt plugins which it always does in the frozen build,
# because the QT_PLUGIN_PATH env var is set. On non-frozen builds,
# it should just work because the hard-coded paths of the Qt
# installation should work. If they do not, then it is a distro
# problem.
fmts = set(map(unicode, QImageReader.supportedImageFormats()))
testf = {'jpg', 'png', 'svg', 'ico', 'gif'}
self.assertEqual(testf.intersection(fmts), testf, "Qt doesn't seem to be able to load some of its image plugins. Available plugins: %s" % fmts)
data = I('blank.png', allow_user_override=False, data=True)
img = image_from_data(data)
image_from_data(P('catalog/mastheadImage.gif', allow_user_override=False, data=True))
for fmt in 'png bmp jpeg'.split():
d = image_to_data(img, fmt=fmt)
image_from_data(d)
# Run the imaging tests
test()
from calibre.gui2 import Application
os.environ.pop('DISPLAY', None)
app = Application([], headless=islinux)
self.assertGreaterEqual(len(QFontDatabase().families()), 5, 'The QPA headless plugin is not able to locate enough system fonts via fontconfig')
na = QNetworkAccessManager()
self.assertTrue(hasattr(na, 'sslErrors'), 'Qt not compiled with openssl')
from PyQt5.QtWebKitWidgets import QWebView
QWebView()
del QWebView
del na
del app
示例2: test_qt
# 需要導入模塊: from PyQt5.Qt import QImageReader [as 別名]
# 或者: from PyQt5.Qt.QImageReader import supportedImageFormats [as 別名]
def test_qt():
from calibre.gui2 import Application
from PyQt5.Qt import (QImageReader, QNetworkAccessManager, QFontDatabase)
from PyQt5.QtWebKitWidgets import QWebView
os.environ.pop('DISPLAY', None)
app = Application([], headless=islinux)
if len(QFontDatabase().families()) < 5:
raise RuntimeError('The QPA headless plugin is not able to locate enough system fonts via fontconfig')
fmts = set(map(unicode, QImageReader.supportedImageFormats()))
testf = set(['jpg', 'png', 'mng', 'svg', 'ico', 'gif'])
if testf.intersection(fmts) != testf:
raise RuntimeError(
"Qt doesn't seem to be able to load its image plugins")
QWebView()
del QWebView
na = QNetworkAccessManager()
if not hasattr(na, 'sslErrors'):
raise RuntimeError('Qt not compiled with openssl')
del na
del app
print ('Qt OK!')
示例3: image_extensions
# 需要導入模塊: from PyQt5.Qt import QImageReader [as 別名]
# 或者: from PyQt5.Qt.QImageReader import supportedImageFormats [as 別名]
def image_extensions():
if not hasattr(image_extensions, 'ans'):
image_extensions.ans = [as_unicode_polyglot(x) for x in QImageReader.supportedImageFormats()]
return image_extensions.ans
示例4: image_extensions
# 需要導入模塊: from PyQt5.Qt import QImageReader [as 別名]
# 或者: from PyQt5.Qt.QImageReader import supportedImageFormats [as 別名]
def image_extensions():
if not hasattr(image_extensions, 'ans'):
image_extensions.ans = [bytes(x).decode('utf-8') for x in QImageReader.supportedImageFormats()]
return image_extensions.ans