Project

random_jpg

0.0
No commit activity in last 3 years
No release in over 3 years
RandomJpg is a tool for easy downloading random images for use in scripts, application test data etc. It runs silently in the background feeding random images to a named pipe at a specified location, by default /tmp/random.jpg.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

random_jpg

random_jpg is a tool for easy downloading random images from the web for use in scripts, application test data etc. It runs silently in the background feeding random images to a named pipe at a specified location, by default /tmp/random.jpg. By using a constant location, this simplifies a number of tasks related to downloading images.

Installation

Install using:

$ gem install random_jpg

Requirements

Build Status

random_jpg is verified to run under:

  • Ruby 1.9.2
  • Ruby 1.9.3

I'm using OS X and believe any Unix-based system will work. I don't expect it to work under Windows, since I'm using mkfifo internally.

Usage

Typical scenario: run once, use everywhere.

$ random_jpg --daemon

This creates the pipe at the default location /tmp/random.jpg. Now you can download 3 random images to ~/Desktop using:

$ cp /tmp/random.jpg ~/Desktop/a.jpg
$ cp /tmp/random.jpg ~/Desktop/b.jpg
$ cp /tmp/random.jpg ~/Desktop/c.jpg

Or you can use it for seed data in loops:

10.times do
  post = Post.new
  post.title = Faker::Lorem.words
  post.image = File.open('/tmp/random.jpg')
  post.save!
end

On each run, a new image will be downloaded and served.

For full usage info, run:

$ random_jpg -h

Image sources

Image source can be chosen using -l LOADER. Available options:

  • flickr (default)
  • imgur (not recommended for production use ;)

Info

random_jpg © 2012 Łukasz Adamczak, read LICENSE file for details.