Method: PDFium::Image#as_science
- Defined in:
- ext/pdfium_ext/image.cc
#as_science ⇒ ImageScience instance
Converts to an ImageScience bitmap and returns it. The ImageScience (github.com/seattlerb/image_science) library must be installed and required before calling this method or a NameError: uninitialized constant ImageScience exception will be raised.
Example
pdf = PDFium::Document.new( "test.pdf" )
page = pdf.pages.first
page.images.each do | image |
image.as_science.cropped_thumbnail 100 do |thumb|
thumb.save "image-#{image.index}-cropped.png"
end
end
207 208 209 210 211 212 213 214 215 |
# File 'ext/pdfium_ext/image.cc', line 207 VALUE image_as_science(VALUE self){ VALUE RBImageScience = rb_const_get(rb_cObject, rb_intern("ImageScience")); FIBITMAP *image = render_to_bitmap(self, FIF_BMP); VALUE instance = Data_Wrap_Struct(RBImageScience, NULL, NULL, image); rb_iv_set(instance, "@file_type", INT2FIX(FIF_BMP)); return instance; } |