Exemple #1
0
        public static void Run()
        {
            // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");

            // ExStart:ExportImageToPSD
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing image
            using (Image image = Image.Load(dataDir + "sample.bmp"))
            {
                // Create an instance of PsdOptions and set it’s various properties
                PsdOptions psdOptions = new PsdOptions();
                psdOptions.ColorMode         = ColorModes.Rgb;
                psdOptions.CompressionMethod = CompressionMethod.Raw;
                psdOptions.Version           = 4;

                // Save image to disk in PSD format
                image.Save(dataDir + "ExportImageToPSD_output.psd", psdOptions);

                // Display Status.
                Console.WriteLine("Export to PSD performed successfully.");
            }
            // ExEnd:ExportImageToPSD
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:UncompressedImageStreamObject
            using (MemoryStream stream = new MemoryStream())
            {
                // Load a PSD file as an image and cast it into PsdImage
                using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "layers.psd"))
                {
                    PsdOptions saveOptions = new PsdOptions();
                    saveOptions.CompressionMethod = CompressionMethod.Raw;
                    psdImage.Save(stream, saveOptions);
                }

                // Now reopen the newly created image. But first seek to the beginning of stream since after saving seek is at the end now.
                stream.Seek(0, System.IO.SeekOrigin.Begin);
                using (PsdImage psdImage = (PsdImage)Image.Load(stream))
                {
                    Graphics graphics = new Graphics(psdImage);
                    // Perform graphics operations.
                }
            }
            //ExEnd:UncompressedImageStreamObject
        }
Exemple #3
0
        public static void Run()
        {
            //ExStart:CreateIndexedPSDFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Create an instance of PsdOptions and set it's properties
            var createOptions = new PsdOptions();

            createOptions.Source    = new FileCreateSource(dataDir + "Newsample_out.psd", false);
            createOptions.ColorMode = ColorModes.Indexed;
            createOptions.Version   = 5;

            // Create a new color palette having RGB colors, Set Palette property & compression method
            Color[] palette = { Color.Red, Color.Green, Color.Blue, Color.Yellow };
            createOptions.Palette           = new PsdColorPalette(palette);
            createOptions.CompressionMethod = CompressionMethod.RLE;

            // Create a new PSD with PsdOptions created previously
            using (var psd = Image.Create(createOptions, 500, 500))
            {
                // Draw some graphics over the newly created PSD
                var graphics = new Graphics(psd);
                graphics.Clear(Color.White);
                graphics.DrawEllipse(new Pen(Color.Red, 6), new Rectangle(0, 0, 400, 400));
                psd.Save();
            }

            //ExEnd:CreateIndexedPSDFiles
        }
        public static void Run()
        {
            //ExStart:AIToPSD
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AI();

            string[] sourcesFiles = new string[]
            {
                @"34992OStroke",
                @"rect2_color",
            };

            for (int i = 0; i < sourcesFiles.Length; i++)
            {
                string name           = sourcesFiles[i];
                string sourceFileName = dataDir + name + ".ai";
                string outFileName    = dataDir + name + ".psd";


                using (AiImage image = (AiImage)Image.Load(sourceFileName))
                {
                    ImageOptionsBase options = new PsdOptions();
                    image.Save(outFileName, options);
                }
            }

            //ExEnd:AIToPSD
        }
        public static void Run()
        {
            // ExStart:UncompressedImageStreamObject
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Create an instance of MemoryStream to hold the uncompressed image data.
            using (MemoryStream stream = new MemoryStream())
            {
                // First convert the image to raw PSD format.
                using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "PsdImage.psd"))
                {
                    PsdOptions saveOptions = new PsdOptions();
                    saveOptions.CompressionMethod = CompressionMethod.Raw;
                    psdImage.Save(dataDir + stream + "_out", saveOptions);
                }

                // Now reopen the newly created image.
                using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + stream + "_out"))
                {
                    Graphics graphics = new Graphics(psdImage);
                    // Perform graphics operations.
                }
            }
            // ExEnd:UncompressedImageStreamObject
        }
