Skip to content

Instantly share code, notes, and snippets.

@ruinunes
Created January 30, 2019 23:54
Show Gist options
  • Save ruinunes/59f351ebcf2ab0e33bdb3cbd048ae1ca to your computer and use it in GitHub Desktop.
Save ruinunes/59f351ebcf2ab0e33bdb3cbd048ae1ca to your computer and use it in GitHub Desktop.
Crop an image in PrawnPdf
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