PythonMagickWand on PyPi

Achim | python | Sunday, July 20th, 2008

Today I have created my first python egg! It’s a PythonMagickWand egg and can be found on PyPi. I have also created a first version of a Sphinx based documentation which can be found in our subversion repository.

3 Comments »

  1. Hi, tried installing this on python 2.6 and got the following error

    [C:\Documents and Settings\stuart.axon\Desktop\download]easy_install PythonMagickWand-0.2-py2.5.egg
    Processing PythonMagickWand-0.2-py2.5.egg
    Copying PythonMagickWand-0.2-py2.5.egg to c:\usr\python26\lib\site-packages
    Adding PythonMagickWand 0.2 to easy-install.pth file

    Installed c:\usr\python26\lib\site-packages\pythonmagickwand-0.2-py2.5.egg
    Processing dependencies for PythonMagickWand==0.2
    Searching for PythonMagickWand==0.2
    Reading http://pypi.python.org/simple/PythonMagickWand/
    Reading http://public.procoders.net/PythonMagickWand/docs/html/index.html
    No local packages or download links found for PythonMagickWand==0.2
    error: Could not find suitable distribution for Requirement.parse(’PythonMagickWand==0.2′)

    Comment by Stu — November 10, 2008 @ 19:45

  2. This works:
    >>> from PythonMagickWand import *
    >>> f=open(’badge-10.pdf’)
    >>> wand = NewMagickWand()
    >>> MagickReadImage(wand,f)

    But my pdf and png are not disk files, they are in string io buffers. or just string vars. I want to replace this code:

    def badge_png(ds):
    “”"
    make a badge image based on real data
    “”"

    # pdf = open(’pycon_sample_badge.pdf’,'rb’).read()
    pdf = mkpdf(ds)

    # convert pdf to some image format
    gs_command = ['gs',
    '-q',
    '-sDEVICE=png16m',
    '-dBATCH', '-dNOPAUSE',
    '-sOutputFile=-',
    '-' ]
    gs_run = subprocess.Popen(gs_command, shell=False, stdin=subprocess.PIPE,
    stdout=subprocess.PIPE, close_fds=True,
    bufsize=1<<12)
    real_wait = gs_run.wait
    def hack_wait():
    try: return real_wait()
    except OSError, e:
    if e.errno != 10: raise
    return 0
    gs_run.wait = hack_wait
    (stdout, stderr) = gs_run.communicate(pdf)

    # crop the badge (pdf may be 8×11 page)
    # and write to a string that can be reutnred
    buffin = StringIO(stdout)
    buffout = StringIO()
    Image.open(buffin).crop([0,0,286,225]).save(buffout, ‘png’)
    img = buffout.getvalue()
    return img

    For the purposed of this thread, mkpdf(ds) can be replaced with
    pdf = open(’pycon_sample_badge.pdf’,'rb’).read()

    Now that we know what pdf is, how do I pass it to MagickReadImage?

    Comment by Carl Karsten — December 24, 2008 @ 9:19

  3. Cool, a higher level API

    But it’s better if you restore the original Pythonmagick webpage (http://www.procoders.net/pythonmagick) as there is not much documentation on PythonMagick API anywhere…

    Thanks!

    Comment by Eric Saint-Etienne — March 19, 2009 @ 12:59

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress | Theme by Roy Tanck

Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien: