you can try to convey the width and height of the image that is actually displayed, if that helps
Shrimp :: Images
Public Data Methods image (file, options = {}) Click to switch source
Add the image to the file name on the current page. Currently, only JPG and PNG files are supported.
NOTE. Shrimp is very slow when rendering PNG with alpha channels. workaround for those who do not want to install RMagick:
github.com/amberbit/prawn-fast-png
Arguments:
path to file or object that responds to #
Options:
: at array [x, y] with the location of the upper left corner of the image.
: position One of (: left ,: center ,: right) or x-offset
: vposition One of (: top ,: center ,: center) or y-offset
: height image height [actual image height]
: width image width [actual image width]
: Scale proportionally scales image sizes
: Fit scales the image proportionally to the size inside [width, height]
Prawn::Document.generate("image2.pdf", :page_layout => :landscape) do pigs = "#{Prawn::BASEDIR}/data/images/pigs.jpg" image pigs, :at => [50,450], :width => 450 dice = "#{Prawn::BASEDIR}/data/images/dice.png" image dice, :at => [50, 450], :scale => 0.75 end
If only one of: width /: height is provided, the image will scale proportionally. When both are provided, the image will be stretched to fit without maintaining aspect ratio.
If: at is provided, the image will be placed on the current page, but the text position will not be changed.
If, instead of an explicit file name, an object with a read method is transferred as a file, you can insert images from I / O objects and things that act like them (including Tempfiles and open-uri objects).
require "open-uri" Prawn::Document.generate("remote_images.pdf") do image open("http://prawn.majesticseacreature.com/media/prawn_logo.png") end
This method returns an image information object that can be used to check the size of the image object, if necessary. (See Also: Shrimp :: Images :: PNG, Shrimp :: Images :: JPG)