handle jpg/jpeg in the qtconsole #1643

merged 5 commits into from Apr 25, 2012


None yet

2 participants

IPython member

This add jpg/jpeg display in QtConsole, after png has been tried, of course.

@minrk minrk commented on an outdated diff Apr 22, 2012
@@ -69,24 +83,38 @@ def _context_menu_make(self, pos):
def _handle_pyout(self, msg):
""" Overridden to handle rich data types, like SVG.
+ def pre_image_append():
minrk Apr 22, 2012 IPython member

This function shouldn't be defined anew every time this is called. Just make it a method.

@minrk minrk and 1 other commented on an outdated diff Apr 22, 2012
@@ -36,6 +44,12 @@ def __init__(self, *args, **kw):
# Dictionary for resolving document resource names to SVG data.
self._name_to_svg_map = {}
+ # Do we support jpg ?
+ # it seems that sometime jpg support is a plugin of QT, so try to assume
+ # it is not always supported.
+ self._supported_format = map(str, QtGui.QImageReader.supportedImageFormats())
+ self._jpg_supported = 'jpeg' in self._supported_format
minrk Apr 22, 2012 IPython member

There should be no attributes that are not always defined. Make sure this is defined in the class at the top level (_jpg_supported = Bool(False))

Carreau Apr 23, 2012 IPython member

Well, it's true that I can put it at class top level, but I don't see why 'jpeg' in _supported_format can be not defined. and Bool traits would be overkill no ?

minrk via email Apr 23, 2012 IPython member
IPython member

What happens to jpegs during export?

IPython member

jpeg are converted to png at export time. I thought it was overkill to try to keep the original file format, as well as proposing a full jpeg export. ( who likes jpeg for graphs anyway ? )
Moreover rich_text.py and HtmlExporter are, I think, written to work only with only one function to convert from the <image> tag of the qtconsole to file.

@minrk minrk commented on an outdated diff Apr 25, 2012
@@ -65,6 +81,15 @@ def _context_menu_make(self, pos):
# 'BaseFrontendMixin' abstract interface
+ def _pre_image_append(self, msg, prompt_number):
+ """ Append the Out[] prompt and mke the output nicer
minrk Apr 25, 2012 IPython member


IPython member

one last spelling error, and I think it's ready for merge.

Carreau added some commits Apr 22, 2012
@Carreau Carreau handle jpg/jpeg in the qtconsole.
This try to handle both image/jpeg image/jpg mimetype that arrives in
the qtconsole, when QImage support It,
note that image/jpg should never append, but is still supported.

It does not allows the export as html/jpeg. The jpeg will be converted
to png at save time.
@Carreau Carreau pylinting 51ddac4
@Carreau Carreau more robust code
_pre_image_append as method
_jpg_supported as Bool Trait
@Carreau Carreau strip copyright 9e8cfdd
@Carreau Carreau do not handle image/jpg 9d7b5df
IPython member

Thanks, as I rebased on master to avoid recursive merge, I squashed the fix in the commit that introduced the docstring :-)
Should I merge ?

IPython member

Sure, go for it.

@Carreau Carreau merged commit f387e4a into ipython:master Apr 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment