mirror of
https://github.com/publiclab/image-sequencer.git
synced 2026-06-16 04:33:26 +02:00
text-overlay in Node (#1125)
* text-overlay in node * text-overlay in node * docs added
This commit is contained in:
+16
-1
@@ -40,6 +40,7 @@ List of Module Documentations
|
||||
35. [ColorTemperature](#color-temperature)
|
||||
36. [Grid-Overlay](#grid-overlay)
|
||||
37. [MinifyImage](#minify-image)
|
||||
38. [Text-Overlay](#text-overlay)
|
||||
|
||||
|
||||
## crop-module
|
||||
@@ -615,4 +616,18 @@ The module supports jpg/jpeg/webp images in browser; but the node version suppor
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('minify-image')
|
||||
.run()
|
||||
```
|
||||
```
|
||||
# Text Overlay
|
||||
|
||||
The modules allows to add text to image in both browser and node environment. We have the options to modify the font-size and also support few font-styles. The text color can also be modified.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('grid-overlay',options)
|
||||
.run()
|
||||
```
|
||||
The options can take various attributes like,
|
||||
```
|
||||
var options = { text : 'Hello World', size : '12'};
|
||||
@@ -3,44 +3,36 @@ module.exports = function TextOverlay(options, UI) {
|
||||
|
||||
var output;
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
function draw(input, callback) {
|
||||
|
||||
var step = this;
|
||||
if (!options.step.inBrowser) { // This module is only for browser
|
||||
this.output = input;
|
||||
callback();
|
||||
|
||||
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
//if (options.step.inBrowser)
|
||||
pixels = require('./TextOverlay')(pixels, options, priorStep);
|
||||
return pixels;
|
||||
}
|
||||
else {
|
||||
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
//if (options.step.inBrowser)
|
||||
pixels = require('./TextOverlay')(pixels, options, priorStep);
|
||||
return pixels;
|
||||
}
|
||||
function output(image, datauri, mimetype) {
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
ui: options.step.ui,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback,
|
||||
useWasm:options.useWasm
|
||||
});
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
ui: options.step.ui,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback,
|
||||
useWasm:options.useWasm
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
module.exports = exports = function(pixels, options, priorstep){
|
||||
|
||||
var $ = require('jquery'); // to make text-overlay work for node.js
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
options.text = options.text || defaults.text;
|
||||
|
||||
@@ -40,6 +40,5 @@
|
||||
"desc": "Enter the font size in pixels.",
|
||||
"default": "12"
|
||||
}
|
||||
},
|
||||
"only": "browser"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user