From 748e71519e606d57977439bf301369f304d454f7 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:04:11 +0200 Subject: [PATCH 01/12] fixes --- js/load-image.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/load-image.js b/js/load-image.js index adb63a9..b22ba17 100644 --- a/js/load-image.js +++ b/js/load-image.js @@ -18,11 +18,16 @@ // Loads an image for a given File object. // Invokes the callback with an img or optional canvas // element (if supported by the browser) as parameter: - var loadImage = function (file, callback, options) { + window.loadImage = function (file, callback, options) { var img = document.createElement('img'), url, oUrl; - img.onerror = callback; + img.onerror = function () { + console.log("img load error"); + if (callback) { + callback(); + } + }; img.onload = function () { if (oUrl && !(options && options.noRevoke)) { loadImage.revokeObjectURL(oUrl); @@ -63,7 +68,7 @@ }, // The check for URL.revokeObjectURL fixes an issue with Opera 12, // which provides URL.createObjectURL but doesn't properly implement it: - urlAPI = (window.createObjectURL && window) || + window.urlAPI = (window.createObjectURL && window) || (window.URL && URL.revokeObjectURL && URL) || (window.webkitURL && webkitURL); From e4a69ccc2a6d920eba5e6de66a55bc4225cdad66 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:13:17 +0200 Subject: [PATCH 02/12] fixes --- bower.json | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 07f9859..66173e4 100644 --- a/bower.json +++ b/bower.json @@ -20,28 +20,7 @@ "thumbnail", "resizing" ], - "homepage": "https://github.com/blueimp/JavaScript-Load-Image", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - }, - "maintainers": [ - { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/blueimp/JavaScript-Load-Image.git" - }, - "bugs": "https://github.com/blueimp/JavaScript-Load-Image/issues", - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } - ], + "homepage": "https://github.com/brownbag-it/JavaScript-Load-Image", "main": [ "js/load-image.js", "js/load-image-ios.js", From 58e473dbbfdc1642e1c28592bbc649a52b973eae Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:20:10 +0200 Subject: [PATCH 03/12] fixes --- bower.json | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 66173e4..07f9859 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,28 @@ "thumbnail", "resizing" ], - "homepage": "https://github.com/brownbag-it/JavaScript-Load-Image", + "homepage": "https://github.com/blueimp/JavaScript-Load-Image", + "author": { + "name": "Sebastian Tschan", + "url": "https://blueimp.net" + }, + "maintainers": [ + { + "name": "Sebastian Tschan", + "url": "https://blueimp.net" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/blueimp/JavaScript-Load-Image.git" + }, + "bugs": "https://github.com/blueimp/JavaScript-Load-Image/issues", + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], "main": [ "js/load-image.js", "js/load-image-ios.js", From e2f46a6c078d99c04a9f3ee6131c9bf840617a97 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:37:03 +0200 Subject: [PATCH 04/12] fixes --- package.json | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index bde2fb2..88bfa47 100644 --- a/package.json +++ b/package.json @@ -20,22 +20,12 @@ "thumbnail", "resizing" ], - "homepage": "https://github.com/blueimp/JavaScript-Load-Image", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - }, - "maintainers": [ - { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - } - ], + "homepage": "https://github.com/brownbag-it/JavaScript-Load-Image", "repository": { "type": "git", - "url": "git://github.com/blueimp/JavaScript-Load-Image.git" + "url": "git://github.com/brownbag-it/JavaScript-Load-Image.git" }, - "bugs": "https://github.com/blueimp/JavaScript-Load-Image/issues", + "bugs": "https://github.com/brownbag-it/JavaScript-Load-Image/issues", "licenses": [ { "type": "MIT", From b86b56e4a08a73c4aa1aa2c5ac57a777e653d524 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:40:01 +0200 Subject: [PATCH 05/12] fixes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88bfa47..f630d7f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "blueimp-load-image", + "name": "blueimp-load-image-brownbag-it", "version": "1.13.0", "title": "JavaScript Load Image", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", From 8c954351f81e9027150814c74854c689dc2748ba Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 17:41:42 +0200 Subject: [PATCH 06/12] fixes --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f630d7f..a493674 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "blueimp-load-image-brownbag-it", - "version": "1.13.0", "title": "JavaScript Load Image", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", "keywords": [ From 091f61b9e12cbb1b79358ad28fddeaa31b8a5e77 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 18:13:13 +0200 Subject: [PATCH 07/12] fixes --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a493674..bf714f6 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "blueimp-load-image-brownbag-it", + "version": "1.14.0", "title": "JavaScript Load Image", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", "keywords": [ From 7de097d5dbaf2b87baa2a94fc2e81d73d68aab4b Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 18:15:03 +0200 Subject: [PATCH 08/12] fixes --- package.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index bf714f6..a413b4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "blueimp-load-image-brownbag-it", - "version": "1.14.0", + "name": "blueimp-load-image", + "version": "1.13.0", "title": "JavaScript Load Image", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", "keywords": [ @@ -21,10 +21,6 @@ "resizing" ], "homepage": "https://github.com/brownbag-it/JavaScript-Load-Image", - "repository": { - "type": "git", - "url": "git://github.com/brownbag-it/JavaScript-Load-Image.git" - }, "bugs": "https://github.com/brownbag-it/JavaScript-Load-Image/issues", "licenses": [ { From 381f58f00f76f7f9dd6131841cd898b92671b3a8 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 18:47:15 +0200 Subject: [PATCH 09/12] fixes --- js/load-image.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/load-image.js b/js/load-image.js index b22ba17..d39c73b 100644 --- a/js/load-image.js +++ b/js/load-image.js @@ -19,7 +19,7 @@ // Invokes the callback with an img or optional canvas // element (if supported by the browser) as parameter: window.loadImage = function (file, callback, options) { - var img = document.createElement('img'), + var img = typeof document != 'undefined' ? document.createElement('img') : new window.canvas.Image, url, oUrl; img.onerror = function () { @@ -156,7 +156,7 @@ // object is passed as image, else the scaled image: loadImage.scale = function (img, options) { options = options || {}; - var canvas = document.createElement('canvas'), + var canvas = typeof document != 'undefined' ? document.createElement('canvas') : new window.canvas(1,1), useCanvas = img.getContext || (loadImage.hasCanvasOption(options) && canvas.getContext), width = img.naturalWidth || img.width, diff --git a/package.json b/package.json index a413b4a..6a5bcd6 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "blueimp-load-image", + "name": "blueimp-load-image-nodejs", "version": "1.13.0", "title": "JavaScript Load Image", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", From d6714d4dbf95bfd7e2103a6e48ae2342f8f071e2 Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 18:50:28 +0200 Subject: [PATCH 10/12] fixes --- js/load-image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/load-image.js b/js/load-image.js index d39c73b..d0d3bbf 100644 --- a/js/load-image.js +++ b/js/load-image.js @@ -1,5 +1,5 @@ /* - * JavaScript Load Image 1.10.0 + * JavaScript Load Image 1.10.0 with nodejs support for canvas and image * https://github.com/blueimp/JavaScript-Load-Image * * Copyright 2011, Sebastian Tschan From 1aae17c6e25b6a176d4122fd1f1f35c7cb3344bc Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 14 Jul 2015 18:51:09 +0200 Subject: [PATCH 11/12] fixes --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 07f9859..079f2ea 100644 --- a/bower.json +++ b/bower.json @@ -1,8 +1,8 @@ { - "name": "blueimp-load-image", + "name": "blueimp-load-image-nodejs", "version": "1.13.0", "title": "JavaScript Load Image", - "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", + "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing. This version is with nodejs support for canvas and image.", "keywords": [ "javascript", "load", From fbf286139458cb9566e0643f9ebe30f4bb22d6eb Mon Sep 17 00:00:00 2001 From: Pawel Glowacki Date: Tue, 28 Jul 2015 11:44:26 +0200 Subject: [PATCH 12/12] fixes --- js/load-image-exif-map.js | 2 +- js/load-image-exif.js | 2 +- js/load-image-ios.js | 6 +++--- js/load-image-meta.js | 6 +++--- js/load-image-orientation.js | 2 +- js/load-image.js | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/js/load-image-exif-map.js b/js/load-image-exif-map.js index 8811a52..c3cafa4 100644 --- a/js/load-image-exif-map.js +++ b/js/load-image-exif-map.js @@ -21,7 +21,7 @@ define(['load-image', 'load-image-exif'], factory); } else { // Browser globals: - factory(window.loadImage); + factory(globalWindow.loadImage); } }(function (loadImage) { 'use strict'; diff --git a/js/load-image-exif.js b/js/load-image-exif.js index 347369b..4969314 100644 --- a/js/load-image-exif.js +++ b/js/load-image-exif.js @@ -19,7 +19,7 @@ define(['load-image', 'load-image-meta'], factory); } else { // Browser globals: - factory(window.loadImage); + factory(globalWindow.loadImage); } }(function (loadImage) { 'use strict'; diff --git a/js/load-image-ios.js b/js/load-image-ios.js index 6f8e4fd..1a3921a 100644 --- a/js/load-image-ios.js +++ b/js/load-image-ios.js @@ -22,14 +22,14 @@ define(['load-image'], factory); } else { // Browser globals: - factory(window.loadImage); + factory(globalWindow.loadImage); } }(function (loadImage) { 'use strict'; // Only apply fixes on the iOS platform: - if (!window.navigator || !window.navigator.platform || - !(/iP(hone|od|ad)/).test(window.navigator.platform)) { + if (!globalWindow.navigator || !globalWindow.navigator.platform || + !(/iP(hone|od|ad)/).test(globalWindow.navigator.platform)) { return; } diff --git a/js/load-image-meta.js b/js/load-image-meta.js index d808508..c0d5748 100644 --- a/js/load-image-meta.js +++ b/js/load-image-meta.js @@ -23,12 +23,12 @@ define(['load-image'], factory); } else { // Browser globals: - factory(window.loadImage); + factory(globalWindow.loadImage); } }(function (loadImage) { 'use strict'; - var hasblobSlice = window.Blob && (Blob.prototype.slice || + var hasblobSlice = globalWindow.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice); loadImage.blobSlice = hasblobSlice && function () { @@ -54,7 +54,7 @@ // 256 KiB should contain all EXIF/ICC/IPTC segments: maxMetaDataSize = options.maxMetaDataSize || 262144, data = {}, - noMetaData = !(window.DataView && file && file.size >= 12 && + noMetaData = !(globalWindow.DataView && file && file.size >= 12 && file.type === 'image/jpeg' && loadImage.blobSlice); if (noMetaData || !loadImage.readFile( loadImage.blobSlice.call(file, 0, maxMetaDataSize), diff --git a/js/load-image-orientation.js b/js/load-image-orientation.js index f0a32fa..ef6f232 100644 --- a/js/load-image-orientation.js +++ b/js/load-image-orientation.js @@ -18,7 +18,7 @@ define(['load-image'], factory); } else { // Browser globals: - factory(window.loadImage); + factory(globalWindow.loadImage); } }(function (loadImage) { 'use strict'; diff --git a/js/load-image.js b/js/load-image.js index d0d3bbf..9ca3680 100644 --- a/js/load-image.js +++ b/js/load-image.js @@ -18,8 +18,8 @@ // Loads an image for a given File object. // Invokes the callback with an img or optional canvas // element (if supported by the browser) as parameter: - window.loadImage = function (file, callback, options) { - var img = typeof document != 'undefined' ? document.createElement('img') : new window.canvas.Image, + globalWindow.loadImage = function (file, callback, options) { + var img = typeof document != 'undefined' ? document.createElement('img') : new globalWindow.canvas.Image, url, oUrl; img.onerror = function () { @@ -68,9 +68,9 @@ }, // The check for URL.revokeObjectURL fixes an issue with Opera 12, // which provides URL.createObjectURL but doesn't properly implement it: - window.urlAPI = (window.createObjectURL && window) || - (window.URL && URL.revokeObjectURL && URL) || - (window.webkitURL && webkitURL); + globalWindow.urlAPI = (globalWindow.createObjectURL && globalWindow) || + (globalWindow.URL && URL.revokeObjectURL && URL) || + (globalWindow.webkitURL && webkitURL); loadImage.isInstanceOf = function (type, obj) { // Cross-frame instanceof check @@ -156,7 +156,7 @@ // object is passed as image, else the scaled image: loadImage.scale = function (img, options) { options = options || {}; - var canvas = typeof document != 'undefined' ? document.createElement('canvas') : new window.canvas(1,1), + var canvas = typeof document != 'undefined' ? document.createElement('canvas') : new globalWindow.canvas(1,1), useCanvas = img.getContext || (loadImage.hasCanvasOption(options) && canvas.getContext), width = img.naturalWidth || img.width, @@ -284,7 +284,7 @@ // invokes the callback with the event object (load or error). // The result can be read via event.target.result: loadImage.readFile = function (file, callback, method) { - if (window.FileReader) { + if (globalWindow.FileReader) { var fileReader = new FileReader(); fileReader.onload = fileReader.onerror = callback; method = method || 'readAsDataURL';