-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows JPEG support #815
Windows JPEG support #815
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "canvas", | ||
"description": "Canvas graphics API backed by Cairo", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"author": "TJ Holowaychuk <[email protected]>", | ||
"contributors": [ | ||
"Nathan Rajlich <[email protected]>", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,10 @@ var Canvas = require('../') | |
|
||
var png_checkers = __dirname + '/fixtures/checkers.png'; | ||
var png_clock = __dirname + '/fixtures/clock.png'; | ||
var jpg_face = __dirname + '/public/face.jpeg'; | ||
|
||
describe('Image', function () { | ||
this.timeout(5000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite a long time, is it really needed? |
||
it('should require new', function () { | ||
assert.throws(function () { Image(); }, TypeError); | ||
}); | ||
|
@@ -19,6 +21,30 @@ describe('Image', function () { | |
assert.ok(Image instanceof Function); | ||
}); | ||
|
||
it('Image set src to JPEG', function () { | ||
var img = new Image | ||
, onloadCalled = 0; | ||
|
||
assert.strictEqual(null, img.onload); | ||
assert.strictEqual(false, img.complete); | ||
|
||
img.onload = function () { | ||
onloadCalled += 1; | ||
assert.strictEqual(img.src, jpg_face); | ||
assert.strictEqual(485, img.width); | ||
assert.strictEqual(401, img.height); | ||
assert.strictEqual(true, img.complete); | ||
}; | ||
|
||
img.onerror = function (e) { | ||
console.error("ERROR", e); // temporary... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LinusU Missed your post ;-) I'll prep a fresh PR based on latest master when I find some time. Probably somewhere later this week. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you 💌 |
||
}; | ||
|
||
img.src = jpg_face; | ||
assert.strictEqual(1, onloadCalled); | ||
assert.strictEqual(img.src, jpg_face); | ||
}); | ||
|
||
it('Image#onload', function () { | ||
var img = new Image | ||
, onloadCalled = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var fs = require('fs') | ||
var paths = ['C:/libjpeg-turbo'] | ||
|
||
if (process.arch === 'x64') { | ||
paths.unshift('C:/libjpeg-turbo64') | ||
} | ||
|
||
paths.forEach(function(path){ | ||
if (exists(path)) { | ||
process.stdout.write(path) | ||
process.exit() | ||
} | ||
}) | ||
|
||
function exists(path) { | ||
try { | ||
return fs.lstatSync(path).isDirectory() | ||
} catch(e) { | ||
return false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't bump the version number, I'll do that as part of the release process