MediaStream Image Capture API의 PhotoCapabilities
인터페이스는 장착된 촬영 장치에서 사용 가능한 설정 옵션을 제공합니다. PhotoCapabilities
객체는 ImageCapture.getPhotoCapabilities()
를 사용해 가져올 수 있습니다..
속성
PhotoCapabilities.redEyeReduction
Read only- 장치의 적목 현상 감소 기능 적용 여부를 나타내는 열거형 값을 반환합니다. 가능한 값은
"never"
,"always"
,"controllable"
로,"controllable"
이어야 설정 가능합니다. PhotoCapabilities.imageHeight
Read only- 사용자 에이전트가 지원하는 이미지 높이를 나타내는
MediaSettingsRange
객체를 반환합니다. PhotoCapabilities.imageWidth
Read only- 사용자 에이전트가 지원하는 이미지 너비를 나타내는
MediaSettingsRange
객체를 반환합니다. PhotoCapabilities.fillLightMode
Read only- 사용 가능한 플래시 옵션을 담은 배열을 반환합니다. 가능한 값은
auto
,off
,flash
입니다.
예제
다음 예제는 Chrome의 Image Capture / Photo Resolution Sample에서 가져온 코드로, getPhotoCapabilities()
를 사용해 범위 입력 칸의 크기를 수정합니다. 또한 장치의 MediaStream
에서 가져온 MediaStreamTrack
객체를 사용해 ImageCapture
객체를 생성하는 부분도 포함하고 있습니다.
const input = document.querySelector('input[type="range"]');
var imageCapture;
navigator.mediaDevices.getUserMedia({video: true})
.then(mediaStream => {
document.querySelector('video').srcObject = mediaStream;
const track = mediaStream.getVideoTracks()[0];
imageCapture = new ImageCapture(track);
return imageCapture.getPhotoCapabilities();
})
.then(photoCapabilities => {
const settings = imageCapture.track.getSettings();
input.min = photoCapabilities.imageWidth.min;
input.max = photoCapabilities.imageWidth.max;
input.step = photoCapabilities.imageWidth.step;
return imageCapture.getPhotoSettings();
})
.then(photoSettings => {
input.value = photoSettings.imageWidth;
})
.catch(error => console.log('Argh!', error.name || error));
명세
Specification | Status | Comment |
---|---|---|
MediaStream Image Capture The definition of 'PotoCapabilities' in that specification. |
Working Draft | Initial definition. |
브라우저 호환성
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.