Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Jacob Seidelin
ce42af6675 Merge pull request #26 from falsefalse/legacy
Carry source images crossOrigin attribute along
2014-08-31 15:35:52 +02:00
Ilya Furman
dca23ce291 Carry source images crossOrigin attribute along
Before canvases transformed with pixastic would be tainted because
image URL was carried along but not crossorigin.
2014-08-29 19:07:20 +03:00
Jacob Seidelin
349808de4f Merge pull request #21 from binoculars/legacy
Image Dimensions Fix
2014-04-17 15:05:31 +02:00
Barrett Harber
f7ee54762d Image Dimensions Fix
If the image has a valid width and height, use it. Otherwise, the
off-screen rendering creates an image that is the maximum size of the
browser window. This can be seen on with large images that are greater
than the size of the browser window.
2013-11-27 18:03:09 -05:00

View file

@ -56,6 +56,7 @@ var Pixastic = (function() {
if (actions.length) { if (actions.length) {
if (el.tagName.toLowerCase() == "img") { if (el.tagName.toLowerCase() == "img") {
var dataImg = new Image(); var dataImg = new Image();
if (el.crossOrigin) dataImg.crossOrigin = el.crossOrigin;
dataImg.src = el.src; dataImg.src = el.src;
if (dataImg.complete) { if (dataImg.complete) {
for (var a=0;a<actions.length;a++) { for (var a=0;a<actions.length;a++) {
@ -217,7 +218,7 @@ var Pixastic = (function() {
var w = img.offsetWidth; var w = img.offsetWidth;
var h = img.offsetHeight; var h = img.offsetHeight;
if (imageIsCanvas) { if (imageIsCanvas || (img.width && img.height)) {
w = img.width; w = img.width;
h = img.height; h = img.height;
} }
@ -381,6 +382,7 @@ var Pixastic = (function() {
process : function(img, actionName, options, callback) { process : function(img, actionName, options, callback) {
if (img.tagName.toLowerCase() == "img") { if (img.tagName.toLowerCase() == "img") {
var dataImg = new Image(); var dataImg = new Image();
if (img.crossOrigin) dataImg.crossOrigin = img.crossOrigin;
dataImg.src = img.src; dataImg.src = img.src;
if (dataImg.complete) { if (dataImg.complete) {
var res = Pixastic.applyAction(img, dataImg, actionName, options); var res = Pixastic.applyAction(img, dataImg, actionName, options);