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? 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);
};
|
|
|
|
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
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 10/27/2022(UTC) Posts: 8
Thanks: 4 times
|
|
|
|
|
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
|
|
|
|
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.