thanks for your answer, i have come to understand that matplotlib is not 
dedicated to raster image manipulation. a nice person pointed out to me 
how to do that in cairo:

img = cairo.ImageSurface.create_from_png( 'c:/temp/tel-hotline.png' )
width = img.get_width()
height = img.get_height()
imgpat = cairo.SurfacePattern(img)
scaler = cairo.Matrix()
#1 = 100%; 2 = 50%;0.5 = 200%
scaler.scale(3,0.5)
imgpat.set_matrix(scaler)
#set resampling filter
imgpat.set_filter(cairo.FILTER_BEST)
canvas = cairo.ImageSurface(cairo.FORMAT_ARGB32,320,240)
ctx = cairo.Context(canvas)
ctx.set_source(imgpat)
ctx.paint()
canvas.write_to_png( 'c:/temp/helo-modified.png' )

that's a bit of code but i'm writing a wrapper `def scale_image()` 
anyhow. the data flow seems reasonable. alas, it only works for *.png, 
no *.jpg support. still i guess i'll go with cairo as it's seemingly 
used inside firefox3 and does impressively good scaling.

cheers & ~flow


Gregor Thalhammer wrote:
> > [had to delete an endless amount of stuff not related to matplotlib]
>
> matplotlib is _not_ a dedicated image manipulation package, so please 
> don't blame it that you don't manage to easily use it as such one. 
> However, matplotlib indeed offers high quality image scaling abilities 
> (at the moment not for downscaling) due to the use of Agg.
>
> If you want a simpler solution, try this:
>
> import wx
> img = wx.Image('your image.jpg')
> scale = 2
> img.Rescale(img.Width * scale, img.Height * scale, wx.IMAGE_QUALITY_HIGH)
> img.SaveFile('your scaled image.jpg')
>
> Gregor
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to