简体   繁体   中英

Perl - Convert MSSQL Image string to JPEG/PNG using Perl

Without having to use Image::Magick;, is there a way to output to the local file system an MSSQL Image string as a JPEG/PNG file.

The following in C# works very well, struggling to find the equivalent in Perl.

     string base64string = "/9j/4AAQSkZJRgABAQAAAQABAAD/4QB...";  # This string shortened otherwise it would not fit
       byte[] blob = Convert.FromBase64String(base64string);
       File.WriteAllBytes(@"C:\image.jpg", blob);

Thanks.

Looks like you just need decode_base64 on your string. Then write it to the file opened with > and run binmode on handler. So your data will not be corrupted by new line character conversion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM