PHPでPowerPointプレゼンテーションをTIFFに変換
概要
TIFF(Tagged Image File Format)は、広く使用されているロスレスラスター画像形式で、優れた画質とグラフィックの詳細な保存が特徴です。デザイナー、写真家、デスクトップパブリッシャーは、画像のレイヤー、カラー精度、元の設定を維持するために TIFF を選択することが多いです。
Aspose.Slides を使用すると、PowerPoint スライド(PPT、PPTX)や OpenDocument スライド(ODP)を直接高品質な TIFF 画像に簡単に変換でき、プレゼンテーションの視覚的忠実度を最大限に保つことができます。
プレゼンテーションを TIFF に変換する
Using the save method provided by the Presentation class, you can quickly convert an entire PowerPoint presentation to TIFF. The resulting TIFF images correspond to the default slide size.
このコードは PowerPoint プレゼンテーションを TIFF に変換する方法を示しています:
// プレゼンテーションファイル (PPT、PPTX、ODP など) を表す Presentation クラスのインスタンスを作成します。
$presentation = new Presentation("presentation.pptx");
try {
// プレゼンテーションを TIFF として保存します。
$presentation->save("output.tiff", SaveFormat::Tiff);
} finally {
$presentation->dispose();
}
プレゼンテーションを白黒 TIFF に変換する
The method setBwConversionMode in the TiffOptions class allows you to specify the algorithm used when converting a colored slide or image to a black-and-white TIFF. Note that this setting applies only when the setCompressionType method is set to CCITT4 or CCITT3.
例として、“sample.pptx” ファイルに以下のスライドがあるとします:

このコードはカラー スライドを白黒 TIFF に変換する方法を示しています:
$tiffOptions = new TiffOptions();
$tiffOptions->setCompressionType(TiffCompressionTypes::CCITT4);
$tiffOptions->setBwConversionMode(BlackWhiteConversionMode::Dithering);
$presentation = new Presentation("sample.pptx");
try {
$presentation->save("output.tiff", SaveFormat::Tiff, $tiffOptions);
} finally {
$presentation->dispose();
}
結果:

カスタムサイズでプレゼンテーションを TIFF に変換する
If you require a TIFF image with specific dimensions, you can set your desired values using methods available in TiffOptions. For instance, the setImageSize method allows you to define the size of the resulting image.
このコードは、カスタムサイズの TIFF 画像にプレゼンテーションを変換する方法を示しています:
// プレゼンテーション ファイル (PPT、PPTX、ODP など) を表す Presentation クラスのインスタンスを作成します。
$presentation = new Presentation("presentation.pptx");
try {
$tiffOptions = new TiffOptions();
// 圧縮タイプを設定します。
$tiffOptions->setCompressionType(TiffCompressionTypes::Default);
/*
圧縮タイプ:
Default - デフォルトの圧縮方式 (LZW) を指定します。
None - 圧縮なしを指定します。
CCITT3
CCITT4
LZW
RLE
*/
// 深度は圧縮タイプに依存し、手動で設定できません。
// 画像の DPI を設定します。
$tiffOptions->setDpiX(200);
$tiffOptions->setDpiY(200);
// 画像サイズを設定します。
$tiffOptions->setImageSize(new Java("java.awt.Dimension", 1728, 1078));
$notesOptions = new NotesCommentsLayoutingOptions();
$notesOptions->setNotesPosition(NotesPositions::BottomFull);
$tiffOptions->setSlidesLayoutOptions($notesOptions);
// 指定したサイズでプレゼンテーションを TIFF として保存します。
$presentation->save("tiff-ImageSize.tiff", SaveFormat::Tiff, $tiffOptions);
} finally {
$presentation->dispose();
}
カスタム画像ピクセルフォーマットでプレゼンテーションを TIFF に変換する
Using the setPixelFormat method from the TiffOptions class, you can specify your preferred pixel format for the resulting TIFF image.
このコードは、カスタムピクセルフォーマットで TIFF 画像にプレゼンテーションを変換する方法を示しています:
// プレゼンテーション ファイル (PPT、PPTX、ODP など) を表す Presentation クラスのインスタンスを作成します。
$presentation = new Presentation("presentation.pptx");
try {
$tiffOptions = new TiffOptions();
$tiffOptions->setPixelFormat(ImagePixelFormat::Format8bppIndexed);
/*
ImagePixelFormat は以下の値を含みます(ドキュメントに記載されている通り):
Format1bppIndexed - 1 ビット/ピクセル、インデックスカラー。
Format4bppIndexed - 4 ビット/ピクセル、インデックスカラー。
Format8bppIndexed - 8 ビット/ピクセル、インデックスカラー。
Format24bppRgb - 24 ビット/ピクセル、RGB。
Format32bppArgb - 32 ビット/ピクセル、ARGB。
*/
// 指定した画像サイズでプレゼンテーションを TIFF として保存します。
$presentation->save("Tiff-PixelFormat.tiff", SaveFormat::Tiff, $tiffOptions);
} finally {
$presentation->dispose();
}
ヒント
Aspose の無料 PowerPoint からポスターへのコンバータをご覧ください。FAQ
個々のスライドだけを TIFF に変換することはできますか?
はい。Aspose.Slides を使用すると、PowerPoint および OpenDocument のプレゼンテーションから個々のスライドを別々に TIFF 画像に変換できます。
プレゼンテーションを TIFF に変換する際にスライド数の制限はありますか?
いいえ、Aspose.Slides にはスライド数に対する制限はありません。任意のサイズのプレゼンテーションを TIFF 形式に変換できます。
PowerPoint のアニメーションやトランジション効果は TIFF に変換すると保持されますか?
保持されません。TIFF は静的画像形式であるため、アニメーションやトランジション効果は保存されず、スライドの静止画がエクスポートされます。