Use both :at and :position/:vposition for images #285

systemed opened this Issue Oct 8, 2011 · 4 comments


None yet

4 participants


At present, if a placed image is :at[x,y], none of the other image position options are read.

It would be nice to be able to use something like

image "file.png" :at=>[300,100], :position=>center, :vposition=>center

whereby the centre of the image, rather than the top left, would be positioned at 300,100.

Prawn has already read the image dimensions when it comes to determining the placement, so it can do this more efficiently than the calling program.

(Incidentally, thanks for the quick and excellent response to #281!)


Adding the following code to lib/prawn/images.rb at line 122 works:

    case options[:position]
    when :center
    when :right
    case options[:vposition]
    when :center
    when :bottom

(apologies - haven't got my head around git enough to send a pull request yet but will try for next time :) )

prawnpdf member

This is a neat idea, but I feel like the right solution is for us to come up with a unified API for positioning box-like content, rather than adding new special cases to each component.

Sorry we never responded to you about this, the project died down for a while. The good news is that we're now active again, so your contributions would be welcome!

@practicingruby practicingruby removed the stale label Mar 17, 2014

Adding myself to the issue


I created a fork with your code:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment