Zooming and panning images

I have attached a python script that I believe would be useful as a template for the manipulation of images with wxPython and PIL. It would be interesting to know if the use of PIL can be eliminated; i.e. wxPython imported, but not Image from PIL. Any feedback (positive or negative) on this snippet would be welcomed.

Have fun!:slight_smile:

ImageZoomScaleExampleC.py (11.4 KB)

Hi,
thanks for the sample code;
as for the avoiding of the PIL dependence, you may try, whether
wx.Image would satisfy your needs:
http://www.wxpython.org/docs/api/wx.Image-class.html

I used it for a simple image viewer and it was rather straigtforward,
but you have to check it with respect to your needs - it is clearly
rather lightweight compared to pil.

hth,
  vbr

···

2014-03-05 12:57 GMT+01:00 Virgil Stokes <vs@it.uu.se>:

I have attached a python script that I believe would be useful as a template
for the manipulation of images with wxPython and PIL. It would be
interesting to know if the use of PIL can be eliminated; i.e. wxPython
imported, but not Image from PIL. Any feedback (positive or negative) on
this snippet would be welcomed.

Have fun!:slight_smile:

--

Sure -- at least at a glance, wx.Image has everything you need.

-Chris

···

On Wed, Mar 5, 2014 at 3:57 AM, Virgil Stokes <vs@it.uu.se> wrote:

I have attached a python script that I believe would be useful as a
template for the manipulation of images with wxPython and PIL. It would be
interesting to know if the use of PIL can be eliminated; i.e. wxPython
imported, but not Image from PIL.

--

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

Chris.Barker@noaa.gov

I have written a couple image viewer implementations myself.
I looked at it, and yes, after a few mods I got it to fire with wxPython only, so yes, PIL isn’t needed here.
PIL is nice and performs better for image stuff like this, so the best thing for you to do
would be to try and import PIL at the start and depending on if it imported, then use a global to regulate how what methods to use.

The code be optimized quite a bit in certain places I see. Also, the Image Window should be it’s own class so that it is easily reusable and not tied into the frame class.
The newer versions of wxPython wx.Image can handle everything I see here.
PIL would only be useful for slight performance gains and maybe oddball image operations if you want to show certain image effects.

The Image window would perform better as a buffer bitmap also, and just have the Paint function call the buffer with a BufferedPaintDC and empty EraseBackground def.

…anyway, that’s just my 2-cents…

···

On Wednesday, March 5, 2014 5:57:54 AM UTC-6, Birdy wrote:

I have attached a python script that I believe would be useful as a template for
the manipulation of images with wxPython and PIL. It would be interesting to
know if the use of PIL can be eliminated; i.e. wxPython imported, but not Image
from PIL. Any feedback (positive or negative) on this snippet would be welcomed.

Have fun!:slight_smile: