Parametrize, add node module
parent
0152285894
commit
c169786e7c
@ -1,2 +1,7 @@
|
||||
/@types/
|
||||
/lib/
|
||||
/node_modules/
|
||||
/package-lock.json
|
||||
/output_im.jpg
|
||||
/output_pyvips.jpg
|
||||
/.log/
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
time python ./main.py
|
||||
# using different transform parameters, as vips takes backward parameters, and imagemagic takes forward parameters
|
||||
|
||||
time python ./main.py demo.jpg '2.39014,0.381091,-5.07071e-13,8.09745e-16,2.45629,-1.95474e-12,0.000344095,0.0000931351' output_pyvips.jpg
|
||||
|
||||
time convert demo.jpg -virtual-pixel Transparent -distort PerspectiveProjection '0.418385,-0.064912,1.11204e-12,-1.07285e-16,0.407118,1.85136e-13,-0.000143964,-0.0000155811' output_im.jpg
|
||||
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "perspective-shift",
|
||||
"version": "0.1.0",
|
||||
"description": "Shift perspective of an image using four-point perspective transform in python, vips ",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "npm run build -- --watch",
|
||||
"install": "npm run build",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"types": "./@types",
|
||||
"dependencies": {
|
||||
"abortable-promise": "git+https://git.kuba-orlik.name/kuba/abortable-promises.git#3d13153",
|
||||
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2bc27a3",
|
||||
"tempy": "^1.0.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.kuba-orlik.name/kuba/perspective-shift.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { resolve } from "path";
|
||||
import AbortablePromise from "abortable-promise";
|
||||
import { deferedSpawn } from "async-spawner";
|
||||
import tempy from "tempy";
|
||||
|
||||
export default function perspectiveShift(
|
||||
source_image: string,
|
||||
reverse_transform_parameters: number[],
|
||||
output_image: string = tempy.file({ extension: "jpg" })
|
||||
): AbortablePromise<any> {
|
||||
return new AbortablePromise(async function* (await_or_abort) {
|
||||
const def = await deferedSpawn("python", [
|
||||
resolve(__dirname, "../main.py"),
|
||||
source_image,
|
||||
reverse_transform_parameters.join(","),
|
||||
output_image,
|
||||
]);
|
||||
yield;
|
||||
return await_or_abort(def.waitForAnswer(), () => {
|
||||
def.kill();
|
||||
});
|
||||
});
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "ES2019",
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["es6", "esnext"],
|
||||
"outDir": "lib",
|
||||
"checkJs": true,
|
||||
"allowJs": true,
|
||||
"declarationDir": "@types",
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
Loading…
Reference in New Issue