-
-
Save stefanpenner/ca0334f617acc02e67482947d1fcf7b0 to your computer and use it in GitHub Desktop.
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
const output = { | |
width: 320, | |
height: 360, | |
}; | |
const ratio = output.width / output.height; | |
let crop; | |
if (width > height) { | |
crop = { | |
width: height * ratio, | |
height: height, | |
}; | |
} else { | |
crop = { | |
width: width, | |
height: width / ratio, | |
}; | |
} | |
const face = { | |
top: detection.box.top, | |
left: detection.box.left, | |
height: detection.box.bottom - detection.box.top, | |
width: detection.box.right - detection.box.left, | |
}; | |
const y = face.top - (crop.height - face.height) / 2; | |
const x = face.left - (crop.width - face.width) / 2; | |
const cropValue = `${crop.width}:${crop.height}:${x}:${y}`; | |
const scaleValue = `${output.width}:${output.height}`; | |
// send to ffmpeg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment