Unable to display a specific image decoded from a Base 64 String

I’m building a ASP.NET Core program that generates images and sends them to a webpage as a base64 encoded string through a REST call. All the images are generated and pulled in without issue, except for one so far.

I have rendered one image that doesn’t seem able to be decoded despite any effort to do a encode/decode cycle with it. I’ve tried using .NET, Python, and various base64 validation websites to find if I could properly decode an encoded string made from this image and I’m at a loss to what could be happening. The image will save a .png of the result that looks correct, but any attempts to convert the bitmap into a base64 encoded string will result in a string that doesn’t seem to be able to load into an image. The string is validated to be proper base64 encoding, and the encoding process works fine in all other cases, but I’m needing to know what’s incorrect about the image that’s being rendered and why it can’t work as encoded data.

The process of rendering these images is that an original image is pulled from files and is cropped and scaled based on user parameters. The new altered file is encoded as a base64 string and sent as a result of a REST call.

private string GetResizedMapString(Map map, CanvasDisplaySettings disp)
{
    string path = GetUploadPath(map.SourceName);

    if (path != string.Empty)
    {
        Image srcImg = Image.FromFile(path);
        RectangleF[] imgSizes = GetRenderAreas(srcImg, map, disp);

        if (imgSizes != null)
        {
            Bitmap destImg = new((int)imgSizes[0].Width, (int)imgSizes[0].Height);
            using var graphics = Graphics.FromImage(destImg);
            graphics.DrawImage(srcImg, imgSizes[0], imgSizes[1], GraphicsUnit.Pixel);

            // CREATING TESTING IMAGE AND ENCODED STRING FILES:
            string testImgName = "TestImgFrom" + disp.DisplayID;
            string filePath = Path.Combine(DepoCollection, testImgName);

            String imageString = ConvertBitmapToString(destImg); // New Image String
            String imageStringPath = filePath + ".txt"; // New Encoded String File
            String imagePngPath = filePath + ".png"; // New Image File

            // Save to PNG
            destImg.Save(imagePngPath);
            graphics.Dispose();

            // Save to .txt to test the encoded string
            using (StreamWriter outputFile = new StreamWriter(imageStringPath))
            {
                outputFile.WriteLine("data:image/png;base64," + imageString);
            }
            return imageString;
        }
        else return "";
    }
}

static string ConvertBitmapToString(Bitmap bitmap)
{
    // Convert the bitmap to a byte array
    MemoryStream ms = new MemoryStream();
    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
    byte[] byteImage = ms.ToArray();

    // Convert the byte array to a base64 string
    string base64String = Convert.ToBase64String(byteImage);

    return base64String;
}

This process has been working with many other images, and the original image before scaling is able to be encoded/decoded. I’ve tried a similar process of encoding/decoding using Python, as well as loading the image into other base64 encoding software found online.

The images the program generates are way larger than the source image, so I can’t upload it here. I’m wondering why what’s happening is increasing the file size so much and if it could possibly be related.
Source Image: 1.34MB, 2200 x 2200 pixels
Rendered Image: 24.00 MB, 2998 x 2998 pixels

Here’s a Google Drive link of the rendered file: https://drive.google.com/file/d/1wxkWCEx3DyUG2yenWoEfOsi9QNEK38FK/view?usp=sharing

Thank you for any clue as to what’s happening and any suggestions of how to avoid these problems!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật