Skip to content

Instantly share code, notes, and snippets.

@devishot
devishot / mini_magick#get_dominant_color.rb
Last active August 29, 2015 13:57
example of how to convert image to "-format %c histogram:info:" (http://www.imagemagick.org/Usage/files/#histogram) by gem "mini_magick". It used below to get dominant color of image by this solution for ImageMagick http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=12033
require "mini_magick"
module MiniMagick
class Image
def get_dominant_color
color = run_command("convert", path, "-format", "%c\n", "-colors", 1, "-depth", 8, "histogram:info:").split(' ');
# color = " 1764000: (208,195,161) #D0C3A1 srgb(208,195,161)\n\n"
{
hex: color[2],
rgb: color[1][1..-2].split(',')
@devishot
devishot / Google Docs - Spreadsheet Parser
Created January 5, 2014 07:12
Parse Google Form answers in SpreadSheets to separated Documents
var numberInPage1 = 7; //Number of questions in Page 1
var numberInPage2 = 6;
var numberInPage3 = 7;
var parsedColor = '#ff0000'
// Define a custom Paragraph style.
var parStyle = {};
parStyle[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT]
= DocumentApp.HorizontalAlignment.CENTER;