fccc - Flickr Collage Coding Challenge

Code Climate

Features

Basic

Ruby command line application that

  • [x] accepts a list of search keywords as arguments
  • [x] queries the Flickr API for the top-rated image for each keyword
  • [x] downloads the results
  • [x] crops them rectangularly
  • [x] assembles a collage grid from ten images and
  • [x] writes the result to a user-supplied filename
  • [x] adds suffix to filename if user-supplied one already exists.
  • [x] If given less than ten keywords, or if any keyword fails to result in a match, retrieves random words from a dictionary source and repeats as necessary until it has gathered ten images.

Additional features

  • [x] Wrapped in a Gem and installable from Github repo.
  • [x] You can provide keywords either as arguments or from a file.

Installation

Requirements

  • Ruby 2.2.x or 2.3.x
    • apt-get install ruby ruby-dev (Ubuntu)
  • ImageMagick
    • brew install imagemagick && brew install pkg-config (Mac OSX)
    • apt-get install imagemagick libmagickcore-dev libmagickwand-dev (Ubuntu)
  • Bundler
    • gem install bundler

Install fccc

There are three ways to install fccc:

  • Install from Github (Recommended)
  • Install locally
  • Just as a Ruby script

Install from Github

First, create Gemfile in your current directory. Gemfile should be like this.

# Gemfile
source 'https://rubygems.org'
gem 'fccc', :git => 'http://github.com/AkihikoITOH/fccc.git'

Then, run

$ bundle install

to install fccc.

Install locally

You can also build gem and install it locally.

$ git clone https://github.com/AkihikoITOH/fccc.git
$ cd fccc && gem build fccc.gemspec
$ gem install fccc-0.1.0.gem

Just as a ruby script

You can also use fccc by simply downloading file from Github.

$ git clone https://github.com/AkihikoITOH/fccc.git
$ cd fccc
$ ruby lib/fccc.rb

Usage

First, you need to put credentials.yml containing api_key and shared_secret of Flickr API in your current directory(in which you will run fccc command).

credentials.yml should be like this.

api_key: yourapikeyhere
shared_secret: yoursecretkeyhere
# As a command line application
$ fccc collage [keyword1, keyword2, ..., keyword10] --output [output_filename]
# If it doesn't work, you can try another way
$ bundle exec fccc collage [keyword1, keyword2, ..., keyword10] --output [output_filename]

# As a Ruby script
$ cd fccc/
$ ruby lib/fccc.rb collage keyword1, keyword2, ..., keyword10 --output filename

Example

# Basic
$ fccc collage dog, cat, lion, tiger, beetle, bee, salmon, mackerel, Kyoto, Hamburg --output mycollage

# If you have a list of keywords in a file, you can use it as input instead of giving them as arguments.
$ fccc collage --input keywords.txt --credential credentials.yml --output mycollage

keywords.txt should be like this.

dog
cat
lion
tiger
beetle
bee
salmon
mackerel
Kyoto
Hamburg

License

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