ImageCapture.getPhotoCapabilities()

ImageCapture 인터페이스의 getPhotoCapabilities() 메서드는 사용 가능한 설정 옵션을 담은 PhotoCapabilities 객체로 이행하는 Promise를 반환합니다.

구문

const capabilitiesPromise = imageCaptureObj.getPhotoCapabilities()

반환 값

PhotoCapabilities 객체로 이행하는 Promise.

예제

다음 예제는 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 'getPhotoCapabilities()' in that specification.
Working Draft Initial definition.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getPhotoCapabilities
Experimental
Chrome Full support 59Edge Full support ≤79Firefox ? IE No support NoOpera Full support 46Safari ? WebView Android Full support 59Chrome Android Full support 59Firefox Android ? Opera Android Full support 43Safari iOS ? Samsung Internet Android Full support 7.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.