Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdf-reader-extract-images

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf-reader-extract-images

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Pdf::Reader::Extract::Images

ExtractImages

Based upon the Example from Pdf::Reader, battle hardened in our applicant tracking system with tens of thousands of PDFs.

Installation

Add this line to your application's Gemfile:

gem 'pdf-reader-extract-images'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install pdf-reader-extract-images

Usage

require 'pdf-reader-extract-images'

reader = PDF::Reader.new(pdf)
images = Pdf::Reader::ExtractImages.extract_all(reader)

# pass an image limit to ignore gigantic image-only pdfs
images = Pdf::Reader::ExtractImages.extract_all(reader, limit: 50)

# [
#  {
#    :filename => "1-1-Im1.jpg",
#    :width => 1772,
#    :height => 591
#    :blob => "....",
#  }
# ]

# OR you can just scan a single Pdf::Reader Page

reader.pages.each do |page|
  images = Pdf::Reader::ExtractImages.extract_from_pdf_page(page)
end

Limitations

There are some PDFs which have tons of images. Make sure to limit the timeout of an extraction somehow.

Also some PDFs product hundreds of images. Make sure to limit further processing down the line

Unfortunately, there is no public test suite. We have a private test suite that tests live pdfs which we cannot share. If you'd like to contribute problematic PDFs, feel free to open PR!

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 26 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc