Example #1
0
        /// <summary>
             /// Updates text and shape color of PSD image and saves to PDF file
             /// </summary>
        private static void UpdateTextAndShapeColor()
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.TextCallback = (processor, textFrame, textString) =>
            {
                var text = processor.ProcessText(textFrame);
                text.String = textString;

                text.Brush = new SolidBrush(RgbColor.DarkRed);

                return(text);
            };

            psdProcessor.FrameCallback = (processor, frame) =>
            {
                if (frame.Type != FrameType.Shape)
                {
                    return(processor.ProcessFrame(frame));
                }

                var shapeFrame = (PsdShapeFrame)frame;

                var graphicsContainer = new GraphicsContainer(frame.X + frame.Width, frame.Y + frame.Height, frame.DpiX, frame.DpiY);

                using (var graphics = graphicsContainer.GetGraphics())
                {
                    graphics.FillPath(new SolidBrush(RgbColor.DarkGreen), shapeFrame.VectorMask);
                }

                return(graphicsContainer);
            };

            psdProcessor.Render(@"../../../../_Input/idtestback.psd", @"../../../../_Output/UpdateTextAndShapeColor.pdf");
        }
Example #2
0
        /// <summary>
             /// Updates text layer of PSD image and saves to PDF file
             /// </summary>
        private static void UpdateText(string str)
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.StringCallback = (processor, textFrame) =>
            {
                var textString = textFrame.GetFormattedText();

                if (textFrame.Name == "Name")
                {
                    textString = str;
                }

                return(textString);
            };

            psdProcessor.Render(@"../../../../_Input/idtestfront.psd", @"../../../../_Output/UpdateText.png");
        }
Example #3
0
    /// <summary>
    /// Updates text layer of PSD image and saves to PDF file
    /// </summary>
    private static void UpdateText()
    {
        var psdProcessor = new PsdProcessor();

        psdProcessor.StringCallback = (processor, textFrame) =>
        {
            var textString = textFrame.GetFormattedText();

            if (textFrame.Name == "Name")
            {
                textString = "Type your name";
            }

            return(textString);
        };

        psdProcessor.Render(@"../../../../_Input/BusinessCard.psd", @"../../../../_Output/UpdateText.pdf");
    }
Example #4
0
        /// <summary>
             /// Inverts background layer of PSD image and saves to PDF file
             /// </summary>
        private static void InvertBackground()
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.FrameCallback = (processor, frame) =>
            {
                if (frame.Type != FrameType.Raster)
                {
                    return(processor.ProcessFrame(frame));
                }

                using (var invert = new Invert())
                {
                    return(frame.ToGraphicsContainer(frame + invert, ResizeMode.ImageFill));
                }
            };

            psdProcessor.Render(@"../../../../_Input/idtestfront.psd", @"../../../../_Output/InvertBackground.pdf");
        }
Example #5
0
        /// <summary>
             /// Updates text color of PSD image and saves to PDF file
             /// </summary>
        private static void UpdateTextColor()
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.TextCallback = (processor, textFrame, textString) =>
            {
                var text = processor.ProcessText(textFrame);
                text.String = textString;

                if (textFrame.Name == "Name")
                {
                    text.Brush = new SolidBrush(RgbColor.Red);
                }

                return(text);
            };

            psdProcessor.Render(@"../../../../_Input/idtestfront.psd", @"../../../../_Output/UpdateTextColor.pdf");
        }
Example #6
0
    /// <summary>
    /// Creates 3D Preview of a customized mug using Adobe Photoshop's SmartObject
    /// http://www.graphicsmill.com/blog/2015/11/25/Creation-3D-preview-of-personalized-products
    /// </summary>
    private static void RenderMugPreview()
    {
        var psdProcessor = new PsdProcessor();

        psdProcessor.FrameCallback = (processor, frame) =>
        {
            if (frame.Type != FrameType.SmartObject || frame.Name != "Design")
            {
                return(processor.ProcessFrame(frame));
            }

            var smartFrame = (PsdSmartFrame)frame;

            return(smartFrame.ToGraphicsContainer(ImageReader.Create(@"../../../../_Input/Copenhagen_RGB.jpg"),
                                                  ResizeMode.ImageFill));
        };

        psdProcessor.Render(@"../../../../_Input/Mug.psd", @"../../../../_Output/RenderMugPreview.png");
    }
Example #7
0
        /// <summary>
             /// Replaces background image of PSD image and saves to PDF file
             /// </summary>
        private static void ReplaceBackground()
        {
            PsdProcessor psdProcessor = new PsdProcessor();

            psdProcessor.FrameCallback = (processor, frame) =>
            {
                if (frame.Type != FrameType.Raster)
                {
                    return(processor.ProcessFrame(frame));
                }

                using (var background = ImageReader.Create(@"../../../../_Input/Venice.jpg"))
                {
                    background.CloseOnDispose = false;

                    return(frame.ToGraphicsContainer(background, ResizeMode.ImageFill));
                }
            };

            psdProcessor.Render(@"../../../../_Input/idtestfront.psd", @"../../../../_Output/ReplaceBackground.pdf");
        }
Example #8
0
        /// <summary>
             /// Merges PSD image to TIFF file
             /// </summary>
        private static void MergeLayers()
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.Render(@"../../../../_Input/idtestfront.psd", @"../../../../_Output/MergeLayers.tif");
        }
Example #9
0
        /// <summary>
             ///  Merges PSD image with vector shape layers to PDF file
             /// </summary>
        private static void MergeSeal()
        {
            var psdProcessor = new PsdProcessor();

            psdProcessor.Render(@"../../../../_Input/idtestback.psd", @"../../../../_Output/MergeSeal.pdf");
        }