<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Schadenfreude &#187; rmagick</title>
	<atom:link href="http://www.ralree.com/tag/rmagick/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Automagic blending of wallpapers using RMagick</title>
		<link>http://www.ralree.com/2007/07/24/automagic-blending-of-wallpapers-using-rmagick/</link>
		<comments>http://www.ralree.com/2007/07/24/automagic-blending-of-wallpapers-using-rmagick/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 00:00:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rmagick]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[wallpaper]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/automagic-blending-of-wallpapers-using-rmagick</guid>
		<description><![CDATA[I wanted a program that let me blend random wallpapers from a directory together and set them every minute with increasing opacity on one image, and then to select a new random image and repeat the process. I did this using RMagick and some Ruby. Make the following tree: ~/.wallmold/ current.yml Fill current.yml with this: --- file2: someimage wallpaperdir: wallpaper directory dissolution: 0.1 file1: anotherimage Replacing the image names and directory with the proper stuffs, full path on directory and [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted a program that let me blend random wallpapers from a directory together and set them every minute with increasing opacity on one image, and then to select a new random image and repeat the process.  I did this using RMagick and some Ruby.</p>
<p>Make the following tree:</p>
<pre><code>
~/.wallmold/
  current.yml
</code></pre>
<p>Fill <code>current.yml</code> with this:</p>
<pre><code>
---
file2: someimage
wallpaperdir: wallpaper directory
dissolution: 0.1
file1: anotherimage
</code></pre>
<p>Replacing the image names and directory with the proper stuffs, full path on directory and relative on image names.  Here&#8217;s mine:</p>
<pre><code>
---
file2: w09.jpg
wallpaperdir: /home/hank/MyDocs/Wallpapers
dissolution: 0.8
file1: Looking_Forward.jpg
</code></pre>
<p>Then, get this, make it executable, and put it somewhere:</p>
<pre><code>
#!/usr/bin/env ruby
# Wallmold - a wallpaper melding script
require 'RMagick'
require 'yaml'

class Array
  def randomize
   arr=self.dup
   arr.collect { arr.slice!(rand(arr.length)) }
  end

  def randomize!
   arr=self.dup
   result = arr.collect { arr.slice!(rand(arr.length)) }
   self.replace result
  end
end

# Load State
configpath = "#{ENV['HOME']}/.wallmold/current.yml"
configfile = File.open(configpath, 'r')
config = YAML.load(configfile)
out = "#{ENV['HOME']}/.wallmold/dissolve.jpg"

# Open the Wallpaper directory
dir = Dir.open(config['wallpaperdir'])
newconfig = config

if config['dissolution'] == 0.9
  # Get new images
  files = dir.to_a.randomize

  newconfig['file1'] = config['file2']
  newconfig['file2'] = files.pop
  newconfig['dissolution'] = 0.1
else
  newconfig['file1'] = config['file1']
  newconfig['file2'] = config['file2']
  newconfig['dissolution'] = config['dissolution'] + 0.1
end

bgnd = Magick::Image.read(dir.path+"/"+newconfig['file1']).first
overlay = Magick::Image.read(dir.path+"/"+newconfig['file2']).first

# Make the first image is the same size as the second
bgnd.crop_resized!(overlay.columns, overlay.rows)

composited = bgnd.dissolve(overlay, newconfig['dissolution'])
composited.write(out)

`fbsetbg #{out}`

# Write new config
configfile.close
configfile = File.open(configpath, 'w')
configfile.puts newconfig.to_yaml
</code></pre>
<p>Now, just edit your crontab:</p>
<pre><code>
* * * * * DISPLAY=:0 ruby -r rubygems /home/hank/bin/wallmold.rb &gt; /dev/null 2&gt;&#038;1
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/07/24/automagic-blending-of-wallpapers-using-rmagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

