Commit 51515306 authored by Thomas Marrinan's avatar Thomas Marrinan

switch from graphicsmagick to imagemagick - solves memory allocation errors...

switch from graphicsmagick to imagemagick - solves memory allocation errors for larger/multi-layered files


Former-commit-id: 5771c09e54d709a0e71135ca22ef1a8911556bf5
parent af1dc370
......@@ -4,6 +4,7 @@
"index_port": 9292,
"clock": 12,
"background": {
"color": "#AAAAAA",
"image": "images/background/minneapolis_skyline_tm.jpg",
"style": "fit"
},
......
......@@ -21,6 +21,8 @@ var ytdl = require('ytdl');
var pdfinfo = require('node-pdfinfo').pdfinfo; // custom node module
var imageMagick = gm.subClass({imageMagick: true});
mime.default_type = "application/custom";
......@@ -235,10 +237,10 @@ appLoader.prototype.loadImageFromFile = function(file, mime_type, url, external_
});
}
else{
gm(file).noProfile().flatten().setFormat("PNG").toBuffer(function (err, buffer) {
imageMagick(file+"[0]").noProfile().flatten().setFormat("PNG").toBuffer(function (err, buffer) {
if(err) throw err;
gm(buffer).size(function (err, size) {
imageMagick(buffer).size(function (err, size) {
if(err) throw err;
_this.loadImageFromDataBuffer(buffer, size.width, size.height, "image/png", url, external_url, name, function(appInstance) {
......
......@@ -359,13 +359,14 @@
var app = new window[data.application];
app.init(data.id, data.width, data.height, data.url, date);
Object.observe(app.state, function(changes) {
var updatedState = JSON.parse(JSON.stringify(app.state));
if(app.state !== undefined){
Object.observe(app.state, function(changes) {
var updatedState = JSON.parse(JSON.stringify(app.state));
wsio.emit('updateAppState', {id: data.id, state: updatedState});
});
wsio.emit('updateAppState', {id: data.id, state: updatedState});
});
}
//app.init(data.id, data.width, data.height, data.url, date);
app.load(data.data, date);
app.draw(date);
......@@ -382,13 +383,14 @@
var app = new window[data.application];
app.init(data.id, data.width, data.height, data.url, date);
Object.observe(app.state, function(changes) {
var updatedState = JSON.parse(JSON.stringify(app.state));
if(app.state !== undefined){
Object.observe(app.state, function(changes) {
var updatedState = JSON.parse(JSON.stringify(app.state));
wsio.emit('updateAppState', {id: data.id, state: updatedState});
});
wsio.emit('updateAppState', {id: data.id, state: updatedState});
});
}
//app.init(data.id, data.width, data.height, data.url, date);
app.load(data.data, date);
app.draw(date);
......
......@@ -10,6 +10,8 @@
var image_viewer = SAGE2_App.extend( {
construct: function() {
arguments.callee.superClass.construct.call(this);
this.src = null;
},
......
......@@ -10,6 +10,8 @@
var media_stream = SAGE2_App.extend( {
construct: function() {
arguments.callee.superClass.construct.call(this);
this.src = null;
},
......
......@@ -10,6 +10,8 @@
var movie_player = SAGE2_App.extend( {
construct: function() {
arguments.callee.superClass.construct.call(this);
this.source = null;
this.playTimeout = null;
this.playDelay = 0.75;
......
......@@ -49,6 +49,9 @@ var loader = require('node-itemloader'); // handles sage item creation
var interaction = require('node-interaction'); // handles sage interaction (move, resize, etc.)
var sagepointer = require('node-sagepointer'); // handles sage pointers (creation, location, etc.)
var imageMagick = gm.subClass({imageMagick: true});
// Command line arguments
program
.version('0.1.0')
......@@ -865,7 +868,7 @@ function setupDisplayBackground() {
tmpImg = path.join(public_https, "images", "background", "tmp_background.png");
var out_res = config.totalWidth.toString() + "x" + config.totalHeight.toString();
gm(bg_file).noProfile().command("convert").in("-gravity", "center").in("-background", "rgba(255,255,255,255)").in("-extent", out_res).write(tmpImg, function(err) {
imageMagick(bg_file).noProfile().command("convert").in("-gravity", "center").in("-background", "rgba(0,0,0,0)").in("-extent", out_res).write(tmpImg, function(err) {
if(err) throw err;
sliceBackgroundImage(tmpImg, bg_file);
......@@ -876,7 +879,7 @@ function setupDisplayBackground() {
imgExt = path.extname(bg_file);
tmpImg = path.join(public_https, "images", "background", "tmp_background" + imgExt);
gm(bg_file).resize(config.totalWidth, config.totalHeight, "!").write(tmpImg, function(err) {
imageMagick(bg_file).resize(config.totalWidth, config.totalHeight, "!").write(tmpImg, function(err) {
if(err) throw err;
sliceBackgroundImage(tmpImg, bg_file);
......@@ -891,10 +894,10 @@ function setupDisplayBackground() {
var tile = cols.toString() + "x" + rows.toString();
var in_res = bg_info.width.toString() + "x" + bg_info.height.toString();
var gmTile = gm().command("montage").in("-geometry", in_res).in("-tile", tile);
for(var i=0; i<rows*cols; i++) gmTile = gmTile.in(bg_file);
var imTile = imageMagick().command("montage").in("-geometry", in_res).in("-tile", tile);
for(var i=0; i<rows*cols; i++) imTile = imTile.in(bg_file);
gmTile.write(tmpImg, function(err) {
imTile.write(tmpImg, function(err) {
if(err) throw err;
sliceBackgroundImage(tmpImg, bg_file);
......@@ -913,8 +916,8 @@ function sliceBackgroundImage(fileName, outputBaseName) {
var output_base = path.basename(outputBaseName, input_ext);
var output = path.join(output_dir, output_base + "_"+i.toString() + output_ext);
console.log(output);
gm(fileName).crop(config.resolution.width, config.resolution.height, x, y).write(output, function(err) {
if(err) throw err;
imageMagick(fileName).crop(config.resolution.width, config.resolution.height, x, y).write(output, function(err) {
if(err) console.log("error slicing image", err); //throw err;
});
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment