This commit is contained in:
admin
2026-02-24 22:24:21 +08:00
parent 68840e6ea4
commit f0bbc86ba6
8 changed files with 409 additions and 237 deletions

View File

@@ -349,7 +349,10 @@ esp_err_t rest_server_print_image_post(httpd_req_t *req) {
char content_type[96] = {0};
if (httpd_req_get_hdr_value_str(req, "Content-Type", content_type, sizeof(content_type)) == ESP_OK) {
if (strstr(content_type, "application/json") != NULL) {
return rest_server_send_error(req, "400 Bad Request", "use binary jpeg body, not json");
return rest_server_send_error(req, "400 Bad Request", "use binary png body, not json");
}
if (strstr(content_type, "image/png") == NULL) {
return rest_server_send_error(req, "415 Unsupported Media Type", "Content-Type must be image/png");
}
}
@@ -376,23 +379,23 @@ esp_err_t rest_server_print_image_post(httpd_req_t *req) {
uint8_t *raster = NULL;
size_t raster_len = 0;
char decode_err[128] = {0};
esp_err_t decode_rc = raster_tools_convert_jpeg_to_raster_384((const uint8_t *)body,
(size_t)req->content_len,
scale_to_width,
threshold,
invert,
max_height,
&width,
&height,
&raster,
&raster_len,
decode_err,
sizeof(decode_err));
esp_err_t decode_rc = raster_tools_convert_png_to_raster_384((const uint8_t *)body,
(size_t)req->content_len,
scale_to_width,
threshold,
invert,
max_height,
&width,
&height,
&raster,
&raster_len,
decode_err,
sizeof(decode_err));
free(body);
if (decode_rc != ESP_OK) {
return rest_server_send_error(req,
"400 Bad Request",
decode_err[0] != '\0' ? decode_err : "decode jpeg failed");
decode_err[0] != '\0' ? decode_err : "decode png failed");
}
esp_err_t submit_rc = submit_raster_job_and_reply(req,