This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
JoshSmith  
#1 Posted : Friday, June 2, 2023 10:02:51 PM(UTC)
JoshSmith

Rank: Newbie

Groups: Guest
Joined: 10/27/2022(UTC)
Posts: 8

Thanks: 4 times
I'm having issues replacing an image layer in my PSD. When I replace the image using a local file path the PNG renders great and looks great on my PSD file. When I stream that same PNG file to a MemoryStream, the result is that the first maybe 10% of image renders at the top, and the bottom 90% does not appear on the PSD finished render. Here is my code. The reason for loading to MemoryStream is to pull the file from an online source and not have to save it locally. I've checked the length of the MemoryStream and it is the correct length right before the render. Is there a known issue with using PNG images in a stream in the Create method?

LogoChallengerLL.png

2023-06-03_00-01-01.png

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

                if (preparedLogoStream != null)
                {
                    if (frame.Name == "Logo")
                    {
                        var psdFrame = (PsdFrame)frame;

                        preparedLogoStream.Seek(0, SeekOrigin.Begin);
                        return psdFrame.ToGraphicsContainer(ImageReader.Create(preparedLogoStream), ResizeMode.ImageFill);
                    }
                }

                return processor.ProcessFrame(frame);
            };
Eugene Kosmin  
#2 Posted : Monday, June 5, 2023 4:30:03 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Guest
Joined: 9/19/2006(UTC)
Posts: 505

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

No, there is no known issue with PNG reader. Could you post here your PSD file?

Best regards,

Eugene Kosmin

The Aurigma Development Team

JoshSmith  
#3 Posted : Tuesday, June 6, 2023 6:33:02 AM(UTC)
JoshSmith

Rank: Newbie

Groups: Guest
Joined: 10/27/2022(UTC)
Posts: 8

Thanks: 4 times
2022-23_GREY_TraderCardBack.zip (3,861kb) downloaded 1 time(s).

Here is the PSD, I had to zip it.

Eugene Kosmin  
#4 Posted : Tuesday, June 6, 2023 7:30:25 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Guest
Joined: 9/19/2006(UTC)
Posts: 505

Was thanked: 41 time(s) in 41 post(s)
I’ve tried to run the code several times, and the result seems to be fine. Maybe the problem is with logo’s Image Reader which can be disposed by GC before actual work in the native code is completed.

Please try to run this code:

Code:
for (int i = 0; i < 20; i++)
{
string file = "2022-23_GREY_TraderCardBack.psd";
string outPath = $"2022-23_GREY_TraderCardBack_{i}.png";

string logoPath = "LogoChallengerLL.png";

var psdProcessor = new PsdProcessor("Fonts");
psdProcessor.FontResolver.AddSource(new FileSystemSource("temp\fonts"));

using (var preparedLogoStream = new System.IO.MemoryStream())
using (var fs = new FileStream(logoPath, FileMode.Open))                
{
    fs.CopyTo(preparedLogoStream);
    preparedLogoStream.Seek(0, SeekOrigin.Begin);

    using (var logoReader = ImageReader.Create(preparedLogoStream))
    {
        psdProcessor.FrameCallback = (processor, frame) =>
        {
            if (frame.Type != FrameType.Raster)
                return processor.ProcessFrame(frame);

            if (preparedLogoStream != null)
            {
                if (frame.Name == "Logo")
                {
                    var psdFrame = (PsdFrame)frame;

                    return psdFrame.ToGraphicsContainer(logoReader, ResizeMode.ImageFill);
                }
            }

            return processor.ProcessFrame(frame);
        };

        psdProcessor.Render(file, outPath);
    }
}
}
Best regards,

Eugene Kosmin

The Aurigma Development Team

Users browsing this topic
Guest
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.