Skip to content

Commit

Permalink
raw examples
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptepper committed May 24, 2012
1 parent a425aac commit 6ac2359
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.rbx
log
tmp
node_modules
Expand Down
30 changes: 30 additions & 0 deletions raw/raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var gm = require("gm")
, fs = require("fs")

, output = fs.createWriteStream("/dev/null")
, image = "../image.jpg"
, limit = 2, count = 1000;

(function self() {
--count;
--limit;
gm(image)
.resize(100, 100)
.stream("jpg", function(err, stdout, stderr) {
if (err) {
throw err;
}
stdout.pipe(output);
stdout.on('end', function () {
++limit;
if (count) {
self();
}
});
});
if (limit && count) {
self();
}
}());
20 changes: 20 additions & 0 deletions raw/raw.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
count = 1000
limit = 2

1.upto(count / limit) do
threads = []

1.upto(limit) do
threads << Thread.new do
IO.popen("/usr/local/bin/gm convert -size 100x100 ../image.jpg -resize 100x100 JPG:-") do |result|
devnull = File.open("/dev/null", "w")

while part = result.read(1024)
devnull.puts(part)
end
end
end
end

threads.join
end

0 comments on commit 6ac2359

Please sign in to comment.