Low commit activity in last 3 years
No release in over a year
simple-images-downloader allows to download images from a file containing list of urls to those images.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.14
~> 0.13.1
~> 12.0
~> 3.0
~> 0.91.0
~> 1.43.2
~> 0.17.1
~> 6.0.0
~> 3.9.1
 Project Readme

Simple Images Downloader

IlkhamGaysin Maintainability Test Coverage Gem Version

This gem allows you download images from either source file with list of urls or plain url. The urls must be non redirectable. For now the feature is unsupported. The gem uses OpenURI class under the hood and is able to download as small files less than 10KB as large files, for example 100MB.

Defaults formats to validate against: image/avif, image/gif, image/apng, image/jpg, image/jpeg, image/png, image/svg+xml, image/webp

Dependencies

  • Ruby >= 2.7.1

Installation

Add this line to your application's Gemfile:

gem 'simple-images-downloader'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install simple-images-downloader

Usage

The gem is provided with executable.

You can either run plain command with file containing list of url:

simple-images-downloader <path_to_file>

Or you can load gem and use public API:

  • SimpleImagesDownloader.from_file - allows download images from file containing urls
[1] pry(main)> require 'simple_images_downloader'

[2] pry(main)> path = File.expand_path("./urls.txt")

[3] pry(main)> SimpleImagesDownloader.from_file(path)
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg
Downloading is finished
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/less_than_10kb.png
Downloading is finished
  • SimpleImagesDownloader.from_url - allows download image from url
[1] pry(main)> require 'simple_images_downloader'

[2] pry(main)> url = 'https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg'

[3] pry(main)> SimpleImagesDownloader.from_url(url)
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg
Downloading is finished

Configuration

By default the images stored in a directory the script is run. You can also configure the place where the images would be stored to:

[1] pry(main)> require 'simple_images_downloader'

[2] pry(main)> SimpleImagesDownloader::Configuration.configure do  |config|
[2] pry(main)*   config.destination = "./tmp/"
[2] pry(main)* end

By default the gem downloads only images with mime types: image/avif, image/gif, image/apng, image/jpg, image/jpeg, image/png, image/svg+xml, image/webp. You can also configure the mime types to download images with:

[1] pry(main)> require 'simple_images_downloader'

[2] pry(main)> SimpleImagesDownloader::Configuration.configure do  |config|
[2] pry(main)*   # You must use RFC 1341 - MIME (Multipurpose Internet Mail Extensions) format
[2] pry(main)*   config.valid_mime_types = %w(image/png image/jpg image/jpeg)
[2] pry(main)* end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/IlkhamGaysin/simple-images-downloader. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

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

Code of Conduct

Everyone interacting in the SimpleImagesDownloader project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.