Rank: Newbie
Groups: Guest
Joined: 4/1/2019(UTC) Posts: 6
|
Hello, I have an example .psd file here. This file consists of a Smartobject with a TextLayer. How can I access and modify the text so that the formatting is preserved? https://www.xup.in/dl,21517984/test.psd/I have only found the solution to save a new text as an image. But I'm losing the formatting.
|
|
|
|
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)
|
Hi, The Smart Object layer contains another PSD file, so you should just render the PSD file recursively. Code:using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;
using System.IO;
class Program
{
static void Main(string[] args)
{
//Render the main PSD file
var mainPsdProcessor = new PsdProcessor();
mainPsdProcessor.FrameCallback = (mainProcessor, frame) =>
{
if (frame.Type != FrameType.SmartObject || frame.Name != "Surname")
return mainProcessor.ProcessFrame(frame);
//Render the PSD file contained in the Smart Object layer
using (var smartFrame = (PsdSmartFrame)frame)
using (var smartFrameInputStream = smartFrame.GetData())
using (var smartFrameOutputStream = new MemoryStream())
{
var smartFramePsdProcessor = new PsdProcessor();
smartFramePsdProcessor.StringCallback = (subProcessor, textFrame) =>
{
var textString = textFrame.GetFormattedText();
if (textFrame.Name == "Name")
textString = "Hello";
return textString;
};
smartFramePsdProcessor.Render(smartFrameInputStream, smartFrameOutputStream, new TiffSettings());
return smartFrame.ToGraphicsContainer(ImageReader.Create(smartFrameOutputStream),
ResizeMode.ImageFill);
}
};
mainPsdProcessor.Render(@"../../../Test.psd", @"../../../out.tif");
}
}
If something is unclear please let me know. Edited by user Monday, April 1, 2019 7:39:26 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
1 user thanked Fedor for this useful post.
|
|
|
Rank: Newbie
Groups: Guest
Joined: 4/1/2019(UTC) Posts: 6
|
Thank you very much. That's how it works. Unfortunately, it does not take on the "smart filter". I have another Test.psd created with a few filters. Could you test this with you? https://www.xup.in/dl,53366082/test.psd/
|
|
|
|
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)
|
Hi, Currently, we don't support Smart Filter. If this functionality is critical for you please contact us. |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 4/1/2019(UTC) Posts: 6
|
I tested effects directly at the text level. If I only use the "Drop Shadow" then it works. But as soon as I use an effect like "Inner Glow" I get an exception. smartFramePsdProcessor.Render(smartFrameInputStream, smartFrameOutputStream, new TiffSettings()); System.ArgumentNullException: Edited by user Tuesday, April 2, 2019 7:01:34 AM(UTC)
| Reason: Not specified
|
|
|
|
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)
|
We don't support the inner glow effect, but its processing should not cause an exception. Could you send us the PSD file you tested? |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 4/1/2019(UTC) Posts: 6
|
My goal is to edit the text of several text layers. Additionally, filters like "Outer Glow" and / or "Blur" should be applied directly and ONLY on the text. Then a .png is created from this one is then additionally processed completely with the filter "Blur". If no smart filters work. Then I have to replace the smart objects with TextLayer and switch the filters manually. But it should work dynamically. I have several PSD files with the same fields but they always have different positions. Is there any other solution? Edited by user Wednesday, April 3, 2019 2:03:59 AM(UTC)
| Reason: Not specified
|
|
|
|
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 can slightly modify the above code to imitate smart filters: Code: //Apply blur directly (insted of smart filter)
var bitmap = new Bitmap(smartFrameOutputStream);
bitmap.Transforms.Blur(5);
return smartFrame.ToGraphicsContainer(bitmap,
ResizeMode.ImageFill);
Here is the full code sample: Code:using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;
using System.IO;
class Program
{
static void Main(string[] args)
{
//Render the main PSD file
var mainPsdProcessor = new PsdProcessor();
mainPsdProcessor.FrameCallback = (mainProcessor, frame) =>
{
if (frame.Type != FrameType.SmartObject || frame.Name != "Surname")
return mainProcessor.ProcessFrame(frame);
//Render the PSD file contained in the Smart Object layer
using (var smartFrame = (PsdSmartFrame)frame)
using (var smartFrameInputStream = smartFrame.GetData())
using (var smartFrameOutputStream = new MemoryStream())
{
var smartFramePsdProcessor = new PsdProcessor();
smartFramePsdProcessor.StringCallback = (subProcessor, textFrame) =>
{
var textString = textFrame.GetFormattedText();
if (textFrame.Name == "Name")
textString = "Hello";
return textString;
};
smartFramePsdProcessor.Render(smartFrameInputStream, smartFrameOutputStream, new TiffSettings());
//Apply blur directly (insted of smart filter)
var bitmap = new Bitmap(smartFrameOutputStream);
bitmap.Transforms.Blur(5);
return smartFrame.ToGraphicsContainer(bitmap,
ResizeMode.ImageFill);
}
};
mainPsdProcessor.Render(@"../../../Test.psd", @"../../../out.tif");
}
}
If you need to process smart filters automatically we can consider to implement it as custom work. |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 4/1/2019(UTC) Posts: 6
|
Originally Posted by: Fedor If you need to process smart filters automatically we can consider to implement it as custom work.
Yes, it would be very nice. An automatic takeover of the filters is exactly what I need, then I could use and buy this API. When is it ready? Edited by user Friday, April 5, 2019 1:06:23 AM(UTC)
| Reason: Not specified
|
|
|
|
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)
|
Originally Posted by: Fedor An automatic takeover of the filters is exactly what I need, then I could use and buy this API. When is it ready? Please contact us at info@aurigma.com for the information. Edited by user Friday, April 5, 2019 2:36:09 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 6/13/2021(UTC) Posts: 2
Thanks: 1 times
|
Originally Posted by: Fedor Hi, The Smart Object layer contains another PSD file, so you should just render the PSD file recursively. Code:using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;
using System.IO;
class Program
{
static void Main(string[] args)
{
//Render the main PSD file
var mainPsdProcessor = new PsdProcessor();
mainPsdProcessor.FrameCallback = (mainProcessor, frame) =>
{
if (frame.Type != FrameType.SmartObject || frame.Name != "Surname")
return mainProcessor.ProcessFrame(frame);
//Render the PSD file contained in the Smart Object layer
using (var smartFrame = (PsdSmartFrame)frame)
using (var smartFrameInputStream = smartFrame.GetData())
using (var smartFrameOutputStream = new MemoryStream())
{
var smartFramePsdProcessor = new PsdProcessor();
smartFramePsdProcessor.StringCallback = (subProcessor, textFrame) =>
{
var textString = textFrame.GetFormattedText();
if (textFrame.Name == "Name")
textString = "Hello";
return textString;
};
smartFramePsdProcessor.Render(smartFrameInputStream, smartFrameOutputStream, new TiffSettings());
return smartFrame.ToGraphicsContainer(ImageReader.Create(smartFrameOutputStream),
ResizeMode.ImageFill);
}
};
mainPsdProcessor.Render(@"../../../Test.psd", @"../../../out.tif");
}
}
If something is unclear please let me know. I have this error => System.ObjectDisposedException: 'Cannot access a disposed object.
|
|
|
|
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)
|
Please submit a case regarding the problem. Don't forget to attach the PSD file you process as well as refer this post. |
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.