Created
January 30, 2019 23:54
-
-
Save ruinunes/59f351ebcf2ab0e33bdb3cbd048ae1ca to your computer and use it in GitHub Desktop.
Crop an image in PrawnPdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bounding_box([bounds.width * 0.5, cursor], width: 200, height: 113) do | |
image_width = 200 | |
image_height = 113 | |
crop_size = 20 | |
save_graphics_state do | |
soft_mask do | |
fill_color 0, 0, 0, 0 | |
fill_rectangle [crop_size, image_height - crop_size], image_width - crop_size * 2, image_height - crop_size * 2 | |
end | |
image "#{IMAGES_PATH}/cat.jpg", at: [bounds.left, bounds.top], width: image_width, height: image_height | |
end | |
stroke_bounds | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment