보강 추가

보강을 사용하면 애플리케이션에서 Google 포토의 앨범 내 사진의 구조와 표시를 제어할 수 있습니다. 이를 통해 텍스트 또는 위치 주석을 통해 사용자에게 추가 컨텍스트를 제공하고 스토리를 함께 전달하는 이미지를 정렬/그룹화할 수 있습니다.

필수 승인 범위

보강을 추가하려면 다음 범위 중 하나 이상이 필요합니다.

  • photoslibrary.appendonly
  • photoslibrary.library
  • photoslibrary.sharing

각 범위에서 enrichAlbum 호출은 앱에서 만든 앨범으로만 제한됩니다.

.sharing 범위를 사용할 때 enrichAlbum는 개발자가 공유 앨범의 소유자를 대신하는 상황으로 제한됩니다.

보강 유형

Google 포토는 텍스트, 위치, 지도의 세 가지 유형의 보강을 지원합니다.

텍스트 보강

텍스트 보강은 앨범에 주석을 달기 위해 삽입할 수 있는 일반 텍스트 문자열입니다.

Google 포토에 표시되는 텍스트 보강 스크린샷

위치 보강

위치 보강은 위치에 주석을 추가하기 위해 삽입할 수 있는 장소 이름과 마커입니다.

Google 포토에 표시되는 위치 보강의 스크린샷

지도 보강

지도 보강은 지정된 출발지와 목적지가 있는 지도로, 앨범에 삽입할 수 있습니다.

Google 포토에 표시되는 지도 보강의 스크린샷

위치

미디어 항목과 앨범 보강 정보를 삽입하려면 앨범의 위치를 지정하세요. 미디어 항목의 경우 위치는 선택사항이지만 앨범 보강에는 지정해야 합니다.

위치는 미디어 항목을 생성하거나 보강을 추가할 때만 지정할 수 있습니다. 앨범의 기존 미디어 항목은 재구성할 수 없으므로 항목이 추가될 때 항목의 위치를 설정하는 것이 중요합니다.

앨범 시작

미디어/보강 항목을 절대 위치로 앨범 시작 부분에 추가할 수 있습니다.

앨범 마지막

미디어/보강 항목을 절대 위치로 앨범 끝에 추가할 수 있습니다.

미디어 항목 기준

미디어/보강 항목은 앨범에서의 위치 이후 시작되는 미디어 항목을 기준으로 추가할 수 있습니다.

보강 항목 기준

미디어/보강 항목은 앨범 내 위치 이후에 시작하는 보강 항목에 상대적으로 추가될 수 있습니다.

앨범에 보강 추가

보강은 한 번에 하나씩 추가되며 앨범의 위치에 추가되어야 합니다. 앨범에 보강을 추가하려면 albums.addEnrichment를 호출합니다.

요청이 성공하면 보강 항목의 id가 반환되며, 이 반환 항목은 미디어 항목 또는 기타 보강 항목을 배치하는 데 사용될 수 있습니다.

REST

다음은 POST 요청입니다.

POST https://photoslibrary.googleapis.com/v1/albums/album-id:addEnrichment
Content-type: application/json
Authorization: Bearer oauth2-token
request-body

요청 본문은 보강 항목과 해당 위치로 구성됩니다.

{
  "newEnrichmentItem": {
    enrichment-to-be-added
  },
  "albumPosition": {
    position-of-enrichment
}

다음은 샘플 응답입니다.

{
  "enrichmentItem": {
    "id": "enrichment-item-id",
  }
}

Java

try {
  // Create the enrichment using the NewEnrichmentItemFactory helper
  NewEnrichmentItem newEnrichmentItem = NewEnrichmentItemFactory.createTextEnrichment("");

  // Set the position of the enrichment within the album
  AlbumPosition albumPosition = AlbumPositionFactory.createFirstInAlbum();

  // To add an enrichment, specify the album, the enrichment item,
  // and the position in the album where the enrichment is to be added
  AddEnrichmentToAlbumResponse response = photosLibraryClient
      .addEnrichmentToAlbum(albumId, newEnrichmentItem, albumPosition);
  // The response contains an EnrichmentItem
  // whose ID can be used to position media items or other enrichments
  EnrichmentItem enrichmentItem = response.getEnrichmentItem();
  String itemId = enrichmentItem.getId();
} catch (ApiException e) {
  // Handle error
}

2,399필리핀

// Create the enrichment item using the PhotosLibraryResourceFactory helper
$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithText("");
// ...
// Set the position of the enrichment within the album
$position = new AlbumPosition();
// ...
try {
    // To add an enrichment, specify the album, the enrichment item,
    // and the position in the album where the enrichment is to be added
    $response = $photosLibraryClient->addEnrichmentToAlbum($albumId, $newEnrichmentItem, $position);
    // The response contains an EnrichmentItem
    // whose ID can be used to position media items or other enrichments
    $enrichmentItem = $response->getEnrichmentItem();
    $itemId = $enrichmentItem->getId();

} catch (\Google\ApiCore\ApiException $e) {
    // Handle error
}

지원되는 보강

텍스트 보강

다음 예와 같이 텍스트 보강에는 단일 텍스트 문자열 (1,000자 이하)이 포함됩니다.

REST

{
  "text": "Text to be shown"
}

Java

// Use the NewEnrichmentItemFactory helper to create a text enrichment item
NewEnrichmentItem newEnrichmentItem =
    NewEnrichmentItemFactory.createTextEnrichment("text to be shown");

2,399필리핀

$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithText("text to be shown");

위치 보강

위치 보강은 임의의 위치 이름과 위도 및 경도 위치로 구성됩니다. locationName는 500자(영문 기준)로 제한됩니다.

REST

{
  "location": {
    "locationName": "Australia",
    "latlng": {
      "latitude": "-21.197",
      "longitude": "95.821"
    }
  }
}

Java

// Use the NewEnrichmentItemFactory helper to create a location enrichment
// with the name, latitude, and longitude of the location
NewEnrichmentItem newEnrichmentItem =
    NewEnrichmentItemFactory.createLocationEnrichment("Australia", -21.197, 95.821);

2,399필리핀

// Create a new location object and set the name, latitude, and longitude of the location
$newLocation = new Location();
$newLocation->setLocationName("Australia");
$newLocation->setLatlng((new LatLng())->setLatitude(-21.197)->setLongitude(95.821));

$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithLocation($newLocation);

지도 보강

지도 보강에는 각각 이름과 위도 및 경도로 구성된 두 위치가 표시됩니다. 위치 보강과 마찬가지로 출처 및 destination 내의 locationName는 500자(영문 기준)로 제한됩니다.

REST

{
  "origin": {
    "locationName": "Australia",
    "latlng": {
      "latitude": "-21.197",
      "longitude": "95.821"
    }
  },
  "destination": {
    "locationName": "San Francisco",
    "latlng": {
      "latitude": "37.757",
      "longitude": "122.507"
    }
  }
}

Java

// Use the NewEnrichmentItemFactory helper to create a map enrichment item for
// an origin and a destination location
NewEnrichmentItem newEnrichmentItem = NewEnrichmentItemFactory.createMapEnrichment(
    "Australia", -21.197, 95.821, // origin
    "San Francisco", 37.757, 122.507 // destination
);

2,399필리핀

// Create two new location objects to create a map enrichment item
// for an origin and a destination location
$locationAustralia = new Location();
$locationAustralia->setLocationName("Australia");
$locationAustralia->setLatlng((new LatLng())->setLatitude(-21.197)->setLongitude(95.821));

$locationSanFrancisco = new Location();
$locationSanFrancisco->setLocationName("San Francisco");
$locationSanFrancisco->setLatlng((new LatLng())->setLatitude(37.757)->setLongitude(122.507));

$newEnrichmentItem =
  PhotosLibraryResourceFactory::newEnrichmentItemWithMap($locationAustralia, $locationSanFrancisco);

지원되는 포지셔닝

앨범 시작

위치 FIRST_IN_ALBUM은 앨범의 시작을 나타냅니다. 여기에 있는 항목은 먼저 사용자에게 표시됩니다.

REST

{
  "position": "FIRST_IN_ALBUM",
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createFirstInAlbum();

2,399필리핀

$albumPosition = new AlbumPosition();
$albumPosition->setPosition(PositionType::FIRST_IN_ALBUM);

앨범 마지막

LAST_IN_ALBUM 위치는 앨범의 끝을 나타냅니다. 여기에 있는 항목은 사용자에게 마지막으로 표시됩니다.

REST

{
  "position": "LAST_IN_ALBUM",
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createLastInAlbum();

2,399필리핀

$albumPosition = new AlbumPosition();
$albumPosition->setPosition(PositionType::LAST_IN_ALBUM);

미디어 항목 기준

위치 relativeMediaItem를 지정하면 미디어 항목을 기준으로 한 위치를 참조합니다. 항목은 지정된 미디어 항목 뒤에 추가됩니다.

REST

{
  "position": "after-media-item",
  "relativeMediaItemId": "media-item-id"
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createAfterMediaItem(mediaItemId);

2,399필리핀

$albumPosition = PhotosLibraryResourceFactory::albumPositionAfterMediaItem($mediaItemId);

보강 항목 기준

relativeEnrichmentItemId를 지정하는 것은 보강 항목을 기준으로 한 위치를 나타냅니다. 항목은 지정된 보강 항목 뒤에 추가됩니다.

REST

{
  "position": "after-enrichment-item",
  "relativeEnrichmentItemId": "enrichment-item-id"
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createAfterEnrichmentItem(enrichmentItemId);

2,399필리핀

$albumPosition = PhotosLibraryResourceFactory::albumPositionAfterEnrichmentItem($enrichmentItemId);

보강 수정

현재 보강을 수정할 수 있는 방법은 없습니다. 하지만 보강을 만들어 앨범에 추가하면 사용자가 Google 포토 앱을 통해 보강을 수정할 수 있습니다.