No description, website, or topics provided.
Groovy
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.settings
grails-app first commit Sep 16, 2011
scripts
src/groovy/org/groovydev fix: saving jpg files Oct 4, 2011
test
web-app/WEB-INF
.classpath fix: saving jpg files Oct 4, 2011
.gitignore
.project first commit Sep 16, 2011
ImageBuilderGrailsPlugin.groovy
README.md fix: saving jpg files Oct 4, 2011
application.properties first commit Sep 16, 2011
plugin.xml

README.md

A simple image builder grails plugin

Example: How to create square 50px50p and 20px20p tumbnail images.

    def b = new org.groovydev.SimpleImageBuilder()
    b.render(width:'100px',height:'100px') {
       fill(color:'ffffff')
       def small
       image(file:'image.jpg') {
         small = fit(width:100,height:100)
       }
       draw(align:'center', image:small)
       fit(width:50,height:50) {
         save(file:'thumbnail-50p.png', format:'png')
       }
       fit(width:20,height:20) {
         save(file:'thumbnail-20p.png', format:'png')
         save(file:'thumbnail-20p.jpg', format:'jpg', bgcolor: '00ff00')
       }
    }

Expressions:

  render(width, height)            - render image
  draw(align,offsetX, offsetY,image) - draw image
  image(file|url|stream)           - load image

  save(file|stream,format,[bgcolor],[image]) - save image
  * format - png, jpg
  * bgcolor (optional, default is white) - Save jpg file use the background color to paint under the non-opaque portions of the image.

  scale(width,height)              - height is optional(use width) e.g: scale(50%) == scale(50%,50%)
  fit(width,height)                - relative scale the image until if fits (default as scale)
                                     bounds of the given box
  rotate(degrees,x,y)              - the rotation position x and y are optional (default is 50%)
  fill(color)                      - fill with color
  margin(left,top,right,bottom)    - add margins to image (resize image canvas)

Values:

  • values ending with '%' means size relative to image size.
  • values ending with 'px' means values in absolute pixels.
  • values without postfix use default notation.