1

I've been looking through Vips and Ruby-Vips documentation, and I am not seeing anyway to load and convert a PDF. Imagemagick has the convert command in their CLI tools. Is there an equivalent to convert in Vips? My goal is to convert a PDF to a jpeg in my Rails 3 app.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
Jahkobi Digital
  • 728
  • 11
  • 24

1 Answers1

0

You can open a PDF like any other image file.

a = Vips::Image.new_from_file "/some/file/called.pdf", access: :sequential
a.write_to_file("tiny.jpg")

Optional arguments let you set a rendering resolution, a background colour, and pick a page or set of pages.

The docs for pdfload explain all the options:

https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-pdfload

jcupitt
  • 10,213
  • 2
  • 23
  • 39