|
|
Author: Date: Subject:
Jacek Poplawski
2008-07-16 20:38:34
[wxpython-users] faster image load?
I want to display thumbnails of photos, I use following code to generate
them:
image = wx.Image(name, wx.BITMAP_TYPE_JPEG)
scaledImage = Scale(image, sizeX, sizeY)
bitmap = wx.StaticBitmap(self, bitmap=wx.BitmapFromImage(scaledImage))
It is very slow. When I cache first line (creating Image), two other lines
work fast. So the problem is in the loading.
Is there any way in wxPython to load JPEG file in lower quality, or in lower
resolution?
Picture browsers display images quickly, wx.Image loads them in full size
and is slow.
Could you recommend any better solution?
--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from
http://decopter.sf.net
<div dir="ltr">I want to display thumbnails of photos, I use following code to generate them:<br><br>image = wx.Image(name, wx.BITMAP_TYPE_JPEG)<br>scaledImage = Scale(image, sizeX, sizeY)<br>bitmap = wx.StaticBitmap(self, bitmap=wx.BitmapFromImage(scaledImage))<br>
<br>It is very slow. When I cache first line (creating Image), two other lines work fast. So the problem is in the loading.<br>Is there any way in wxPython to load JPEG file in lower quality, or in lower resolution?<br><br>
Picture browsers display images quickly, wx.Image loads them in full size and is slow.<br><br>Could you recommend any better solution?<br><br clear="all"><br>-- <br>Free Software - find interesting programs and change them<br>
NetHack - meet interesting creatures, kill them and eat their bodies<br>Usenet - meet interesting people from all over the world and flame them<br>Decopter - unrealistic helicopter simulator, get it from <a href="http://decopter.sf.net">http://decopter.sf.net</a><br>
</div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author: Date: Subject:
Mike Driscoll
2008-07-16 14:05:14
Re: [wxpython-users] faster image load?
Jacek,
> I want to display thumbnails of photos, I use following code to
> generate them:
>
> image = wx.Image(name, wx.BITMAP_TYPE_JPEG)
> scaledImage = Scale(image, sizeX, sizeY)
> bitmap = wx.StaticBitmap(self, bitmap=wx.BitmapFromImage(scaledImage))
>
> It is very slow. When I cache first line (creating Image), two other
> lines work fast. So the problem is in the loading.
> Is there any way in wxPython to load JPEG file in lower quality, or in
> lower resolution?
>
> Picture browsers display images quickly, wx.Image loads them in full
> size and is slow.
>
> Could you recommend any better solution?
>
Check out Andrea's and Peter's ThumbnailCtrl:
http://xoomer.alice.it/infinity77/main/ThumbnailCtrl.html
I think it does what you want. And if not, you can hack it!
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author: Date: Subject:
Christopher Barker
2008-07-16 14:41:51
Re: [wxpython-users] faster image load?
Mike Driscoll wrote:
> Check out Andrea's and Peter's ThumbnailCtrl:
> http://xoomer.alice.it/infinity77/main/ThumbnailCtrl.html
Which is nice, but I"m not sure it would solve the OP's problem.
I suspect that it takes a while to load up the entire image, then
convert it to a thumbnail.
With jpeg, is is possible to load up a lower resolution image without
loading the whole thing. Essentially, what you can do is load just the
average value for each 8x8 pixel block -- a trick that takes advantage
of how jpeg is compressed.
I doubt wx supports this, but PIL (or another image processing tool for
Python) might.
Otherwise, what you would do ideally is cache the thumbnails somewhere,
so you don't need to re-create them each time the app is used.
image = wx.Image(name, wx.BITMAP_TYPE_JPEG)
scaledImage = Scale(image, sizeX, sizeY)
Where does this "Scale" function from from? You might try:
scaledImage = image.Scale(sizeX, sizeY)
or
scaledImage = image.Scale(sizeX, sizeY, wx.IMAGE_QUALITY_HIGH)
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author: Date: Subject:
Jacek Poplawski
2008-07-16 23:43:17
Re: [wxpython-users] faster image load?
On Wed, Jul 16, 2008 at 11:41 PM, Christopher Barker <[email protected]>
wrote:
> Mike Driscoll wrote:
>
>> Check out Andrea's and Peter's ThumbnailCtrl:
>> http://xoomer.alice.it/infinity77/main/ThumbnailCtrl.html
>>
>
> Which is nice, but I"m not sure it would solve the OP's problem.
Well.... I installed this script, started it, and it loads thumbnails very
quickly.
But it just uses PIL. I need to analize how it works.
>
> image = wx.Image(name, wx.BITMAP_TYPE_JPEG)
> scaledImage = Scale(image, sizeX, sizeY)
>
> Where does this "Scale" function from from? You might try:
>
> scaledImage = image.Scale(sizeX, sizeY)
> or
> scaledImage = image.Scale(sizeX, sizeY, wx.IMAGE_QUALITY_HIGH)
Oh, sorry, yes, I am calling image.Scale inside my Scale, and this doesn't
affect performance, the only problem is loading image.
--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from
http://decopter.sf.net
<div dir="ltr">On Wed, Jul 16, 2008 at 11:41 PM, Christopher Barker <<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Mike Driscoll wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Check out Andrea's and Peter's ThumbnailCtrl: <a href="http://xoomer.alice.it/infinity77/main/ThumbnailCtrl.html" target="_blank">http://xoomer.alice.it/infinity77/main/ThumbnailCtrl.html</a><br>
</blockquote>
<br></div>
Which is nice, but I"m not sure it would solve the OP's problem.</blockquote><div><br>Well.... I installed this script, started it, and it loads thumbnails very quickly.<br>But it just uses PIL. I need to analize how it works.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="Ih2E3d">image = wx.Image(name, wx.BITMAP_TYPE_JPEG)<br>
scaledImage = Scale(image, sizeX, sizeY)<br>
<br></div>
Where does this "Scale" function from from? You might try:<br>
<br>
scaledImage = image.Scale(sizeX, sizeY)<br>
or<br>
scaledImage = image.Scale(sizeX, sizeY, wx.IMAGE_QUALITY_HIGH)</blockquote><div><br>Oh, sorry, yes, I am calling image.Scale inside my Scale, and this doesn't affect performance, the only problem is loading image.<br>
<br></div></div><br>-- <br>Free Software - find interesting programs and change them<br>NetHack - meet interesting creatures, kill them and eat their bodies<br>Usenet - meet interesting people from all over the world and flame them<br>
Decopter - unrealistic helicopter simulator, get it from <a href="http://decopter.sf.net">http://decopter.sf.net</a><br>
</div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author: Date: Subject:
Jacek Poplawski
2008-07-17 11:10:40
Re: [wxpython-users] faster image load?
If anyone is interested in the solution (I found it by reading
ThumbnailCtrl.py):
# from pil
import Image
# thumbnail size
tx = 100
ty = 100
# fast load
pil_image = Image.open(full)
pil_image.thumbnail((tx,ty))
# convert to wx
img = wx.EmptyImage(pil_image.size[0], pil_image.size[1])
d = pil_image.convert("RGB")
img.SetData(d.tostring())
# now img is wx.Image with thumbnail
--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from
http://decopter.sf.net
<div dir="ltr">If anyone is interested in the solution (I found it by reading ThumbnailCtrl.py):<br><br># from pil<br>
import Image <br><br> # thumbnail size<br> tx = 100<br>
ty = 100<br>
<br> # fast load<br> pil_image = Image.open(full)<br> pil_image.thumbnail((tx,ty))<br> <br> # convert to wx<br> img = wx.EmptyImage(pil_image.size[0], pil_image.size[1])<br>
d = pil_image.convert("RGB")<br> img.SetData(d.tostring())<br><br> # now img is wx.Image with thumbnail<br><br>-- <br>Free Software - find interesting programs and change them<br>
NetHack - meet interesting creatures, kill them and eat their bodies<br>Usenet - meet interesting people from all over the world and flame them<br>Decopter - unrealistic helicopter simulator, get it from <a href="http://decopter.sf.net">http://decopter.sf.net</a><br>
</div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
|