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

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: Member
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: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,654

Thanks: 5 times
Was thanked: 75 time(s) in 73 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
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.

New server