Quantcast

[IPython-User] ipython notebook - how to display image (not from pylab)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[IPython-User] ipython notebook - how to display image (not from pylab)

Anthony Tanbakuchi
I have a custom module that generates a png image file from some
calculations (sadly it doesn't work well for me to use matplotlib to
display this image). It's rather slow to read the image back in to
matplotlib and display it since it is somewhat large. How can I embed
my image similar to how it is done for the pylab inline option?

Are there any special hooks in the notebook where I can easily do
this? Or is there a way I could just print the html code to display
the image file inline? Something like print '<img src="file.png"/>'
and have that displayed in the notebook as html rather than code
output.

Thanks for the great work on the notebook server. It's a great tool.

-Anthony
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ipython notebook - how to display image (not from pylab)

Brian Granger-3
There are a couple of ways of doing this, but the simplest is the following:

from IPython.core.display import Image
Image('myimage.png')

Cheers,

Brian

On Wed, Feb 22, 2012 at 7:59 PM, Anthony Tanbakuchi
<[hidden email]> wrote:

> I have a custom module that generates a png image file from some
> calculations (sadly it doesn't work well for me to use matplotlib to
> display this image). It's rather slow to read the image back in to
> matplotlib and display it since it is somewhat large. How can I embed
> my image similar to how it is done for the pylab inline option?
>
> Are there any special hooks in the notebook where I can easily do
> this? Or is there a way I could just print the html code to display
> the image file inline? Something like print '<img src="file.png"/>'
> and have that displayed in the notebook as html rather than code
> output.
>
> Thanks for the great work on the notebook server. It's a great tool.
>
> -Anthony
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user



--
Brian E. Granger
Cal Poly State University, San Luis Obispo
[hidden email] and [hidden email]
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ipython notebook - how to display image (not from pylab)

Anthony Tanbakuchi
Brian,

Thanks, using Image(filename='myimage.png') works well.

One additional question that I couldn't find from the documents. Is
there a way that I can specify the html image width / height
properties for the displayed image?

Annoyingly, the package I'm using generates very large PNG files that
display way to large to view in the notebook without lots of
scrolling. I'm trying to figure out how to change the output in the
package, but in the mean time, can I just use HTML tags to scale the
image? I'd rather not have to down size the images via post processing
before displaying.

Thanks,

Anthony

On Wed, Feb 22, 2012 at 9:27 PM, Brian Granger <[hidden email]> wrote:

> There are a couple of ways of doing this, but the simplest is the following:
>
> from IPython.core.display import Image
> Image('myimage.png')
>
> Cheers,
>
> Brian
>
> On Wed, Feb 22, 2012 at 7:59 PM, Anthony Tanbakuchi
> <[hidden email]> wrote:
>> I have a custom module that generates a png image file from some
>> calculations (sadly it doesn't work well for me to use matplotlib to
>> display this image). It's rather slow to read the image back in to
>> matplotlib and display it since it is somewhat large. How can I embed
>> my image similar to how it is done for the pylab inline option?
>>
>> Are there any special hooks in the notebook where I can easily do
>> this? Or is there a way I could just print the html code to display
>> the image file inline? Something like print '<img src="file.png"/>'
>> and have that displayed in the notebook as html rather than code
>> output.
>>
>> Thanks for the great work on the notebook server. It's a great tool.
>>
>> -Anthony
>> _______________________________________________
>> IPython-User mailing list
>> [hidden email]
>> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
> --
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> [hidden email] and [hidden email]
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ipython notebook - how to display image (not from pylab)

Zoltán Vörös-2
Hi Antony,

Your question was addressed to Brian, but perhaps, you won't mind, if I
answer. You could do something like this

from IPython.core.display import HTML
HTML('<img src="files/python-logo.svg" width=100 height=20/>')

I hope this helps.
Cheers,
Zoltán

On 02/23/2012 05:14 PM, Anthony Tanbakuchi wrote:

> Brian,
>
> Thanks, using Image(filename='myimage.png') works well.
>
> One additional question that I couldn't find from the documents. Is
> there a way that I can specify the html image width / height
> properties for the displayed image?
>
> Annoyingly, the package I'm using generates very large PNG files that
> display way to large to view in the notebook without lots of
> scrolling. I'm trying to figure out how to change the output in the
> package, but in the mean time, can I just use HTML tags to scale the
> image? I'd rather not have to down size the images via post processing
> before displaying.
>
> Thanks,
>
> Anthony
>
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ipython notebook - how to display image (not from pylab)

Brian Granger-3
Yes, that will work, but we should add width/height keyword args to
the Image class.  Could you create a github issue for this?

Cheers,

Brian

2012/2/23 Zoltán Vörös <[hidden email]>:

> Hi Antony,
>
> Your question was addressed to Brian, but perhaps, you won't mind, if I
> answer. You could do something like this
>
> from IPython.core.display import HTML
> HTML('<img src="files/python-logo.svg" width=100 height=20/>')
>
> I hope this helps.
> Cheers,
> Zoltán
>
> On 02/23/2012 05:14 PM, Anthony Tanbakuchi wrote:
>> Brian,
>>
>> Thanks, using Image(filename='myimage.png') works well.
>>
>> One additional question that I couldn't find from the documents. Is
>> there a way that I can specify the html image width / height
>> properties for the displayed image?
>>
>> Annoyingly, the package I'm using generates very large PNG files that
>> display way to large to view in the notebook without lots of
>> scrolling. I'm trying to figure out how to change the output in the
>> package, but in the mean time, can I just use HTML tags to scale the
>> image? I'd rather not have to down size the images via post processing
>> before displaying.
>>
>> Thanks,
>>
>> Anthony
>>
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user



--
Brian E. Granger
Cal Poly State University, San Luis Obispo
[hidden email] and [hidden email]
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ipython notebook - how to display image (not from pylab)

Anthony Tanbakuchi
Thanks for the response.

I went to add the issue but it was already added. You guys are fast.

-Anthony

On Thu, Feb 23, 2012 at 11:07 AM, Brian Granger <[hidden email]> wrote:

> Yes, that will work, but we should add width/height keyword args to
> the Image class.  Could you create a github issue for this?
>
> Cheers,
>
> Brian
>
> 2012/2/23 Zoltán Vörös <[hidden email]>:
>> Hi Antony,
>>
>> Your question was addressed to Brian, but perhaps, you won't mind, if I
>> answer. You could do something like this
>>
>> from IPython.core.display import HTML
>> HTML('<img src="files/python-logo.svg" width=100 height=20/>')
>>
>> I hope this helps.
>> Cheers,
>> Zoltán
>>
>> On 02/23/2012 05:14 PM, Anthony Tanbakuchi wrote:
>>> Brian,
>>>
>>> Thanks, using Image(filename='myimage.png') works well.
>>>
>>> One additional question that I couldn't find from the documents. Is
>>> there a way that I can specify the html image width / height
>>> properties for the displayed image?
>>>
>>> Annoyingly, the package I'm using generates very large PNG files that
>>> display way to large to view in the notebook without lots of
>>> scrolling. I'm trying to figure out how to change the output in the
>>> package, but in the mean time, can I just use HTML tags to scale the
>>> image? I'd rather not have to down size the images via post processing
>>> before displaying.
>>>
>>> Thanks,
>>>
>>> Anthony
>>>
>> _______________________________________________
>> IPython-User mailing list
>> [hidden email]
>> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
> --
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> [hidden email] and [hidden email]
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Loading...