by
8,582 17

How to Create Thumbnails from PSD Files inside .NET Applications

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1007363/How-to-Create-Thumbnails-from-PSD-Files-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// Enter here the actual content of the snippet. // Creating Thumbnails from PSD Files //[C# Code Sample] //Load a PSD in an instance of PsdImage using (Aspose.Imaging.FileFormats.Psd.PsdImage image = (Aspose.Imaging.FileFormats.Psd.PsdImage)Aspose.Imaging.Image.Load(sourceFilePath)) { //Iterate over the PSD resources foreach (var resource in image.ImageResources) { //Check if the resource is of thumbnail type if (resource is Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailResource) { //Retrieve the ThumbnailResource var thumbnail = (Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailResource)resource; //Check the format of the ThumbnailResource if (thumbnail.Format == Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailFormat.kJpegRGB) { //Create a new BmpImage by specifying the width and heigh Aspose.Imaging.FileFormats.Bmp.BmpImage thumnailImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(thumbnail.Width, thumbnail.Height); //Store the pixels of thumbnail on to the newly created BmpImage thumnailImage.SavePixels(thumnailImage.Bounds, thumbnail.ThumbnailData); //Save thumbnail on disc thumnailImage.Save("D:\\test.bmp"); } } } } //[VB.NET Code Sample] 'Load a PSD in an instance of PsdImage Using image As Aspose.Imaging.FileFormats.Psd.PsdImage = CType(Aspose.Imaging.Image.Load(sourceFilePath), Aspose.Imaging.FileFormats.Psd.PsdImage) 'Iterate over the PSD resources For Each resource In image.ImageResources 'Check if the resource is of thumbnail type If TypeOf resource Is Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailResource Then 'Retrieve the ThumbnailResource Dim thumbnail = CType(resource, Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailResource) 'Check the format of the ThumbnailResource If thumbnail.Format = Aspose.Imaging.FileFormats.Psd.Resources.ThumbnailFormat.kJpegRGB Then 'Create a new BmpImage by specifying the width and heigh Dim thumnailImage As New Aspose.Imaging.FileFormats.Bmp.BmpImage(thumbnail.Width, thumbnail.Height) 'Store the pixels of thumbnail on to the newly created BmpImage thumnailImage.SavePixels(thumnailImage.Bounds, thumbnail.ThumbnailData) 'Save thumbnail on disc thumnailImage.Save("D:\test.bmp") End If End If Next resource End Using
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus