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

Notification

Icon
Error

Options
Go to last post Go to first unread
psdworker  
#1 Posted : Monday, April 1, 2019 1:51:44 AM(UTC)
psdworker

Rank: Newbie

Groups: Member
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.
Fedor  
#2 Posted : Monday, April 1, 2019 7:38:47 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
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
thanks 1 user thanked Fedor for this useful post.
delavarimohsen on 8/30/2021(UTC)
psdworker  
#3 Posted : Tuesday, April 2, 2019 3:03:56 AM(UTC)
psdworker

Rank: Newbie

Groups: Member
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/
Fedor  
#4 Posted : Tuesday, April 2, 2019 3:50:52 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
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
psdworker  
#5 Posted : Tuesday, April 2, 2019 4:11:05 AM(UTC)
psdworker

Rank: Newbie

Groups: Member
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

Fedor  
#6 Posted : Tuesday, April 2, 2019 8:43:58 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
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
psdworker  
#7 Posted : Wednesday, April 3, 2019 2:01:05 AM(UTC)
psdworker

Rank: Newbie

Groups: Member
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

Fedor  
#8 Posted : Thursday, April 4, 2019 9:35:19 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
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
psdworker  
#9 Posted : Friday, April 5, 2019 1:05:04 AM(UTC)
psdworker

Rank: Newbie

Groups: Member
Joined: 4/1/2019(UTC)
Posts: 6

Originally Posted by: Fedor Go to Quoted Post

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

Fedor  
#10 Posted : Friday, April 5, 2019 2:35:34 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)
Originally Posted by: Fedor Go to Quoted Post
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
delavarimohsen  
#11 Posted : Monday, August 30, 2021 6:07:35 AM(UTC)
delavarimohsen

Rank: Newbie

Groups: Member
Joined: 6/13/2021(UTC)
Posts: 2

Thanks: 1 times
Originally Posted by: Fedor Go to Quoted Post
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.
Fedor  
#12 Posted : Monday, August 30, 2021 7:47:43 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
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
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.