PowerPoint.ShapeGetImageOptions interface

図形の画像を取得するときに使用できるオプションを表します。 画像は、目的の寸法に収まるようにスケーリングされます。 幅と高さが指定されていない場合は、図形の実際のサイズが使用されます。 幅または高さのどちらか一方のみを指定した場合は、縦横比を保持するためにもう一方が計算されます。 結果として得られる寸法は、大きすぎる場合は、サポートされている最大サイズに自動的にクランプされます。

注釈

API セット: PowerPointApi 1.10

使用元

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shape-as-image.yaml

// Gets an image of the first selected shape with all options specified:
// a fixed width, height, and explicit PNG format.
await PowerPoint.run(async (context) => {
  const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  await context.sync();

  if (shapeCount.value === 0) {
    console.warn("No shapes are selected. Please select a shape and try again.");
    return;
  }

  const shape: PowerPoint.Shape = shapes.getItemAt(0);
  const options: PowerPoint.ShapeGetImageOptions = {
    format: PowerPoint.ShapeGetImageFormatType.png,
    width: 300,
    height: 150,
    // Both width and height are specified, so the image is scaled to fit within
    // 300x150 pixels. The image may not fill both dimensions if the aspect ratios differ.
  };
  const imageResult: OfficeExtension.ClientResult<string> = shape.getImageAsBase64(options);
  await context.sync();

  displayImage(imageResult.value, "PNG, 300x150px");
});

プロパティ

format

結果の画像の目的の形式。

height

結果のイメージの希望の高さ (ピクセル単位)。 この値が大きすぎる場合は、サポートされている最大サイズに自動的にクランプされます。 正以外の整数を設定すると、 InvalidArgument 例外をスローします。

width

結果の画像に必要な幅 (ピクセル単位)。 この値が大きすぎる場合は、サポートされている最大サイズに自動的にクランプされます。 正以外の整数を設定すると、 InvalidArgument 例外をスローします。

プロパティの詳細

format

結果の画像の目的の形式。

format?: PowerPoint.ShapeGetImageFormatType | "Png";

プロパティ値

注釈

API セット: PowerPointApi 1.10

height

結果のイメージの希望の高さ (ピクセル単位)。 この値が大きすぎる場合は、サポートされている最大サイズに自動的にクランプされます。 正以外の整数を設定すると、 InvalidArgument 例外をスローします。

height?: number;

プロパティ値

number

注釈

API セット: PowerPointApi 1.10

width

結果の画像に必要な幅 (ピクセル単位)。 この値が大きすぎる場合は、サポートされている最大サイズに自動的にクランプされます。 正以外の整数を設定すると、 InvalidArgument 例外をスローします。

width?: number;

プロパティ値

number

注釈

API セット: PowerPointApi 1.10