UNPKG

magica

Version:

ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.

102 lines 3.86 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const misc_utils_of_mine_generic_1 = require("misc-utils-of-mine-generic"); const file_1 = require("../../file/file"); class SizeHelper { constructor() { this.name = 'size'; } exec(options) { return __awaiter(this, void 0, void 0, function* () { var file = misc_utils_of_mine_generic_1.asArray(typeof options.file === 'string' ? yield file_1.File.resolve(options.file) : options.file); return yield file[0].size(); }); } fnCompileTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } fnRunTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } } exports.SizeHelper = SizeHelper; class ImageInfoHelper { constructor() { this.name = 'imageInfo'; } exec(options) { return __awaiter(this, void 0, void 0, function* () { var file = misc_utils_of_mine_generic_1.asArray(typeof options.file === 'string' ? yield file_1.File.resolve(options.file) : options.file).filter(misc_utils_of_mine_generic_1.notUndefined).map(file_1.File.asFile); return yield file[0].infoOne(); }); } fnCompileTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } fnRunTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } } exports.ImageInfoHelper = ImageInfoHelper; class HeightHelper { constructor() { this.name = 'height'; } exec(options) { return __awaiter(this, void 0, void 0, function* () { var file = misc_utils_of_mine_generic_1.asArray(typeof options.file === 'string' ? yield file_1.File.resolve(options.file) : options.file); return (yield file[0].size()).height; }); } fnCompileTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } fnRunTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } } exports.HeightHelper = HeightHelper; class WidthHelper { constructor() { this.name = 'width'; } exec(options) { return __awaiter(this, void 0, void 0, function* () { var file = misc_utils_of_mine_generic_1.asArray(typeof options.file === 'string' ? yield file_1.File.resolve(options.file) : options.file); return (yield file[0].size()).width; }); } fnCompileTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } fnRunTime(options) { return __awaiter(this, void 0, void 0, function* () { return yield this.exec(options); }); } } exports.WidthHelper = WidthHelper; //# sourceMappingURL=imageHelper.js.map