<commit_before># Fotofetch

This gem allows the simple searching for and saving of images to your app. Various photo-searching API's will provide more consistent results, but this is a quick way to find images matching a query. Results can be restricted by photo dimensions and batch-saved to your directory. This gem was extracted from an app to fetch movie posters for a movie suggestion [site](http://www.nonshittymovies.com), which dynamically creates the content on each page load.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'fotofetch'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install fotofetch

## Basic Usage  

- Initiate an instance of Fotofetch:  
```ruby
@fetcher = Fotofetch::Fetch.new
```
- To fetch an image of a Tesla Model S:
```ruby
link = @fetcher.fetch_links("tesla model s")
```  
- To save the link to your file directory (links must be in an array, so call .values):
```ruby
@ff.save_images(link.values, './')
```  
The 'save_images' method takes two arguments: link(s) and the file path for where to save. File names are gerated from the previous query, so if you search for 2 images of 'red_ball', they will be saved as 'red_ball_0.jpg' and 'red_ball_1.jpg'.

## More Specific Queries
Arguments for the 'fetch_links' method are: search value (required), number of links returned (optional), and two dimension restrictions arguments (optional: width, height).  

If a dimension argument is positive, it will look for pictures larger than that,<commit_msg>silly variable rename in README<commit_after># Fotofetch

This gem allows the simple searching for and saving of images to your app. Various photo-searching API's will provide more consistent results, but this is a quick way to find images matching a query. Results can be restricted by photo dimensions and batch-saved to your directory. This gem was extracted from an app to fetch movie posters for a movie suggestion [site](http://www.nonshittymovies.com), which dynamically creates the content on each page load.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'fotofetch'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install fotofetch

## Basic Usage  

- Initiate an instance of Fotofetch:  
```ruby
@fetcher = Fotofetch::Fetch.new
```
- To fetch an image of a Tesla Model S:
```ruby
link = @fetcher.fetch_links("tesla model s")
```  
- To save the link to your file directory (links must be in an array, so call .values):
```ruby
@fetcher.save_images(link.values, './')
```  
The 'save_images' method takes two arguments: link(s) and the file path for where to save. File names are gerated from the previous query, so if you search for 2 images of 'red_ball', they will be saved as 'red_ball_0.jpg' and 'red_ball_1.jpg'.

## More Specific Queries
Arguments for the 'fetch_links' method are: search value (required), number of links returned (optional), and two dimension restrictions arguments (optional: width, height).  

If a dimension argument is positive, it will look for pictures larger than that,
{'fraction_non_alphanumeric': 0.08020532563362208, 'fraction_numerical': 0.0019249278152069298, 'mean_word_length': 4.385146804835924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6730695', 'n_tokens_mistral': 889, 'n_tokens_neox': 845, 'n_words': 439}