Aspose.Total for .NET を使用すると、2つの簡単な手順で任意の.NETアプリケーション内のPSDイメージにCGMを簡単にエクスポートできます。まず、 Aspose.PDF for .NET を使用すると、CGMをJPEGにエクスポートできます。その後、 Aspose.Imaging for .NET Image Processing APIを使用して、JPEGをPSDに変換できます。
.NET経由でCGMファイルをPSDに変換する
- Document クラスを使用してCGMファイルを開きます
- JpegDevice クラスオブジェクトを初期化し、 Process を使用してCGMをJPEGにレンダリングします。 com / pdf / net / aspose.pdf.devices.pagedevice / process / methods / 1)メソッド
- Image クラスを使用してJPEGファイルをロードします
- Save メソッドを使用してドキュメントをPSD形式で保存します
変換要件
コマンドラインからnuget install Aspose.Total
としてインストールするか、VisualStudioのパッケージマネージャーコンソールからInstall-PackageAspose.Total
を使用してインストールします。
または、 ダウンロード からオフラインMSIインストーラーまたはDLLをZIPファイルで取得します。
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
C#を介して単一ファイルでCGMファイルをPSDに変換する
APIを使用して、CGMファイルをPSDに変換して単一の画像ファイルにすることもできます。すべてのページを変換するには、最初にCGMドキュメントを1つのTIFFファイルにレンダリングし、その後TIFFファイルをPSDにエクスポートできます。 Document クラスを使用して入力ファイルを開き、Resolution、TiffSettings、およびTIFFデバイスオブジェクトを作成できます。 TiffDevice の Process メソッドを使用して単一のTIFF画像を取得できますクラス。最後に、 画像 クラスを使用してTIFFファイルを読み込むことができます Save メソッドを使用してPSD形式で保存します。
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// Open PDF document | |
Document pdfDocument = new Document("input.pdf"); | |
// Create Resolution object | |
Resolution resolution = new Resolution(300); | |
// Create TiffSettings object | |
TiffSettings tiffSettings = new TiffSettings | |
{ | |
Compression = CompressionType.None, | |
Depth = ColorDepth.Default, | |
Shape = ShapeType.Landscape, | |
SkipBlankPages = false | |
}; | |
// Create TIFF device | |
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); | |
// Convert a particular page and save the image to stream | |
tiffDevice.Process("output.tif"); | |
// load TIFF file | |
var image = Image.Load("output.tif"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save TIFF to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
C#を介してCGMファイルをPSDに変換および回転します
APIを使用すると、必要に応じて出力PSD画像を回転させることもできます。 Image.RotateFlipメソッドを使用すると、画像を90/180/270度回転し、画像を水平または垂直に反転できます。画像に適用する回転と反転のタイプを指定できます。画像を回転および反転するには、 Image クラスで公開されているファクトリメソッドを使用して変換されたJPEG画像を読み込み、画像を呼び出します。適切な RotateFlipType を指定しながら.RotateFlipメソッド。
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// rotate the image | |
image.RotateFlip(RotateFlipType.Rotate270FlipNone); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |