camera.getImage
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trả về hình ảnh có kích thước đầy đủ hoặc hình ảnh được điều chỉnh theo tỷ lệ dựa trên URI. Các tham số đầu vào bao gồm
độ phân giải. Đây là lệnh duy nhất sẽ trả về, Content-Type: image/jpeg
.
Tất cả các lệnh khác trả về Content-Type: application/json;charset=utf-8
.
Lệnh này không còn được dùng trong API cấp 2.
Tham số
- fileUri: URI của tệp đích. Các nhà sản xuất quyết định có nên sử dụng
URI tuyệt đối hoặc tương đối. Ứng dụng có thể coi đây là giá trị nhận dạng không rõ ràng.
- maxSize: (Không bắt buộc) Kích thước tối đa của hình ảnh được yêu cầu;
max(scaledimage_width, chiều_cao_hình_ảnh_tỷ_lệ). Nếu
maxSize
bị bỏ qua hoặc lớn hơn
hình ảnh kích thước đầy đủ sẽ được trả về.
Kết quả
- content: Dữ liệu nhị phân của hình ảnh, bao gồm cả dữ liệu tương ứng (ví dụ: được điều chỉnh theo tỷ lệ)
siêu dữ liệu trong tiêu đề hình ảnh.
Lỗi
- missingTham số:
fileUri
bắt buộc chưa được chỉ định.
- không hợp lệ Tham số: Tên tham số đầu vào không nhận dạng được.
- invalidParameterValue: Tên thông số đầu vào được nhận dạng, nhưng giá trị của tham số đó
không hợp lệ; ví dụ: giá trị
fileUri
không tồn tại, loại dữ liệu của giá trị không chính xác,
hoặc maxSize
có loại dữ liệu không chính xác.
Lệnh I/O |
Nhập lệnh |
{
"parameters": {
"fileUri": "file URI",
"maxSize": 400
}
} |
Kết quả lệnh |
Image binary data |
Ra lệnh (Lỗi) |
{
"error": {
"code": "invalidParameterValue",
"message": "Parameter fileUri doesn't exist."
}
} |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-08-21 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-08-21 UTC."],[[["\u003cp\u003eReturns a full-size or scaled image based on its URI, with optional resizing using the \u003ccode\u003emaxSize\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eThis command is deprecated and was replaced in API level 2, primarily used for retrieving image data in JPEG format.\u003c/p\u003e\n"],["\u003cp\u003eInput requires a \u003ccode\u003efileUri\u003c/code\u003e parameter, while \u003ccode\u003emaxSize\u003c/code\u003e is optional for scaling the output image.\u003c/p\u003e\n"],["\u003cp\u003eOutput provides the image as binary data, including relevant metadata, or an error message in JSON format.\u003c/p\u003e\n"],["\u003cp\u003ePotential errors involve missing or invalid parameters, such as an incorrect \u003ccode\u003efileUri\u003c/code\u003e or \u003ccode\u003emaxSize\u003c/code\u003e value.\u003c/p\u003e\n"]]],["The command retrieves an image (full-size or scaled) via its URI, with `fileUri` being mandatory and `maxSize` (maximum dimension) being optional. If `maxSize` is omitted or exceeds the image's full size, the full-size image is provided. Output is image binary data, with `Content-Type: image/jpeg`. Errors include missing/invalid parameter or invalid value. It was deprecated in API level 2. Example input involves `fileUri` and `maxSize`. Example error is related to an invalid `fileUri`.\n"],null,["# camera.getImage\n\nReturns a full-size or scaled image given its URI. Input parameters include\nresolution. This is the only command that should return, `Content-Type: image/jpeg`.\nAll other commands return `Content-Type: application/json;charset=utf-8`.\n**This command was deprecated in API level 2.**\n\nParameters\n----------\n\n- **fileUri:** URI of the target file. Manufacturers decide whether to use absolute or relative URIs. Clients may treat this as an opaque identifier.\n- **maxSize:** (Optional) Maximum size of the requested image; max(scaledimage_width, scaledimage_height). If `maxSize` is omitted or larger than the full-size image, the full-size image is returned.\n\nResults\n-------\n\n- **content:** Image binary data, including corresponding (for example, scaled) metadata in image header.\n\nErrors\n------\n\n- **missingParameter:** The required `fileUri` is not specified.\n- **invalidParameterName:** An input parameter name is unrecognized.\n- **invalidParameterValue:** The input parameter name is recognized, but its value is invalid; for example, the `fileUri` value doesn't exist, its data type is incorrect, or `maxSize` has the wrong data type.\n\n| Command I/O ----------- ||\n|----------------------------|-------------------------------------------------------------------------------------------------------------|\n| **Command Input** | ```text { \"parameters\": { \"fileUri\": \"file URI\", \"maxSize\": 400 } } ``` |\n| **Command Output** | ```text Image binary data ``` |\n| **Command Output (Error)** | ```text { \"error\": { \"code\": \"invalidParameterValue\", \"message\": \"Parameter fileUri doesn't exist.\" } } ``` |"]]