Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  165] [ 6]  / answers: 1 / hits: 23365  / 13 Years ago, fri, october 28, 2011, 12:00:00

The title says it. I know Imagemagick can do that, but let us assume I am on a cloud server that will only allow me JavaScript (coughnodestercough). Which is not a bad thing, actually.



Recently I heard that there are h.264 renderers in javascript, so png is not that far fetched?


More From » node.js

 Answers
14

A PNG renderer is not far fetched, in fact it already exists: http://devongovett.github.com/png.js/



The problem here is that you would need a fake canvas implementation that doesn't draw anything, just builds a pixel array, that could then be saved to a PNG. There is nothing like that 'cause it's kind of useless except for this case...



i.e.: svg -> bitmap renderer (fake canvas) -> rgb array -> png file



Some hosting providers will allow you to declare system-level dependencies, or have some defaults available. gm would work fine for this purpose:



gm = require('gm')

gm('image.svg').write('image.png', function(err){
if (!err) console.log('image converted.')
})


You can apparently install imagemagick/graphicsmagick on a http://no.de machine, and dotcloud also has IM available. Ask the guys at nodester, it's very likely that they have a graphics library available.


[#89394] Thursday, October 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;