Exemple #6
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            //ExStart:CombiningImages

            // Create an instance of PsdOptions and set its various properties
            PsdOptions imageOptions = new PsdOptions();

            // Create an instance of FileCreateSource and assign it to Source property
            imageOptions.Source = new FileCreateSource(dataDir + "Two_images_result_out.psd", false);

            // Create an instance of Image and define canvas size
            using (var image = Image.Create(imageOptions, 600, 600))
            {
                // Create and initialize an instance of Graphics, Clear the image surface with white color and Draw Image
                var graphics = new Graphics(image);
                graphics.Clear(Color.White);
                graphics.DrawImage(Image.Load(dataDir + "example1.psd"), 0, 0, 300, 600);
                graphics.DrawImage(Image.Load(dataDir + "example2.psd"), 300, 0, 300, 600);
                image.Save();
            }


            //ExEnd:CombiningImages
        }
        public static void Run()
        {
            // ExStart:UncompressedImageStreamObject
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Create an instance of MemoryStream to hold the uncompressed image data.
            using (MemoryStream stream = new MemoryStream())
            {
                // First convert the image to raw PSD format.
                using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "PsdImage.psd"))
                {
                    PsdOptions saveOptions = new PsdOptions();
                    saveOptions.CompressionMethod = CompressionMethod.Raw;
                    psdImage.Save(dataDir + stream + "_out", saveOptions);
                }

                // Now reopen the newly created image.
                using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + stream + "_out"))
                {
                    Graphics graphics = new Graphics(psdImage);
                    // Perform graphics operations.
                }
            }
            // ExEnd:UncompressedImageStreamObject
        }
        public static void Run()
        {
            //ExStart:ExportImageToPSD
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Create a new image from scratch.
            using (BmpImage bmpImage = new BmpImage(300, 300))
            {
                // Fill image data.
                Graphics graphics = new Graphics(bmpImage);
                graphics.Clear(Color.White);
                var pen = new Pen(Color.Brown);
                graphics.DrawRectangle(pen, bmpImage.Bounds);

                // Create an instance of PsdOptions, Set it's various properties Save image to disk in PSD format
                PsdOptions psdOptions = new PsdOptions();
                psdOptions.ColorMode         = ColorModes.Rgb;
                psdOptions.CompressionMethod = CompressionMethod.Raw;
                psdOptions.Version           = 4;
                bmpImage.Save(dataDir + "ExportImageToPSD_output.psd", psdOptions);
            }

            //ExEnd:ExportImageToPSD
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:ControllCacheReallocation

            // The path to the documents directory.
            //  string dataDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            // By default the cache folder is set to the local temp directory.  You can specify a different cache folder from the default this way:
            Cache.CacheFolder = dataDir;

            // Set cache on disk.
            Cache.CacheType = CacheType.CacheOnDiskOnly;

            // The default cache max value is 0, which means that there is no upper limit
            Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
            Cache.MaxMemoryForCache    = 1073741824; // 1 gigabyte

            // We do not recommend that you change the following property because it may greatly affect performance
            Cache.ExactReallocateOnly = false;

            // At any time you can check how many bytes are currently allocated for the cache in memory or on disk By examining the following properties
            long l1 = Cache.AllocatedDiskBytesCount;
            long l2 = Cache.AllocatedMemoryBytesCount;

            PsdOptions options = new PsdOptions();

            //GifOptions options = new GifOptions();
            options.Palette = new ColorPalette(new[] { Color.Red, Color.Blue, Color.Black, Color.White });
            options.Source  = new StreamSource(new MemoryStream(), true);

            using (RasterImage image = (RasterImage)Image.Create(options, 100, 100))
            {
                Color[] pixels = new Color[10000];
                for (int i = 0; i < pixels.Length; i++)
                {
                    pixels[i] = Color.White;
                }

                image.SavePixels(image.Bounds, pixels);

                // After executing the code above 40000 bytes are allocated to disk.
                long diskBytes   = Cache.AllocatedDiskBytesCount;
                long memoryBytes = Cache.AllocatedMemoryBytesCount;
            }

            // The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed. If you've forgotten to call dispose on an object the cache values will not be 0.
            l1 = Cache.AllocatedDiskBytesCount;
            l2 = Cache.AllocatedMemoryBytesCount;

            //ExEnd:ControllCacheReallocation
        }
Exemple #10
0
        public static void Run() {

            //ExStart:PSBToPSD
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSB();

            string sourceFilePathPsb = dataDir + "2layers.psb";
            string outputFilePathPsd = dataDir +  "ConvertFromPsb.psd";
            using (Image img = Image.Load(sourceFilePathPsb))
            {
                var options = new PsdOptions((PsdImage)img) { FileFormatVersion = FileFormatVersion.Psd };
                img.Save(outputFilePathPsd, options);
            }
            //ExEnd:PSBToPSD
        }
Exemple #11
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir      = RunExamples.GetDataDir_PSD();
            string outputFolder = RunExamples.GetDataDir_Output();

            //ExStart:Saving16BitGrayscalePsdTo8BitRgb

            //The following example demonstrates that reading and saving the Grayscale 16 bit PSD files to 16bit per channel RGB works correctly and without an exception.

            string     sourceFilePath = Path.Combine(dataDir, "grayscale5x5.psd");
            string     exportFilePath = Path.Combine(outputFolder, "rgb16bit5x5.psd");
            PsdOptions psdOptions     = new PsdOptions()
            {
                ColorMode        = ColorModes.Rgb,
                ChannelBitsCount = 16,
                ChannelsCount    = 4
            };

            using (PsdImage image = (PsdImage)Image.Load(sourceFilePath))
            {
                RasterCachedImage raster   = image.Layers[0];
                Graphics          graphics = new Graphics(raster);
                int       width            = raster.Width;
                int       height           = raster.Height;
                Rectangle rect             = new Rectangle(width / 3, height / 3, width - (2 * (width / 3)) - 1, height - (2 * (height / 3)) - 1);
                graphics.DrawRectangle(new Pen(Color.DarkGray, 1), rect);
                image.Save(exportFilePath, psdOptions);
            }

            string pngExportPath = Path.ChangeExtension(exportFilePath, "png");

            using (PsdImage image = (PsdImage)Image.Load(exportFilePath))
            {
                // Here should be no exception.
                image.Save(pngExportPath, new PngOptions()
                {
                    ColorType = PngColorType.GrayscaleWithAlpha
                });
            }

            //ExEnd:Saving16BitGrayscalePsdTo8BitRgb

            Console.WriteLine("Saving16BitGrayscalePsdTo8BitRgb executed successfully");
        }
 public static void Run()
 {
     // ExStart:ExportImageToPSD
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
    
     // Load an existing image
     using (Image image = Image.Load(dataDir + "sample.bmp"))
     {
         // Create an instance of PsdOptions, Set it’s various properties Save image to disk in PSD format
         PsdOptions psdOptions = new PsdOptions();
         psdOptions.ColorMode = ColorModes.Rgb;
         psdOptions.CompressionMethod = CompressionMethod.Raw;
         psdOptions.Version = 4;
         image.Save(dataDir + "ExportImageToPSD_output.psd", psdOptions);               
     }
     // ExEnd:ExportImageToPSD
 }
Exemple #13
0
        public static void Run()
        {
            //ExStart:ExportImageToPSD
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing image
            using (Image image = Image.Load(dataDir + "sample.bmp"))
            {
                // Create an instance of PsdOptions, Set it’s various properties Save image to disk in PSD format
                PsdOptions psdOptions = new PsdOptions();
                psdOptions.ColorMode         = ColorModes.Rgb;
                psdOptions.CompressionMethod = CompressionMethod.Raw;
                psdOptions.Version           = 4;
                image.Save(dataDir + "ExportImageToPSD_output.psd", psdOptions);
            }
            //ExEnd:ExportImageToPSD
        }
Exemple #14
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:AddTextLayer
            string sourceFileName = dataDir + "OneLayer.psd";
            string outFileName    = dataDir + "OneLayerWithAddedText.psd";

            using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
            {
                image.AddTextLayer("Some text", new Rectangle(50, 50, 100, 100));
                PsdOptions options = new PsdOptions(image);
                image.Save(outFileName, options);
            }

            //ExEnd:AddTextLayer
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Output();

            //ExStart:ExportImagesinMultiThreadEnv

            string imageDataPath = dataDir + @"sample.psd";

            try
            {
                // Create the stream of the existing image file.
                using (System.IO.FileStream fileStream = System.IO.File.Create(imageDataPath))
                {
                    // Create an instance of PSD image option class.
                    using (PsdOptions psdOptions = new PsdOptions())
                    {
                        // Set the source property of the imaging option class object.
                        psdOptions.Source = new Sources.StreamSource(fileStream);

                        // DO PROCESSING.
                        // Following is the sample processing on the image. Un-comment to use it.
                        //using (RasterImage image = (RasterImage)Image.Create(psdOptions, 10, 10))
                        //{
                        //    Color[] pixels = new Color[4];
                        //    for (int i = 0; i < 4; ++i)
                        //    {
                        //        pixels[i] = Color.FromArgb(40, 30, 20, 10);
                        //    }
                        //    image.SavePixels(new Rectangle(0, 0, 2, 2), pixels);
                        //    image.Save();
                        //}
                    }
                }
            }
            finally
            {
                // Delete the file. This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
                System.IO.File.Delete(imageDataPath);
            }

            //ExEnd:ExportImagesinMultiThreadEnv
        }
Exemple #16
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:CreateLayerGroups

            string inputFile = dataDir + "ButtonTemp.psd";

            var createOptions = new PsdOptions();

            createOptions.Source  = new FileCreateSource(inputFile, false);
            createOptions.Palette = new PsdColorPalette(new Color[] { Color.Green });

            using (var psdImage = (PsdImage)Image.Create(createOptions, 500, 500))
            {
                LayerGroup group1 = psdImage.AddLayerGroup("Group 1", 0, true);

                Layer layer1 = new Layer(psdImage);
                layer1.Name = "Layer 1";
                group1.AddLayer(layer1);

                LayerGroup group2 = group1.AddLayerGroup("Group 2", 1);

                Layer layer2 = new Layer(psdImage);
                layer2.Name = "Layer 2";
                group2.AddLayer(layer2);

                Layer layer3 = new Layer(psdImage);
                layer3.Name = "Layer 3";
                group2.AddLayer(layer3);

                Layer layer4 = new Layer(psdImage);
                layer4.Name = "Layer 4";
                group1.AddLayer(layer4);

                psdImage.Save(dataDir + "LayerGroups_out.psd");
            }
            //ExEnd:CreateLayerGroups

            Console.WriteLine("CreateLayerGroups executed successfully");
        }
        public static void Run()
        {
            //ExStart:UncompressedImageUsingFile
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // First convert the image to raw PSD format.
            using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "PsdImage.psd"))
            {
                PsdOptions saveOptions = new PsdOptions();
                saveOptions.CompressionMethod = CompressionMethod.Raw;
                psdImage.Save(dataDir + "uncompressed_out.psd", saveOptions);
            }

            // Now reopen the newly created image.
            using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "uncompressed_out.psd"))
            {
                Graphics graphics = new Graphics(psdImage);
                // Perform graphics operations.
            }
            //ExEnd:UncompressedImageUsingFile
        }
        public static void Run()
        {
            // ExStart:UncompressedImageUsingFile
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // First convert the image to raw PSD format.
            using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "PsdImage.psd"))
            {
                PsdOptions saveOptions = new PsdOptions();
                saveOptions.CompressionMethod = CompressionMethod.Raw;
                psdImage.Save(dataDir + "uncompressed_out.psd", saveOptions);
            }

            // Now reopen the newly created image.
            using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "uncompressed_out.psd"))
            {
                Graphics graphics = new Graphics(psdImage);
                // Perform graphics operations.
            }
            // ExEnd:UncompressedImageUsingFile
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:CreatingbySettingPath
            string desName = dataDir + "CreatingAnImageBySettingPath_out.psd";

            // Creates an instance of PsdOptions and set its various properties
            PsdOptions psdOptions = new PsdOptions();

            psdOptions.CompressionMethod = CompressionMethod.RLE;

            // Define the source property for the instance of PsdOptions. Second boolean parameter determines if the file is temporal or not
            psdOptions.Source = new FileCreateSource(desName, false);

            // Creates an instance of Image and call Create method by passing the PsdOptions object
            using (Image image = Image.Create(psdOptions, 500, 500))
            {
                image.Save();
            }

            //ExEnd:CreatingbySettingPath
        }
Exemple #20
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir      = RunExamples.GetDataDir_PSD();
            string outputFolder = RunExamples.GetDataDir_Output();

            //ExStart:Saving16BitGrayscalePsdImage
            Stack <string> outputFilePathStack = new Stack <string>();

            //The following example demonstrates that reading and saving the Grayscale 16 bit PSD files works correctly and without an exception.
            void SaveToPsdThenLoadAndSaveToPng(
                string file,
                ColorModes colorMode,
                short channelBitsCount,
                short channelsCount,
                CompressionMethod compression,
                int layerNumber)
            {
                string     filePath   = Path.Combine(dataDir, file + ".psd");
                string     postfix    = colorMode.ToString() + channelBitsCount + "_" + channelsCount + "_" + compression;
                string     exportPath = Path.Combine(outputFolder, file + postfix + ".psd");
                PsdOptions psdOptions = new PsdOptions()
                {
                    ColorMode         = colorMode,
                    ChannelBitsCount  = channelBitsCount,
                    ChannelsCount     = channelsCount,
                    CompressionMethod = compression
                };

                using (PsdImage image = (PsdImage)Image.Load(filePath))
                {
                    RasterCachedImage raster = layerNumber >= 0 ? (RasterCachedImage)image.Layers[layerNumber] : image;

                    Graphics  graphics = new Graphics(raster);
                    int       width    = raster.Width;
                    int       height   = raster.Height;
                    Rectangle rect     = new Rectangle(
                        width / 3,
                        height / 3,
                        width - (2 * (width / 3)) - 1,
                        height - (2 * (height / 3)) - 1);
                    graphics.DrawRectangle(new Pen(Color.DarkGray, 1), rect);

                    image.Save(exportPath, psdOptions);
                }

                string pngExportPath = Path.ChangeExtension(exportPath, "png");

                using (PsdImage image = (PsdImage)Image.Load(exportPath))
                {
                    // Here should be no exception.
                    image.Save(pngExportPath, new PngOptions()
                    {
                        ColorType = PngColorType.GrayscaleWithAlpha
                    });
                }

                outputFilePathStack.Push(exportPath);
            }

            SaveToPsdThenLoadAndSaveToPng("grayscale5x5", ColorModes.Cmyk, 16, 5, CompressionMethod.RLE, 0);
            SaveToPsdThenLoadAndSaveToPng("argb16bit_5x5", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, 0);
            SaveToPsdThenLoadAndSaveToPng("argb16bit_5x5_no_layers", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, -1);
            SaveToPsdThenLoadAndSaveToPng("argb8bit_5x5", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, 0);
            SaveToPsdThenLoadAndSaveToPng("argb8bit_5x5_no_layers", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, -1);
            SaveToPsdThenLoadAndSaveToPng("cmyk16bit_5x5_no_layers", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, -1);
            SaveToPsdThenLoadAndSaveToPng("index8bit_5x5", ColorModes.Grayscale, 16, 2, CompressionMethod.RLE, -1);

            //ExEnd:Saving16BitGrayscalePsdImage

            Console.WriteLine("Saving16BitGrayscalePsdImage executed successfully");
        }
Exemple #21
0
        public static void Run()
        {
            string baseFolder = RunExamples.GetDataDir_PSD();
            string output     = RunExamples.GetDataDir_Output();

            //ExStart:ConversionPSDToGrayscaleRgbCmyk
            //ExSummary:These examples demonstrate conversion of the PSD image format to other Color Modes/BitDepth.

            string dataDir   = baseFolder;
            string outputDir = output;

            // These examples demonstrate conversion of the PSD image format to other Color Modes/BitDepth.
            ImageConversion(ColorModes.Grayscale, 16, 2);
            ImageConversion(ColorModes.Grayscale, 8, 2);
            ImageConversion(ColorModes.Grayscale, 8, 1);
            ImageConversion(ColorModes.Rgb, 8, 4);
            ImageConversion(ColorModes.Rgb, 16, 4);
            ImageConversion(ColorModes.Cmyk, 8, 5);
            ImageConversion(ColorModes.Cmyk, 16, 5);

            void ImageConversion(ColorModes colorMode, short channelBitsCount, short channelsCount)
            {
                var compression = channelBitsCount > 8 ? CompressionMethod.Raw : CompressionMethod.RLE;

                SaveToPsdThenLoadAndSaveToPng(
                    "SheetColorHighlightExample",
                    colorMode,
                    channelBitsCount,
                    channelsCount,
                    compression,
                    1);
                SaveToPsdThenLoadAndSaveToPng(
                    "FillOpacitySample",
                    colorMode,
                    channelBitsCount,
                    channelsCount,
                    compression,
                    2);
                SaveToPsdThenLoadAndSaveToPng(
                    "ClippingMaskRegular",
                    colorMode,
                    channelBitsCount,
                    channelsCount,
                    compression,
                    3);
            }

            // Saves to PSD then loads the saved file and saves to PNG.
            void SaveToPsdThenLoadAndSaveToPng(
                string file,
                ColorModes colorMode,
                short channelBitsCount,
                short channelsCount,
                CompressionMethod compression,
                int layerNumber)
            {
                string srcFile = dataDir + file + ".psd";
                string postfix = colorMode.ToString() + channelBitsCount + "bits" + channelsCount + "channels" +
                                 compression;
                string     fileName   = file + "_" + postfix + ".psd";
                string     exportPath = outputDir + fileName;
                PsdOptions psdOptions = new PsdOptions()
                {
                    ColorMode         = colorMode,
                    ChannelBitsCount  = channelBitsCount,
                    ChannelsCount     = channelsCount,
                    CompressionMethod = compression
                };

                using (var image = (PsdImage)Image.Load(srcFile))
                {
                    image.Convert(psdOptions);

                    RasterCachedImage raster = image.Layers.Length > 0 && layerNumber >= 0
                        ? (RasterCachedImage)image.Layers[layerNumber]
                        : image;
                    Graphics  graphics = new Graphics(raster);
                    int       width    = raster.Width;
                    int       height   = raster.Height;
                    Rectangle rect     = new Rectangle(
                        width / 3,
                        height / 3,
                        width - (2 * (width / 3)) - 1,
                        height - (2 * (height / 3)) - 1);
                    graphics.DrawRectangle(new Pen(Color.DarkGray, 1), rect);

                    image.Save(exportPath);
                }

                string pngExportPath = Path.ChangeExtension(exportPath, "png");

                using (PsdImage image = (PsdImage)Image.Load(exportPath))
                {
                    image.Save(pngExportPath, new PngOptions()
                    {
                        ColorType = PngColorType.TruecolorWithAlpha
                    });
                }
            }

            //ExEnd:ConversionPSDToGrayscaleRgbCmyk

            Console.WriteLine("ConversionPSDToGrayscaleRgbCmyk executed successfully");
        }
        ///<Summary>
        /// ConvertImageFormat method to convert image to different image formats
        ///</Summary>
        public Response ConvertImageFormat(string fileName, string folderName, string outputType)
        {
            if (outputType.Equals("gif") || outputType.Equals("bmp") || outputType.Equals("jpg") || outputType.Equals("png") ||
                outputType.Equals("psd") || outputType.Equals("emf") || outputType.Equals("svg") || outputType.Equals("wmf"))
            {
                ImageOptionsBase optionsBase = new BmpOptions();

                if (outputType.Equals("jpg"))
                {
                    optionsBase = new JpegOptions();
                }
                else if (outputType.Equals("png"))
                {
                    optionsBase = new PngOptions();
                }
                else if (outputType.Equals("gif"))
                {
                    optionsBase = new GifOptions();
                }
                else if (outputType.Equals("psd"))
                {
                    optionsBase = new PsdOptions();
                }
                else if (outputType.Equals("emf"))
                {
                    optionsBase = new EmfOptions();
                }
                else if (outputType.Equals("svg"))
                {
                    optionsBase = new SvgOptions();
                }
                else if (outputType.Equals("wmf"))
                {
                    optionsBase = new WmfOptions();
                }
                return(ProcessTask(fileName, folderName, "." + outputType, true, true, delegate(string inFilePath, string outPath, string zipOutFolder)
                {
                    string fileExtension = Path.GetExtension(inFilePath).ToLower();
                    if ((fileExtension == ".tif") || (fileExtension == ".tiff"))
                    {
                        string outfileName = Path.GetFileNameWithoutExtension(fileName) + "_{0}";
                        using (TiffImage multiImage = (TiffImage)Image.Load(inFilePath))
                        {
                            if (multiImage.Frames.Length > 1)
                            {
                                int frameCounter = 0;
                                // Iterate over the TiffFrames in TiffImage
                                foreach (TiffFrame tiffFrame in multiImage.Frames)
                                {
                                    multiImage.ActiveFrame = tiffFrame;
                                    // Load Pixels of TiffFrame into an array of Colors
                                    Color[] pixels = multiImage.LoadPixels(tiffFrame.Bounds);
                                    // Create an instance of JpegOptions

                                    // Set the Source of JpegOptions as FileCreateSource by specifying the location where output will be saved
                                    // Last boolean parameter denotes isTemporal
                                    outPath = zipOutFolder + "/" + outfileName;

                                    optionsBase.Source = new FileCreateSource(string.Format(outPath, frameCounter + 1) + "." + outputType, false);
                                    // Create a new RasterImage of Jpeg type
                                    using (var jpgImage = (RasterImage)Image.Create(optionsBase, tiffFrame.Width, tiffFrame.Height))
                                    {
                                        // Save the JpegImage with pixels from TiffFrame
                                        jpgImage.SavePixels(tiffFrame.Bounds, pixels);
                                        // Resize the Jpeg Image
                                        jpgImage.Resize(100, 100, ResizeType.NearestNeighbourResample);
                                        // Save the results on disk
                                        jpgImage.Save();
                                    }
                                    frameCounter++;
                                }
                            }
                            else
                            {
                                multiImage.Save(outPath, optionsBase);
                            }
                        }
                    }
                    else

                    {
                        using (Image image = Image.Load(inFilePath))
                        {
                            image.Save(outPath, optionsBase);
                        }
                    }
                }));
            }

            return(new Response
            {
                FileName = null,
                Status = "Output type not found",
                StatusCode = 500
            });
        }