Code Monkey home page Code Monkey logo

pgmagick's Introduction

About

Build status

pgmagick is a yet another boost.python based wrapper for GraphicsMagick.

Installation

install to:

$ pip install pgmagick

Requirements

Python2.5++, GraphicsMagick and Boost.Python.

package install on Ubuntu(test on Ubuntu10.04+):

### Ubuntu11.10+ ###
$ apt-get install python-pgmagick

### Ubuntu10.04+ ###
$ apt-get install libgraphicsmagick++1-dev
$ apt-get install libboost-python1.40-dev

package install on Fedora:

$ yum install GraphicsMagick-c++-devel
$ yum install boost-devel

GraphicsMagick from source package:

$ ./configure --enable-shared=yes
$ make && make install

MacOSX

via homebrew-cask(homebrew-pgmagick)

use homebrew-pgmagick

$ brew tap hhatto/pgmagick
$ brew install pgmagick

via homebrew and pip

update 2014.05.12 on MacOSX 10.9.2 (add ARCHFLAGS):

$ brew install graphicsmagick
$ brew install boost --with-python
$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pgmagick

update 2013.08.31 with Homebrew

$ brew install graphicsmagick     # or imagemagick
$ brew install boost --with-thread-unsafe --build-from-source
$ pip install pgmagick

install reported on MacOSX, Thanks Rohan Singh and Simon Harrison.

Windows

Now, not official support. However, unofficial binary packages exists.

ImageMagick support

pgmagick is supported to ImageMagick library. (version:0.4+)

package install on Ubuntu(test on Ubuntu10.04+):

$ apt-get install libmagick++-dev

show library name and version:

>>> from pgmagick import gminfo
>>> gminfo.library
'GraphicsMagick'    # or 'ImageMagick'
>>> gminfo.version
'1.3.x'
>>>

Usage

scale example:

>>> from pgmagick import Image, FilterTypes
>>> im = Image('input.jpg')
>>> im.quality(100)
>>> im.filterType(FilterTypes.SincFilter)
>>> im.scale('100x100')
>>> im.sharpen(1.0)
>>> im.write('output.jpg')

composite example:

>>> from pgmagick import Image, CompositeOperator as co
>>> base = Image('base.png')
>>> layer = Image('layer_one.png')
>>> base.composite(layer, 100, 100, co.OverCompositeOp)
>>> im.write('output.png')

draw example:

>>> from pgmagick import Image, DrawableCircle, DrawableText, Geometry, Color
>>> im = Image(Geometry(300, 300), Color("yellow"))
>>> circle = DrawableCircle(100, 100, 20, 20)
>>> im.draw(circle)
>>> im.fontPointsize(65)
>>> text = DrawableText(30, 250, "Hello pgmagick")
>>> im.draw(text)
>>> im.write('hoge.png')

blob access:

>>> from pgmagick import Image, Blob, Geometry
>>> blob = Blob(open('filename.jpg').read())
>>> blob.update(open('filename2.jpg').read())
>>> img = Image(blob, Geometry(600, 480))
>>> img.scale('300x200')
>>> img.write('out.jpg')

create animated-GIF:

from pgmagick import Image, ImageList, Geometry, Color

imgs = ImageList()
for color in ('red', 'blue', 'green', 'black', 'yellow'):
    imgs.append(Image(Geometry(200, 200), Color(color)))
imgs.animationDelayImages(100)
imgs.scaleImages(Geometry(100, 100))
imgs.writeImages('output.gif')

more API detail... read to Magick++ API for GraphicsMagick document.

Python APIs(NOTICE!! this api is alpha version!!):

>>> from pgmagick.api import Image
>>> img = Image((300, 300), "gradient:#ffffff-#000000")
>>> img.scale(0.8)
>>> img.write('out.png')

Links

pgmagick's People

Contributors

ciupicri avatar hhatto avatar jerzyk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.