Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
service-it-01  
#1 Posted : Thursday, May 31, 2018 6:24:50 AM(UTC)
service-it-01

Rank: Newbie

Groups: Member
Joined: 4/15/2018(UTC)
Posts: 9

Thanks: 1 times
Hello,

like the subject explain it, when I Render a PSD template, the position of elements in result (in jpg) are a little bit different than the original.
I join my code and also original and render.

Do you have any idea why ?

Original
Forum_original.jpg

Render
Forum_render.jpg

Code:

            //Create a font fetcher and specify a local folder to download fonts to.
            var fontResolver = new FontResolver(@"Fonts");

            //Set font source for the fetcher.
            //Add a local font source.
            fontResolver.AddSource(new FileSystemSource(@"C:\tmp\PSD\Fonts"));

            var psdProcessorFont = new PsdProcessor(fontResolver);

            var missingFonts = psdProcessorFont.GetMissingFonts(file);

            if (missingFonts.Count() > 0)
            {
                Console.WriteLine("The following fonts are not found in the given font sources: ");

                foreach (var font in missingFonts)
                    Console.WriteLine("  {0}", font);
            }
            else
            {
            }



            var psdProcessor = new PsdProcessor(fontResolver);

             psdProcessor.TextCallback = (processor, textFrame, textstring) =>
            {
                var text = processor.ProcessText(textFrame);
                try
                {
                    if (textFrame.Name == "CustomerName")
                    {
                        text.String = "<p><span>Cher David,</span></p>";
                    }

                    return text;
                }
                catch
                {
                    return text;
                }
            };
            psdProcessor.Render(file, file.Replace(".psd",".jpg"));
Eugene Kosmin  
#2 Posted : Sunday, June 3, 2018 7:04:08 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 9/19/2006(UTC)
Posts: 505

Was thanked: 41 time(s) in 41 post(s)
Hi David,

GM rendering result will always be a little bit different because we have different rendering engines. Sometimes we are pretty close to original, sometimes not. It also depends on features used for text formatting. Sometimes we have different math maybe, sometimes, we don't have the support of all necessary features.

It's hard to say for sure regarding your image without seeing the original PSD. I see different image dimensions of the source and produced images, and it seems to me strange.

Photoshop stores a rendered copy of each frame along with meta information. So you can change the text of frames with a placeholder, and keep all other frames untouched.

Try to add a FrameCallback handler to your code:

Code:
psdProcessor.FrameCallback = (procesor, frame) =>
{
    if (frame.Name == "CustomerName")
        return procesor.ProcessFrame(frame);

    var gc = new GraphicsContainer(frame);
    using (var gr = gc.GetGraphics())
    {
        // Frame raster data comes directly from PSD.
        gr.DrawImage(frame, frame.X, frame.Y);
    }

    return gc;
};
Best regards,
Eugene Kosmin
The Aurigma Development Team
service-it-01  
#3 Posted : Wednesday, June 6, 2018 2:29:43 AM(UTC)
service-it-01

Rank: Newbie

Groups: Member
Joined: 4/15/2018(UTC)
Posts: 9

Thanks: 1 times
Originally Posted by: Eugene Kosmin Go to Quoted Post
Hi David,

GM rendering result will always be a little bit different because we have different rendering engines. Sometimes we are pretty close to original, sometimes not. It also depends on features used for text formatting. Sometimes we have different math maybe, sometimes, we don't have the support of all necessary features.

It's hard to say for sure regarding your image without seeing the original PSD. I see different image dimensions of the source and produced images, and it seems to me strange.

Photoshop stores a rendered copy of each frame along with meta information. So you can change the text of frames with a placeholder, and keep all other frames untouched.

Try to add a FrameCallback handler to your code:

Code:
psdProcessor.FrameCallback = (procesor, frame) =>
{
    if (frame.Name == "CustomerName")
        return procesor.ProcessFrame(frame);

    var gc = new GraphicsContainer(frame);
    using (var gr = gc.GetGraphics())
    {
        // Frame raster data comes directly from PSD.
        gr.DrawImage(frame, frame.X, frame.Y);
    }

    return gc;
};


Hello Eugene,

Thank you for your feed back. I have try your code but it doesn't work on my computer.

var gc = new GraphicsContainer(frame);

GraphicsContainer is not recognized and I had the "using Aurigma.GrpahicsMill"

Do you have any idea ?

Thank you
Eugene Kosmin  
#4 Posted : Wednesday, June 6, 2018 4:24:14 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 9/19/2006(UTC)
Posts: 505

Was thanked: 41 time(s) in 41 post(s)
That's OK. PsdProcessor uses GraphicsMill under the hood, so in some cases, you need to add the appropriate using statement.
Do you experience any problems after adding using Aurigma.GraphicsMill?
Best regards,
Eugene Kosmin
The Aurigma Development Team
service-it-01  
#5 Posted : Tuesday, June 12, 2018 2:34:17 AM(UTC)
service-it-01

Rank: Newbie

Groups: Member
Joined: 4/15/2018(UTC)
Posts: 9

Thanks: 1 times
Originally Posted by: Eugene Kosmin Go to Quoted Post
That's OK. PsdProcessor uses GraphicsMill under the hood, so in some cases, you need to add the appropriate using statement.
Do you experience any problems after adding using Aurigma.GraphicsMill?


using Aurigma.GraphicsMill was already there but it's "grey"

Just found it, it's using Aurigma.GraphicsMill.AdvancedDrawing that had to be added :)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.