-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a425aac
commit 6ac2359
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
.rbx | ||
log | ||
tmp | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |