|
@@ -37,6 +37,13 @@ const router = express.Router()
|
|
|
* @apiSuccess {String} data.info.sceneName Scene name of the original image
|
|
|
* @apiSuccess {Number} data.info.quality Quality of the original image
|
|
|
* @apiSuccess {String} data.info.ext Extension of the original image
|
|
|
+ * @apiSuccess {Object} data.metadata Metadata of the image, @see https://sharp.dimens.io/en/stable/api-input/#metadata
|
|
|
+ * @apiSuccess {Object} data.info.extractsConfig Configuration used to cut the image
|
|
|
+ * @apiSuccess {Number} data.info.extractsConfig.x Number of extracts per line (horizontal)
|
|
|
+ * @apiSuccess {Number} data.info.extractsConfig.y Number of extracts per row (vertical)
|
|
|
+ * @apiSuccess {Object} data.info.extractsSize Size of extracted images
|
|
|
+ * @apiSuccess {Number} data.info.extractsSize.width Width of the extracted images
|
|
|
+ * @apiSuccess {Number} data.info.extractsSize.height Height of the extracted images
|
|
|
* @apiSuccessExample {json} Success response example
|
|
|
* HTTP/1.1 200 OK /api/getImageExtracts?sceneName=bathroom&imageQuality=200&horizontalExtractCount=1&verticalExtractCount=2
|
|
|
* {
|
|
@@ -46,11 +53,33 @@ const router = express.Router()
|
|
|
* "/api/images/bathroom/extracts/x1_y2/zone00002/bathroom_zone00002_200.png"
|
|
|
* ],
|
|
|
* "info": {
|
|
|
- * "link": "/api/images/bathroom/bathroom_00200.png",
|
|
|
- * "fileName": "bathroom_00200.png",
|
|
|
- * "sceneName": "bathroom",
|
|
|
- * "quality": 200,
|
|
|
- * "ext": "png"
|
|
|
+ * "extractsConfig": {
|
|
|
+ * "x": 1,
|
|
|
+ * "y": 2
|
|
|
+ * },
|
|
|
+ * "extractsSize": {
|
|
|
+ * "width": 800,
|
|
|
+ * "height": 400
|
|
|
+ * },
|
|
|
+ * "image": {
|
|
|
+ * "link": "/api/images/bathroom/bathroom_00200.png",
|
|
|
+ * "fileName": "bathroom_00200.png",
|
|
|
+ * "sceneName": "bathroom",
|
|
|
+ * "quality": 200,
|
|
|
+ * "ext": "png"
|
|
|
+ * "metadata": {
|
|
|
+ * "format": "png",
|
|
|
+ * "width": 800,
|
|
|
+ * "height": 800,
|
|
|
+ * "space": "rgb16",
|
|
|
+ * "channels": 3,
|
|
|
+ * "depth": "ushort",
|
|
|
+ * "density": 72,
|
|
|
+ * "isProgressive": false,
|
|
|
+ * "hasProfile": false,
|
|
|
+ * "hasAlpha": false
|
|
|
+ * }
|
|
|
+ * }
|
|
|
* }
|
|
|
* }
|
|
|
* }
|
|
@@ -169,7 +198,11 @@ const cutImage = async (image, xExtracts, yExtracts) => {
|
|
|
link: extractLink,
|
|
|
path: extractPath,
|
|
|
fileName: extractName,
|
|
|
- sceneName: image.sceneName
|
|
|
+ sceneName: image.sceneName,
|
|
|
+ originalWidth: width,
|
|
|
+ originalHeight: height,
|
|
|
+ width: xCropSize,
|
|
|
+ height: yCropSize
|
|
|
}
|
|
|
|
|
|
// Check the file already exist
|
|
@@ -273,7 +306,17 @@ router.get('/', asyncMiddleware(async (req, res) => {
|
|
|
res.json({
|
|
|
data: {
|
|
|
extracts: extracts.map(x => x.link),
|
|
|
- info: image
|
|
|
+ info: {
|
|
|
+ extractsConfig: {
|
|
|
+ x: horizontalExtractCountInt,
|
|
|
+ y: verticalExtractCountInt
|
|
|
+ },
|
|
|
+ extractsSize: {
|
|
|
+ width: extracts[0].width,
|
|
|
+ height: extracts[0].height
|
|
|
+ },
|
|
|
+ image
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}))
|