Skip to content

Instantly share code, notes, and snippets.

@ciscou
Created November 2, 2011 20:26
Show Gist options
  • Select an option

  • Save ciscou/1334795 to your computer and use it in GitHub Desktop.

Select an option

Save ciscou/1334795 to your computer and use it in GitHub Desktop.
Extracts a section of a page of a PDF into a JPG image
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pdf_file = "QR Creator.pdf"
pdf_page = 1
jpg_file = "QR Creator.jpg"
qrcode_offset = [1330, 590]
qrcode_size = [1024, 1024]
output = %x(convert -density 300 -quality 95 -crop #{qrcode_size.join 'x'}+#{qrcode_offset.join '+'} -resize 50% "#{pdf_file}[#{pdf_page - 1}]" "#{jpg_file}")
if $?.success?
puts "OK"
else
puts output
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment