On May 24, 7:00 pm, Andrew Straw <
ast...@caltech.edu> wrote:
> website. Virtually no one has heard of SourceForge and
> it has only 8 years of history and 1.8 million users
> in the open source community. Clearly the matplotlib
> developers hoped to avoid attracting users, generating
> discussion, or, worst of all, forming a community.
> Despite all the layers of security protecting the
> project, hundreds have already subscribed and posted
> to the mailing list. I have no idea how those
andrew, your points are valid, but i know what i’ve done
countless times, like sifting through mailing lists on
sf.net, dealing with <shudder/> mailman subscriptions
etc. -- mailman was great in the nineties, but now we have
google groups who set the standard in mailing list
accessibility. not suggesting everyone now move to big
brother google, but there are alternatives.
anyhow, thanks for going through the trouble to find
the example code for me. i immediately went to
sf.net to
download the source *.tgz separately (i don't think the
examples are installed when doing easy_install *.egg).
ok so this is image_demo3.py, ever so slightly edited to
preserve the original’s intent:
from pylab import *
import Image
pyl_image = Image.open('c:/temp/Guilloche.jpg')
dpi = rcParams['figure.dpi']
figsize = ( pyl_image.size[0] / dpi, pyl_image.size[1] / dpi, )
figure( figsize = figsize )
mpl_image = imshow(pyl_image, origin='lower')
savefig( 'c:/temp/Guilloche-modified.jpg' )
thanks for shortening this for me (here for comparison your much
leaner
code):
> import Image
> import pylab
> im=Image.open('/Users/astraw/Desktop/PC040235.jpg')
> pylab.imshow(im)
> pylab.axis('off')
> pylab.show()
you did manage to take out some complexities. there's no scaling
operation involved in your example, and no saving of the image. i have
to load, scale, and save a raster image, that's the task. the original
example fails with:
Traceback (most recent call last):
File "C:\temp\try-matplotlib.py", line 9, in <module>
savefig( 'c:/temp/Guilloche-modified.jpg' )
...
ValueError: Format "jpg" is not supported.
Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
ah yeah, was a bad idea right from the start to believe a math
plotting library would supply saving to *.jpg. well i now do it
in pil (`import Image`) altogether, includeing the image sacaling,
so i sidestepped that part.
but pls. observe that the data flow in both our examples is
at the least unintuitive: basically we both do
image = Image.open( '/foo/bar.jpg ) #1
pylab.imshow( image ) #2
pylab.axis('off') #3a
savefig( '/foo/baz.jpg' ) #3b
stepa #1 and #2 are ok so far. but steps #3a and #3b
both lack an explicit mention of the image at hand.
it remains obscure where the context is
derived from. my schoolmarm always warned me against
introducing this kind of hidden (global?) states, and
matplotlib uses a lot of it. the suspicion is that 1) i’ll run
into difficulties as soon as i handle more than one image
at any one given time, and that 2) this code is not threadsafe,
and can never be.
because of point 2, threadsafeness, if i want to use
this approch inside a web application, i will have to
take care any image processing is done only one
at any given time. barb.
ah, wrong place for this discussion, this is pyglet, not
matplotlib. not going to bother you guys no more with
that.
it's just so disappointing when you try to find
packages that bring accessible, no-nonsense image
handling capabilities to python, and you find a lot of
code, but little of it being readily usable, actively
maintained and so on. pygame was pointed out earlier,
cairo too, so that's the next things for me to look to.
the pyglet library did impress me for one. keep up the
good work. thx for the support.
cheers & ~flow
PS. ah yes someone suggested imagemagick to me earlier.
i have written a webservice for our company where you
can obtain images of headlines. works with imagemagick.
the headaches incurred in absorbing the relevant
documentation have been tremendous so far. imagemagick’s
(command-line) interface has wholly gone overboard. you
never know whether to put a minus, or a plus, or what
else, in front of your option letter, and whether to
quote your argument or not, and exactly what ‘special’
characters will be allowed and interpreted correctly:
convert -gravity South
caption:'Caption'
text:-'[0]'
-size 320x100 xc:lightblue
-trim +repage
-draw "fill tomato circle 250,30 310,30 text 0,0 'TEXT'"
-resize 64x64\!
(you see they have designed a drawing primitives sub-
language that goes into a string passed to `-draw`.
weird stuff that. overboard.)
to say something nice about this package, the example @
http://www.imagemagick.org/Usage/resize/#liquid-rescale
is a bit impressive: content-aware scaling, wow. but a
command-line interface convoluted as this is definietly
not the way to go. not me.