@loaders.gl/images
Advanced tools
Comparing version 0.7.1 to 1.0.0-alpha.1
@@ -10,21 +10,2 @@ "use strict"; | ||
/* | ||
/* global Image, Blob, createImageBitmap * | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
export const ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; | ||
// Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
export const HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; | ||
// Loads a platform-specific image type that can be used as input data to WebGL textures | ||
export const PlatformImageLoader = { | ||
parse: parseToPlatformImage, | ||
load: loadToPlatformImage | ||
}; | ||
*/ | ||
var _default = { | ||
@@ -31,0 +12,0 @@ name: 'Images', |
@@ -7,14 +7,9 @@ "use strict"; | ||
exports.PlatformImageLoader = exports.HTMLImageLoader = exports.ImageBitmapLoader = void 0; | ||
/* global Image, Blob, createImageBitmap */ | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
var ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; // Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
}; | ||
exports.ImageBitmapLoader = ImageBitmapLoader; | ||
var HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; // Loads a platform-specific image type that can be used as input data to WebGL textures | ||
}; | ||
exports.HTMLImageLoader = HTMLImageLoader; | ||
@@ -24,6 +19,3 @@ var PlatformImageLoader = { | ||
load: loadToPlatformImage | ||
}; // TODO - export functions that work on "platform images", | ||
// e.g. extracts image data as typed array from any of the platform image formats. | ||
// Asynchronously parses an array buffer into an ImageBitmap - this contains the decoded data | ||
}; | ||
exports.PlatformImageLoader = PlatformImageLoader; | ||
@@ -30,0 +22,0 @@ |
@@ -9,11 +9,5 @@ "use strict"; | ||
// TODO - currently only work in browser, great if could work on all platform image types | ||
/* global document */ | ||
// Unpacks compressed image data into an HTML image | ||
function decodeImage(arrayBufferOrView, _ref) { | ||
var _ref$mimeType = _ref.mimeType, | ||
mimeType = _ref$mimeType === void 0 ? 'image/jpeg' : _ref$mimeType; | ||
/* global window, Blob, Image */ | ||
var blob = new Blob([arrayBufferOrView], { | ||
@@ -35,5 +29,4 @@ type: mimeType | ||
}); | ||
} // Get (uncompressed) image pixel data | ||
} | ||
function getImagePixelData(image) { | ||
@@ -40,0 +33,0 @@ var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
@@ -1,23 +0,2 @@ | ||
/* TODO - from luma.gl | ||
export function getImageFromContext(gl) { | ||
const image = createImage(gl.drawingBufferWidth, gl.drawingBufferHeight); | ||
return new Promise(resolve => { | ||
image.onload = () => { | ||
resolve(image); | ||
}; | ||
image.src = gl.canvas.toDataURL(); | ||
}); | ||
} | ||
function createImage(width, height) { | ||
const image = document.createElement('img'); | ||
image.width = width; | ||
image.height = height; | ||
image.style.position = 'absolute'; | ||
image.style.top = 0; | ||
image.style.left = 0; | ||
return image; | ||
}s | ||
*/ | ||
"use strict"; | ||
//# sourceMappingURL=image-utils.js.map |
@@ -32,2 +32,14 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "isImage", { | ||
enumerable: true, | ||
get: function get() { | ||
return _getImageSize.isImage; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getImageSize", { | ||
enumerable: true, | ||
get: function get() { | ||
return _getImageSize.getImageSize; | ||
} | ||
}); | ||
@@ -41,2 +53,4 @@ var _imageLoader = _interopRequireDefault(require("./image-loader")); | ||
var _imageUtilsBrowser = require("./image-utils/image-utils-browser"); | ||
var _getImageSize = require("./image-utils/get-image-size"); | ||
//# sourceMappingURL=index.js.map |
@@ -31,5 +31,4 @@ "use strict"; | ||
}); | ||
} // Resolves to an ndarray | ||
} | ||
function loadImageNode(url, options) { | ||
@@ -36,0 +35,0 @@ var getPixelsAsync = _util.default.promisify(_getPixels.default); |
@@ -14,17 +14,2 @@ "use strict"; | ||
// Image loading/saving for browser | ||
/* global document, HTMLCanvasElement, Image */ | ||
/* global process, Buffer */ | ||
// Note: through adds stream support | ||
/* | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image - Image or Canvas | ||
* @param {String} opt.type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
*/ | ||
function encodeImageBrowser(image, type) { | ||
@@ -40,6 +25,4 @@ if (image instanceof HTMLCanvasElement) { | ||
canvas.height = image.height; | ||
canvas.getContext('2d').drawImage(image, 0, 0); // Get raw image data | ||
var data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); // Dump data into stream and return | ||
canvas.getContext('2d').drawImage(image, 0, 0); | ||
var data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); | ||
var result = (0, _through.default)(); | ||
@@ -46,0 +29,0 @@ process.nextTick(function () { |
@@ -14,22 +14,7 @@ "use strict"; | ||
// Use stackgl modules for DOM-less reading and writing of images | ||
// NOTE: These are not dependencies of luma.gl. | ||
// They need to be imported by the app. | ||
/** | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image to save | ||
* @param {String} type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
* @return {*} bytes | ||
*/ | ||
function encodeImageToStreamNode(image, options) { | ||
// Support MIME type strings | ||
var type = options.type ? options.type.replace('image/', '') : 'jpeg'; | ||
var pixels = (0, _ndarray.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); // Note: savePixels returns a stream | ||
var pixels = (0, _ndarray.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); | ||
return (0, _savePixels.default)(pixels, type, options); | ||
} | ||
//# sourceMappingURL=encode-image-node.js.map |
import { loadImage } from './load-image/load-image'; | ||
/* | ||
/* global Image, Blob, createImageBitmap * | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
export const ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; | ||
// Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
export const HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; | ||
// Loads a platform-specific image type that can be used as input data to WebGL textures | ||
export const PlatformImageLoader = { | ||
parse: parseToPlatformImage, | ||
load: loadToPlatformImage | ||
}; | ||
*/ | ||
export default { | ||
@@ -23,0 +3,0 @@ name: 'Images', |
@@ -1,17 +0,11 @@ | ||
/* global Image, Blob, createImageBitmap */ | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
export const ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; // Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
}; | ||
export const HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; // Loads a platform-specific image type that can be used as input data to WebGL textures | ||
}; | ||
export const PlatformImageLoader = { | ||
parse: parseToPlatformImage, | ||
load: loadToPlatformImage | ||
}; // TODO - export functions that work on "platform images", | ||
// e.g. extracts image data as typed array from any of the platform image formats. | ||
// Asynchronously parses an array buffer into an ImageBitmap - this contains the decoded data | ||
}; | ||
@@ -18,0 +12,0 @@ function parseToImageBitmap(arrayBuffer) { |
@@ -1,10 +0,4 @@ | ||
// TODO - currently only work in browser, great if could work on all platform image types | ||
/* global document */ | ||
// Unpacks compressed image data into an HTML image | ||
export function decodeImage(arrayBufferOrView, _ref) { | ||
let _ref$mimeType = _ref.mimeType, | ||
mimeType = _ref$mimeType === void 0 ? 'image/jpeg' : _ref$mimeType; | ||
/* global window, Blob, Image */ | ||
const blob = new Blob([arrayBufferOrView], { | ||
@@ -24,4 +18,3 @@ type: mimeType | ||
}); | ||
} // Get (uncompressed) image pixel data | ||
} | ||
export function getImagePixelData(image) { | ||
@@ -28,0 +21,0 @@ let width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
@@ -1,22 +0,2 @@ | ||
/* TODO - from luma.gl | ||
export function getImageFromContext(gl) { | ||
const image = createImage(gl.drawingBufferWidth, gl.drawingBufferHeight); | ||
return new Promise(resolve => { | ||
image.onload = () => { | ||
resolve(image); | ||
}; | ||
image.src = gl.canvas.toDataURL(); | ||
}); | ||
} | ||
function createImage(width, height) { | ||
const image = document.createElement('img'); | ||
image.width = width; | ||
image.height = height; | ||
image.style.position = 'absolute'; | ||
image.style.top = 0; | ||
image.style.left = 0; | ||
return image; | ||
}s | ||
*/ | ||
//# sourceMappingURL=image-utils.js.map |
@@ -5,2 +5,3 @@ export { default as ImageLoader } from './image-loader'; | ||
export { decodeImage } from './image-utils/image-utils-browser'; | ||
export { isImage, getImageSize } from './image-utils/get-image-size'; | ||
//# sourceMappingURL=index.js.map |
@@ -16,4 +16,3 @@ import { isBrowser, loadImage as loadImageBrowser } from '@loaders.gl/core'; | ||
})); | ||
} // Resolves to an ndarray | ||
} | ||
export function loadImageNode(url, options) { | ||
@@ -20,0 +19,0 @@ const getPixelsAsync = util.promisify(getPixels); |
@@ -1,18 +0,3 @@ | ||
// Image loading/saving for browser | ||
/* global document, HTMLCanvasElement, Image */ | ||
/* global process, Buffer */ | ||
import { assert } from '@loaders.gl/core'; | ||
import through from 'through'; // Note: through adds stream support | ||
/* | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image - Image or Canvas | ||
* @param {String} opt.type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
*/ | ||
import through from 'through'; | ||
export function encodeImageBrowser(image, type) { | ||
@@ -28,6 +13,4 @@ if (image instanceof HTMLCanvasElement) { | ||
canvas.height = image.height; | ||
canvas.getContext('2d').drawImage(image, 0, 0); // Get raw image data | ||
const data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); // Dump data into stream and return | ||
canvas.getContext('2d').drawImage(image, 0, 0); | ||
const data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); | ||
const result = through(); | ||
@@ -34,0 +17,0 @@ process.nextTick(() => result.end(new Buffer(data, 'base64'))); |
@@ -1,23 +0,8 @@ | ||
// Use stackgl modules for DOM-less reading and writing of images | ||
// NOTE: These are not dependencies of luma.gl. | ||
// They need to be imported by the app. | ||
import savePixels from 'save-pixels'; | ||
import ndarray from 'ndarray'; | ||
/** | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image to save | ||
* @param {String} type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
* @return {*} bytes | ||
*/ | ||
export function encodeImageToStreamNode(image, options) { | ||
// Support MIME type strings | ||
const type = options.type ? options.type.replace('image/', '') : 'jpeg'; | ||
const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); // Note: savePixels returns a stream | ||
const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); | ||
return savePixels(pixels, type, options); | ||
} | ||
//# sourceMappingURL=encode-image-node.js.map |
import { loadImage } from './load-image/load-image'; | ||
/* | ||
/* global Image, Blob, createImageBitmap * | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
export const ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; | ||
// Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
export const HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; | ||
// Loads a platform-specific image type that can be used as input data to WebGL textures | ||
export const PlatformImageLoader = { | ||
parse: parseToPlatformImage, | ||
load: loadToPlatformImage | ||
}; | ||
*/ | ||
export default { | ||
@@ -23,0 +3,0 @@ name: 'Images', |
@@ -1,17 +0,11 @@ | ||
/* global Image, Blob, createImageBitmap */ | ||
// Specifically loads an ImageBitmap (works on newer browser main and worker threads) | ||
export var ImageBitmapLoader = { | ||
parse: parseToImageBitmap | ||
}; // Specifically loads an HTMLImage (works on alls browser main threads but not on worker threads) | ||
}; | ||
export var HTMLImageLoader = { | ||
load: loadToHTMLImage | ||
}; // Loads a platform-specific image type that can be used as input data to WebGL textures | ||
}; | ||
export var PlatformImageLoader = { | ||
parse: parseToPlatformImage, | ||
load: loadToPlatformImage | ||
}; // TODO - export functions that work on "platform images", | ||
// e.g. extracts image data as typed array from any of the platform image formats. | ||
// Asynchronously parses an array buffer into an ImageBitmap - this contains the decoded data | ||
}; | ||
@@ -18,0 +12,0 @@ function parseToImageBitmap(arrayBuffer) { |
@@ -1,10 +0,4 @@ | ||
// TODO - currently only work in browser, great if could work on all platform image types | ||
/* global document */ | ||
// Unpacks compressed image data into an HTML image | ||
export function decodeImage(arrayBufferOrView, _ref) { | ||
var _ref$mimeType = _ref.mimeType, | ||
mimeType = _ref$mimeType === void 0 ? 'image/jpeg' : _ref$mimeType; | ||
/* global window, Blob, Image */ | ||
var blob = new Blob([arrayBufferOrView], { | ||
@@ -26,4 +20,3 @@ type: mimeType | ||
}); | ||
} // Get (uncompressed) image pixel data | ||
} | ||
export function getImagePixelData(image) { | ||
@@ -30,0 +23,0 @@ var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
@@ -1,22 +0,2 @@ | ||
/* TODO - from luma.gl | ||
export function getImageFromContext(gl) { | ||
const image = createImage(gl.drawingBufferWidth, gl.drawingBufferHeight); | ||
return new Promise(resolve => { | ||
image.onload = () => { | ||
resolve(image); | ||
}; | ||
image.src = gl.canvas.toDataURL(); | ||
}); | ||
} | ||
function createImage(width, height) { | ||
const image = document.createElement('img'); | ||
image.width = width; | ||
image.height = height; | ||
image.style.position = 'absolute'; | ||
image.style.top = 0; | ||
image.style.left = 0; | ||
return image; | ||
}s | ||
*/ | ||
//# sourceMappingURL=image-utils.js.map |
@@ -5,2 +5,3 @@ export { default as ImageLoader } from './image-loader'; | ||
export { decodeImage } from './image-utils/image-utils-browser'; | ||
export { isImage, getImageSize } from './image-utils/get-image-size'; | ||
//# sourceMappingURL=index.js.map |
@@ -18,4 +18,3 @@ import { isBrowser, loadImage as loadImageBrowser } from '@loaders.gl/core'; | ||
}); | ||
} // Resolves to an ndarray | ||
} | ||
export function loadImageNode(url, options) { | ||
@@ -22,0 +21,0 @@ var getPixelsAsync = util.promisify(getPixels); |
@@ -1,18 +0,3 @@ | ||
// Image loading/saving for browser | ||
/* global document, HTMLCanvasElement, Image */ | ||
/* global process, Buffer */ | ||
import { assert } from '@loaders.gl/core'; | ||
import through from 'through'; // Note: through adds stream support | ||
/* | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image - Image or Canvas | ||
* @param {String} opt.type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
*/ | ||
import through from 'through'; | ||
export function encodeImageBrowser(image, type) { | ||
@@ -28,6 +13,4 @@ if (image instanceof HTMLCanvasElement) { | ||
canvas.height = image.height; | ||
canvas.getContext('2d').drawImage(image, 0, 0); // Get raw image data | ||
var data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); // Dump data into stream and return | ||
canvas.getContext('2d').drawImage(image, 0, 0); | ||
var data = canvas.toDataURL(type || 'png').replace(/^data:image\/(png|jpg);base64,/, ''); | ||
var result = through(); | ||
@@ -34,0 +17,0 @@ process.nextTick(function () { |
@@ -1,23 +0,8 @@ | ||
// Use stackgl modules for DOM-less reading and writing of images | ||
// NOTE: These are not dependencies of luma.gl. | ||
// They need to be imported by the app. | ||
import savePixels from 'save-pixels'; | ||
import ndarray from 'ndarray'; | ||
/** | ||
* Returns data bytes representing a compressed image in PNG or JPG format, | ||
* This data can be saved using file system (f) methods or | ||
* used in a request. | ||
* @param {Image} image to save | ||
* @param {String} type='png' - png, jpg or image/png, image/jpg are valid | ||
* @param {String} opt.dataURI= - Whether to include a data URI header | ||
* @return {*} bytes | ||
*/ | ||
export function encodeImageToStreamNode(image, options) { | ||
// Support MIME type strings | ||
var type = options.type ? options.type.replace('image/', '') : 'jpeg'; | ||
var pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); // Note: savePixels returns a stream | ||
var pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0); | ||
return savePixels(pixels, type, options); | ||
} | ||
//# sourceMappingURL=encode-image-node.js.map |
{ | ||
"name": "@loaders.gl/images", | ||
"version": "0.7.1", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Framework-independent loaders and writers for images (PNG, JPG, ...)", | ||
@@ -29,9 +29,3 @@ "license": "MIT", | ||
], | ||
"scripts": { | ||
"clean": "rm -fr dist && mkdir -p dist", | ||
"build": "npm run clean && npm run build-es6 && npm run build-esm && npm run build-es5", | ||
"build-es6": "BABEL_ENV=es6 babel src --config-file ../../babel.config.js --out-dir dist/es6 --source-maps --ignore 'node_modules/'", | ||
"build-esm": "BABEL_ENV=esm babel src --config-file ../../babel.config.js --out-dir dist/esm --source-maps --ignore 'node_modules/'", | ||
"build-es5": "BABEL_ENV=es5 babel src --config-file ../../babel.config.js --out-dir dist/es5 --source-maps --ignore 'node_modules/'" | ||
}, | ||
"scripts": {}, | ||
"sideEffects": false, | ||
@@ -38,0 +32,0 @@ "browser": { |
@@ -5,6 +5,5 @@ export {default as ImageLoader} from './image-loader'; | ||
export {loadImage} from './load-image/load-image'; | ||
export {decodeImage} from './image-utils/image-utils-browser'; | ||
export { | ||
decodeImage | ||
} from './image-utils/image-utils-browser'; | ||
// UTILS | ||
export {isImage, getImageSize} from './image-utils/get-image-size'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
113660
72
1233
1