Rank: Newbie
Groups: Guest
Joined: 12/24/2018(UTC) Posts: 7
|
Hello i have a PSD with 2 smart objects with names Design & Design2, i create the following code to change the content of smart object layers. The code replace only the smartframe with name Design2. If comment the part2 code the smartframe with name Design working. Plase any help how to resolve this problem. Code:
public static String PsdChangeSO(String filename,String Template, String filename2)
{
var customResolver = new FontResolver(@"C:\inetpub\wwwroot\Images\FontCache");
var psdProcessor = new PsdProcessor(Path.GetTempPath());
//part1
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type == FrameType.SmartObject && frame.Name == "Design")
{
var smartFrame = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename));
return smartFrame.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
}
else {
return processor.ProcessFrame(frame);
}
};
//part2
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type == FrameType.SmartObject && frame.Name == "Design2")
{
var smartFrame2 = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename2));
return smartFrame2.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
}
else {
return processor.ProcessFrame(frame);
}
};
var outputFilename = GetTimestamp(DateTime.Now);
psdProcessor.Render(@"C:\inetpub\wwwroot\Images\"+Template, @"C:\inetpub\wwwroot\Images\Output\" + outputFilename + ".png");
return outputFilename+".png";
}
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 12/24/2018(UTC) Posts: 7
|
Here another not working code Code:public static String PsdChangeSO(String filename,String Template, String filename2)
{
var customResolver = new FontResolver(@"C:\inetpub\wwwroot\Images\FontCache");
var psdProcessor = new PsdProcessor(Path.GetTempPath());
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.SmartObject || frame.Name != "Design")
return processor.ProcessFrame(frame);
var smartFrame = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename));
return smartFrame.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
};
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.SmartObject || frame.Name != "Design2")
return processor.ProcessFrame(frame);
var smartFrame = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename));
return smartFrame.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
};
var outputFilename = GetTimestamp(DateTime.Now);
psdProcessor.Render(@"C:\inetpub\wwwroot\Images\"+Template, @"C:\inetpub\wwwroot\Images\Output\" + outputFilename + ".png");
return outputFilename+".png";
}
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
You should use a single delegate for the FrameCallback callback, as it is not an event and doesn't broadcast to multiple delegates. Please note, the code is untested. Code: psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.SmartObject || (frame.Name != "Design" && frame.Name != "Design2"))
return processor.ProcessFrame(frame);
if (frame.Name == "Design")
{
var smartFrame = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename));
return smartFrame.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
}
else //Design2
{
var smartFrame = (PsdSmartFrame)frame;
var webclient = new System.Net.WebClient();
var uriimage = webclient.OpenRead(new Uri(filename));
return smartFrame.ToGraphicsContainer(new Aurigma.GraphicsMill.Bitmap(uriimage), ResizeMode.Fit);
}
};
|
Best regards, Fedor Skvortsov
|
|
|
|
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.