Comparing version 0.1.14 to 0.1.15
144
gia-ast.js
@@ -16,2 +16,4 @@ #!/bin/env node | ||
const fs = require('fs'); | ||
const tempfile = require('tempfile'); | ||
const sharp = require('sharp'); | ||
@@ -22,2 +24,60 @@ | ||
//----for later | ||
// const yargs = require('yargs'); | ||
// var ver = yargs.version(); | ||
// var appStartMessage = | ||
// `Multi platform Contact Sheet maker | ||
// By Guillaume Descoteaux-Isabelle, 2020-2021 | ||
// version ${ver} | ||
// ----------------------------------------`; | ||
// //const { argv } = require('process'); | ||
// //const { hideBin } = require('yargs/helpers') | ||
// const argv = yargs(process.argv) | ||
// .scriptName("gis-csm") | ||
// .usage(appStartMessage) | ||
// // .command('serve [port]', 'start the server', (yargs) => { | ||
// // yargs | ||
// // .positional('f', { | ||
// // describe: 'port to bind on', | ||
// // type:'string', | ||
// // default: 5000 | ||
// // }) | ||
// // }, (argv) => { | ||
// // if (argv.verbose) console.info(`start server on :${argv.port}`) | ||
// // //serve(argv.port) | ||
// // console.log("test"); | ||
// // console.info(`start server on :${argv.port}`) | ||
// // }) | ||
// .option('file', { | ||
// alias: 'f', | ||
// type: 'string', | ||
// description: 'Specify the file out' | ||
// }) | ||
// .option('directory', { | ||
// alias: 'd', | ||
// type: 'boolean', | ||
// default:false, | ||
// description: 'Name the output using current Basedirname' | ||
// }).usage(`gis-csm -d --label # Assuming this file in directory: vm_s01-v01_768x___285k.jpg | ||
// # will extract 285 and add that instead of filename`) | ||
// .option('verbose', { | ||
// alias: 'v', | ||
// default:false, | ||
// type: 'boolean', | ||
// description: 'Run with verbose logging' | ||
// }) | ||
// .option('label', { | ||
// alias: 'l', | ||
// type: 'boolean', | ||
// default:false, | ||
// description: 'Label using last digit in filename (used for parsing inference result that contain checkpoint number)' | ||
// }) | ||
// .argv; | ||
//----------- | ||
var config = null; | ||
@@ -42,18 +102,21 @@ | ||
var envErr = 0; | ||
//----grab-the-env | ||
if (process.env.asthostname) | ||
config.hostname = process.env.asthostname; | ||
config.hostname = process.env.asthostname; | ||
else envErr++; | ||
if (process.env.astoutsuffix) | ||
config.outsuffix = process.env.astoutsuffix; | ||
config.outsuffix = process.env.astoutsuffix; | ||
else envErr++; | ||
if ( process.env.astportbase) | ||
config.portbase = process.env.astportbase; | ||
config.portbase = process.env.astportbase; | ||
else envErr++; | ||
if (process.env.astcallprotocol) | ||
config.callprotocol = process.env.astcallprotocol; | ||
config.callprotocol = process.env.astcallprotocol; | ||
else envErr++; | ||
if (process.env.astcallmethod) | ||
config.callmethod = process.env.astcallmethod; | ||
config.callmethod = process.env.astcallmethod; | ||
else envErr++; | ||
if (envErr > 0) { | ||
@@ -63,2 +126,4 @@ console.log("Env require setup"); | ||
} | ||
//----grab-the-env | ||
@@ -78,3 +143,3 @@ } catch (error) { | ||
by Guillaume D-Isabelle, 2021 | ||
Version 0.1.14 | ||
Version 0.1.15 | ||
-------------------------------------- | ||
@@ -105,2 +170,10 @@ -------------HELP---------------------- | ||
var resizeSwitch = false; | ||
var targetResolutionX = 768; | ||
if (args[2]) { | ||
resizeSwitch = true; | ||
targetResolutionX = Number(args[2]); | ||
} | ||
//ModelID is related to a port will use | ||
@@ -118,6 +191,48 @@ var modelid = args[1]; | ||
/* | ||
//Use later to resized the image if switch used | ||
sharp('input.jpg') | ||
.rotate() | ||
.resize(200) | ||
.jpeg({ mozjpeg: true }) | ||
.toBuffer() | ||
.then( data => { ... }) | ||
.catch( err => { ... }); | ||
*/ | ||
doWeResize(imgFile,config,portnum,callurl,targetOutput,resizeSwitch,targetResolutionX); | ||
} | ||
function doWeResize(imgFile,config,portnum,callurl,targetOutput,resizeSwitch=false,targetResolutionX=512) | ||
{ | ||
if (resizeSwitch) | ||
{ | ||
var tfile = tempfile('.jpg'); | ||
//console.log("Tempfile:" + tfile); | ||
sharp(imgFile) | ||
.resize(targetResolutionX) | ||
.toFile( tfile, (err, info) => { | ||
if (err) console.error(err); | ||
//console.log(info); | ||
console.log("A resized contentImage should be available at that path :\n feh " + tfile | ||
+ " \n with resolution : " + targetResolutionX); | ||
// process.exit(1); | ||
doTheWork(tfile,config,portnum,callurl,targetOutput); | ||
}); | ||
} else //no resize command | ||
doTheWork(imgFile,config,portnum,callurl,targetOutput); | ||
} | ||
function doTheWork(cFile,config,portnum,callurl,targetOutput) | ||
{ | ||
try { | ||
var data = giaenc. | ||
encFileToJSONStringifyBase64Prop(imgFile,"contentImage"); | ||
encFileToJSONStringifyBase64Prop(cFile,"contentImage"); | ||
//console.log(data); | ||
@@ -139,3 +254,3 @@ //var unparsedData = JSON.parse(data); | ||
console.log("Calling : " + config.hostname); | ||
console.log("Calling : " + config.hostname + ":" + portnum); | ||
@@ -152,2 +267,4 @@ axios.post(callurl, data, options) | ||
giaenc.dec64_StringToFile(stylizedImage,targetOutput); | ||
console.log("A stylizedImage should be available at that path :\n feh " + targetOutput); | ||
@@ -168,9 +285,2 @@ //console.log(stylizedImage); | ||
console.log(error); | ||
} | ||
} | ||
}} |
{ | ||
"name": "gia-ast", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "A CLI Wrapping AST Web API calls to servers", | ||
@@ -33,4 +33,7 @@ "main": "index.js", | ||
"gia-lib-encoding-base64": "^0.1.0", | ||
"safer-buffer": "^2.1.2" | ||
"safer-buffer": "^2.1.2", | ||
"sharp": "^0.28.1", | ||
"tempfile": "^3.0.0", | ||
"yargs": "^16.2.0" | ||
} | ||
} |
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
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
562
21606
6
9
+ Addedsharp@^0.28.1
+ Addedtempfile@^3.0.0
+ Addedyargs@^16.2.0
+ Addedansi-regex@2.1.15.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedcolor@3.2.1(transitive)
+ Addedcolor-convert@1.9.32.0.1(transitive)
+ Addedcolor-name@1.1.31.1.4(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddecompress-response@4.2.1(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-fullwidth-code-point@1.0.03.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmimic-response@2.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@2.30.1(transitive)
+ Addednode-addon-api@3.2.1(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedprebuild-install@6.1.4(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@2.3.83.6.2(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsemver@5.7.27.6.3(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsharp@0.28.3(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@3.1.1(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedstring-width@1.0.24.2.3(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.16.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtemp-dir@2.0.0(transitive)
+ Addedtempfile@3.0.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.2.0(transitive)
+ Addedyargs-parser@20.2.9(transitive)