Convertire immagine PSD in formato raster usando C#
Panoramica
Aspose.PSD consente di convertire formati PSD e PSB in JPEG, JPEG2000, PNG, TIFF, PDF, GIF e BMP.
Puoi convertire file PSD sul tuo server con Aspose.PSD senza Photoshop. Si tratta di una buona alternativa agli script di Adobe Photoshop poiché l’EULA di Adobe vieta l’utilizzo dell’app su un server e la modifica della sua interfaccia utente. Ma con PSD Format SDK puoi effettuare una conversione di batch di file PSD. La tua esportazione in formato PSD può essere impeccabile nei pixel con la modalità di sola lettura, oppure puoi cambiare livelli, testi, effetti e poi eseguire l’esportazione.
Esempi specifici di esportazione di PSD in formati raster
Esportazione immagine PSD in vari formati raster
Di seguito è riportato un codice di esempio che dimostra come convertire PSD in diversi formati file raster.
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
string srcPath = dataDir + @"sample.psd"; | |
string destName = dataDir + @"export"; | |
// Load an existing PSD image as Image | |
using (Image image = Image.Load(srcPath)) | |
{ | |
// Create an instance of PngOptions class | |
PngOptions pngOptions = new PngOptions(); | |
// Create an instance of BmpOptions class | |
BmpOptions bmpOptions = new BmpOptions(); | |
// Create an instance of TiffOptions class | |
TiffOptions tiffOptions = new TiffOptions(FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Create an instance of GifOptions class | |
GifOptions gifOptions = new GifOptions(); | |
// Create an instance of JpegOptions class | |
JpegOptions jpegOptions = new JpegOptions(); | |
// Create an instance of Jpeg2000Options class | |
Jpeg2000Options jpeg2000Options = new Jpeg2000Options(); | |
// Call the save method, provide output path and export options to convert PSD file to various raster file formats. | |
image.Save(destName + ".png", pngOptions); | |
image.Save(destName + ".bmp", bmpOptions); | |
image.Save(destName + ".tiff", tiffOptions); | |
image.Save(destName + ".gif", gifOptions); | |
image.Save(destName + ".jpeg", jpegOptions); | |
image.Save(destName + ".jp2", jpeg2000Options); | |
} |