This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
jag12  
#1 Posted : Tuesday, September 14, 2021 8:43:23 AM(UTC)
jag12

Rank: Newbie

Groups: Guest
Joined: 9/14/2021(UTC)
Posts: 1

Code:
    private static void MergeAndResize()
    {
        int x = 400;
        int y = 100;
        using (var psdReader = new PsdReader(@"C:\Users\jrajagopalan\source\repos\PSDTestPicture\Stonefire.psd"))
        using (var resize = new Resize(x, y, ResizeInterpolationMode.High))
        using (var writer = ImageWriter.Create(@"C:\Users\jrajagopalan\source\repos\PSDTestPicture\output\BusinessCard_Resize.png"))
        {
            resize.Receivers.Add(writer);
            psdReader.MergeLayers(resize);
        }
    }


exception.PNG

Edited by moderator Tuesday, September 14, 2021 9:15:39 PM(UTC)  | Reason: Not specified

Fedor  
#2 Posted : Tuesday, September 14, 2021 9:15:24 PM(UTC)
Fedor

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 add ColorConverter to explicitly convert the image to the pixel format supported with the target PNG file format.

Code:
    private static void MergeAndResize()
    {
        int x = 400;
        int y = 100;
        using (var psdReader = new PsdReader(@"C:\Users\jrajagopalan\source\repos\PSDTestPicture\Stonefire.psd"))
        using (var converter = new ColorConverter(PixelFormat.Format32bppArgb)
        using (var resize = new Resize(x, y, ResizeInterpolationMode.High))
        using (var writer = ImageWriter.Create(@"C:\Users\jrajagopalan\source\repos\PSDTestPicture\output\BusinessCard_Resize.png"))
        {
            converter.Receivers.Add(resize);
            resize.Receivers.Add(writer);
            psdReader.MergeLayers(converter);
        }
    }


P.S. Please note, the code is untested.

Edited by user Tuesday, September 14, 2021 9:16:07 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
Guest
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.