We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PSD smartFilter

Smart filters are not saved when updating text. But if you open the PSD and save the smart object yourself, then all filters start working again

@Hacls Could you please provide a code sample with the test file(s). We will check this and then will be created an issue.

Снимок.PNG (6.0 KB)
This is what the original text looks like.
Снимок2.PNG (12.2 KB)
This is what it looks like after saving
Сни2мок.PNG (885 Bytes)
The letter L becomes a curve after saving. Even though I don’t change it
If the text is not changed, but change the picture and save. The text will still be distorted

private void button3_Click(object sender, EventArgs e)
{
//путь к исхожнику фш
string sourceFilePath = @“F:\тестим c#\TestPSDWF\123.psd”;
//Имя для сохранения в псд
string outputFilePath = “1_output2.psd”;
//Имя для сохранения в пнг
string outputPngFilePath = Path.ChangeExtension(outputFilePath, “.jpg”);
//Хуй пойми что
PsdLoadOptions options = new PsdLoadOptions() { LoadEffectsResource = true };
//Открываем исходник
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath))
{

            //Количество слоёв
            var length = image.Layers.Length;
            //Проходим по слоям
            for (int i = 0; i < length; i++)
            {
                var smart = image.Layers[i] as SmartObjectLayer;
                //Находим нужный смарт
                if (smart != null && smart.Name == "Text")
                {
                    //Захоидм в нешл
                    using (var stream = new MemoryStream(smart.Contents))
                    {
                        stream.Position = 0;
                        //Загружаем смарт
                        using (var imageInSmart = (PsdImage)Image.Load(stream))
                        {
                            //Ищем фотку в смарте
                            var layerToReplace = (Image)FindLayer("133", imageInSmart);
                            //Открываем новую фотку которую хотим вставить
                            using (Stream streamss = new FileStream(@"F:\тестим c#\TestPSDWF\MINISTRY OF INTERNAL AFFAIRS.png", FileMode.Open))
                            {
                                //Делаем новую фотку слоем
                                var newLayer = new Layer(streamss);
                                //Старую фотку вносим в графику для изменения
                                var graphic = new Graphics(layerToReplace);
                                //Удаляем старый рисунов
                                graphic.Clear(Color.Empty);
                                //Вставляем новые по размерам как старый
                                graphic.DrawImage(newLayer, new Rectangle(new Point(), new Size(layerToReplace.Width, layerToReplace.Height)));
                                //Сохраняем изменения в смарте
                                smart.ReplaceContents(imageInSmart);
                            }
                        }
                    }
                }
                if (smart != null && smart.Name == "Text")
                {
                    using (var stream = new MemoryStream(smart.Contents))
                    {
                        stream.Position = 0;
                        using (var imageInSmart = (PsdImage)Image.Load(stream))
                        {

                            var TextPhotoshop = (TextLayer)FindLayer("Name", imageInSmart);
                            TextPhotoshop.UpdateText("PECHAN");
                            TextPhotoshop = (TextLayer)FindLayer("LastName", imageInSmart);
                            TextPhotoshop.UpdateText("PECHAN");

                            smart.ReplaceContents(imageInSmart);
                        }
                    }
                    GaussianBlurSmartFilter gaussianBlur = (GaussianBlurSmartFilter)smart.SmartFilters.Filters[4];
                    // update filter values
                    gaussianBlur.Radius = 2;
                    gaussianBlur.Opacity = 2;
                    gaussianBlur.IsEnabled = true;

                    // add new filter items
                    var filters = new List<SmartFilter>(smart.SmartFilters.Filters);
                    filters.Add(new GaussianBlurSmartFilter());

                    // apply changes
                    smart.SmartFilters.UpdateResourceValues();
                    smart.SmartFilters.Filters[0].Apply(image.Layers[2]);
                }
            }

            var TextBezSmart = (TextLayer)FindLayer("Namess", image);
            TextBezSmart.UpdateText("PECHAN");

            var layerToReplaces = (Image)FindLayer("Photo (edit)", image);
            //Открываем новую фотку которую хотим вставить
            using (Stream streamss = new FileStream(@"F:\тестим c#\TestPSDWF\fewfewf.png", FileMode.Open))
            {
                //Делаем новую фотку слоем
                var newLayer = new Layer(streamss);
                //Старую фотку вносим в графику для изменения
                var graphic = new Graphics(layerToReplaces);
                //Удаляем старый рисунов
                graphic.Clear(Color.Empty);
                //Вставляем новые по размерам как старый
                graphic.DrawImage(newLayer, new Rectangle(new Point(), new Size(layerToReplaces.Width, layerToReplaces.Height)));
            }


            //Сохранить как псд
            image.Save(outputFilePath, new PsdOptions(image));
            //Сохранить как пнг
            image.Save(outputPngFilePath, new JpegOptions());
        }
    }

Are you here ?

@Hacls Could you please provide file “F:\тестим c#\TestPSDWF\123.psd”. Also, could you please provide the code of the FindLayer method, in the case if it has issues.

This code is used for the opening of psd files with the specific options. You should use it if your file has the layer effects

PsdLoadOptions options = new PsdLoadOptions() { LoadEffectsResource = true };

How it should be used:

using (PsdImage image = (PsdImage)Image.Load(sourceFilePath, options))