forked from jywarren/image-sequencer
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a function to sequencer and then made the functionality availab…
…le to crop and overlay module. (#592) * Add manifest.json and cache static assets for offline use (#331) * Add manifest.json * cache static assets for offline use * update cache * add meta theme-color and change static files to be cache * cache the files on network request * caching on first run Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add a button to clear cache * add styling to clear cache link * Update Modules.js (#452) I've arranged the modules in alphabetical order. * Added a function to parse Input coordinates and added the functionality for crop and overlay modules * Added changed dist files * Revert "Added changed dist files" This reverts commit dbda25a. * Changed function name and added the functionaity to src/utils folder * Added unit test * Added unit test to /test/util
- Loading branch information
Showing
8 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = function parseCornerCoordinateInputs(options,coord,callback) { | ||
var getPixels = require('get-pixels'); | ||
getPixels(coord.src, function(err, pixels) { | ||
var iw = pixels.shape[0], | ||
ih = pixels.shape[1]; | ||
if (!coord.x.valInp) { | ||
return | ||
} | ||
else { | ||
Object.keys(coord).forEach(convert); | ||
function convert(key) { | ||
var val = coord[key]; | ||
if (val.valInp && val.valInp.slice(-1) === "%") { | ||
val.valInp = parseInt(val.valInp, 10); | ||
if (val.type === 'horizontal') | ||
val.valInp = val.valInp * iw / 100; | ||
else | ||
val.valInp = val.valInp * ih / 100; | ||
} | ||
} | ||
} | ||
callback(options, coord); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var test = require('tape'); | ||
|
||
var red = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; | ||
|
||
var parseCornerCoordinateInputs = require('../../src/util/ParseInputCoordinates'); | ||
|
||
|
||
test('parseCornerCoordinateInputs works.', function (t) { | ||
var options = { x: '10%' }, | ||
coord = { src: red, x: { valInp: options.x, type: 'horizontal' } } | ||
callback = function (options, coord) { | ||
options.x = parseInt(coord.x.valInp); | ||
t.equal(options.x, 1, 'parseCornerCoordinateInputs works.'); | ||
t.end(); | ||
}; | ||
parseCornerCoordinateInputs(options, coord, callback); | ||
}); |