|
@@ -12,6 +12,92 @@ import { getImage } from './getImage'
|
|
|
|
|
|
const router = express.Router()
|
|
|
|
|
|
+/**
|
|
|
+ * @api {get} /getImageExtracts?sceneName=:sceneName&imageQuality=:imageQuality&horizontalExtractCount=:horizontalExtractCount&verticalExtractCount=:verticalExtractCount Get image extracts
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiName GetImageExtracts
|
|
|
+ * @apiGroup API
|
|
|
+ *
|
|
|
+ * @apiDescription Get an image from a scene with the required quality and cut it with the requested configuration
|
|
|
+ *
|
|
|
+ * @apiParam {String} sceneName The selected scene
|
|
|
+ * @apiParam {Number} imageQuality The required quality of the image
|
|
|
+ * @apiParam {Number} horizontalExtractCount The amount of extracts for the horizontal axis
|
|
|
+ * @apiParam {Number} verticalExtractCount The amount of extracts for the vertical axis
|
|
|
+ *
|
|
|
+ * @apiHeader (Response Headers) {String} Content-Type application/json; charset=utf-8
|
|
|
+ *
|
|
|
+ * @apiExample Usage example
|
|
|
+ * curl -i -L -X GET "http://localhost:5000/api/getImageExtracts?sceneName=bathroom&imageQuality=200&horizontalExtractCount=1&verticalExtractCount=2"
|
|
|
+ *
|
|
|
+ * @apiSuccess {String[]} data Path to the extracted images
|
|
|
+ * @apiSuccessExample {json} Success response example
|
|
|
+ * HTTP/1.1 200 OK /api/getImageExtracts?sceneName=bathroom&imageQuality=200&horizontalExtractCount=1&verticalExtractCount=2
|
|
|
+ * {
|
|
|
+ * "data": [
|
|
|
+ * "/api/images/bathroom/extracts/x1_y2/zone00001/bathroom_zone00001_200.png",
|
|
|
+ * "/api/images/bathroom/extracts/x1_y2/zone00002/bathroom_zone00002_200.png"
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 4xx) 400 Missing parameter(s)
|
|
|
+ * @apiErrorExample {json} Missing parameter
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "message": "Missing parameter(s). Required parameters : sceneName, imageQuality, horizontalExtractCount, verticalExtractCount."
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 4xx) 400 Invalid query parameter
|
|
|
+ * @apiErrorExample {json} Invalid query parameter(s)
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "message": "Invalid query parameter(s).",
|
|
|
+ * "data": [
|
|
|
+ * "The requested scene name \".//../\" is not valid.",
|
|
|
+ * "The specified quality is not an integer.",
|
|
|
+ * "The specified number of extract for the horizontal axis is not an integer.",
|
|
|
+ * "The specified number of extract for the vertical axis is not an integer."
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 4xx) 400 Invalid configuration
|
|
|
+ * @apiErrorExample {json} Invalid configuration
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "message": "Invalid query parameter(s).",
|
|
|
+ * "data": [
|
|
|
+ * "Incompatible number of horizontal extracts (width % numberOfExtracts != 0).",
|
|
|
+ * "Incompatible number of vertical extracts (height % numberOfExtracts != 0)."
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 4xx) 404 Quality not found
|
|
|
+ * @apiErrorExample {json} Quality not found
|
|
|
+ * HTTP/1.1 404 Not Found
|
|
|
+ * {
|
|
|
+ * "message": "The requested quality (9999) was not found for the requested scene (bathroom)."
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 5xx) 500 Can't access the `IMAGES_PATH` directory
|
|
|
+ * @apiErrorExample {json} Images directory not accessible
|
|
|
+ * HTTP/1.1 500 Internal Server Error
|
|
|
+ * {
|
|
|
+ * "message": "Can't access the \"images\" directory. Check it exists and you have read permission on it"
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @apiError (Error 5xx) 500 Failed to parse a file's name
|
|
|
+ * @apiErrorExample {json} Failed to parse a file's name
|
|
|
+ * HTTP/1.1 500 Internal Server Error
|
|
|
+ * {
|
|
|
+ * "message": "Failed to parse file names in the \"bathroom\"'s scene directory.",
|
|
|
+ * "data": [
|
|
|
+ * "The file name does not match convention (scene_000150.ext - /^(.*)?_([0-9]{2,})\\.(.*)$/) : \"bathroom_adz00020.png\".",
|
|
|
+ * "The file name does not match convention (scene_000150.ext - /^(.*)?_([0-9]{2,})\\.(.*)$/) : \"bathroom_adz00020.png\"."
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
/**
|
|
|
* Cut an image, save its extracts and get the url of these extracts
|
|
|
*
|