Convert front panel screenshot to base64 string using LabVIEW 2018 - labview

I need to convert the screenshot of the front panel of the application into a Base64 string to post it to a web API. The block diagram is:
I used a "base64_fast_encode" utility vi from the link
https://forums.ni.com/t5/Example-Programs/Fast-Base64-Encoder-Decoder-using-LabVIEW/ta-p/3503281
Please find the encoded base64 string file from the link:
https://fil.email/WFBxwWyr
I pasted the resultant encoded base64 string in the below website:
https://codebeautify.org/base64-to-image-converter#
And I observed that it is not decoded back to image.
Please suggest if there are any other utility vis to convert to base64. If not, suggest an alternative of doing it.
Thanks in advance.

What you are missing is converting the LabVIEW image data to a more generic image format that would be understood outside of the context of LabVIEW, such as by the CodeBeautify tool. All you need to do is convert Image Data using LV Image to PNG Data.VI to PNG before you encode it.
Using the below example, if I take the base64 encoded string output and use the CodeBeautify base64-to-image-converter tool, it does show the expected image.

Related

pdf2svg leads to blurry images

I'm trying to convert a pdf figure to svg so I can edit some details with Inkscape. The problem I have is that the import changes slightly through some sort of smoothing.
In particular, this is the original figure:
And this is the figure after converting to SVG
This is the output of pdf2svg, which is exactly the same I get if I use Inkscape directly.
I attach a link where you can get both files.
https://www.dropbox.com/s/domxcc8pncyouy6/images.tar.gz?dl=0
Do you know a workaround to this issue?
Without seeing the SVG it is hard to tell for sure. However it looks like the "heat map" portion of your PDF/SVG may be a low resolution bitmap that is being enlarged in the page.
By default, SVG renderers will use interpolation when enlarging an image. This gives the image a smoothed/blurry look at large scales.
You could try locating the <image> element in your SVG and adding the attribute image-rendering="pixelated" to the <image> tag. Some browsers support that option and will scale the image using the nearest-neighbour scaling method.
Otherwise you may need to extract the image from the PDF or SVG; resample it at a higher (eg. 4x or 8x) resolution; then reinsert it back into the file.
Find the image in the SVG file (<image id="image5" .../>
Extract the Base64 encoded image from the DataURI. And decode it using a Base64 decoder.
Multiply the image resolution using an editor, cusch as Photoshop or Gimp.
Encode the file back to Base64
Update that <image> element with the new Base64.

How to convert WritableBitmap to Base64 string

In my application I am using WriteableBitmapRenderExtensions.Render() method present in WinRT XAML toolkit for rendering xaml element. After rendering the xaml control I need to send this to server in the form of Base64 string. How I can convert this WritableBitmap class in to Base64 string?
Save the WriteableBitmap to a png or jpg (there's an extension for that in the toolkit that you can probably modify to get the compressed image as byte array) to reduce the data size and then use Convert.ToBase64String() as Chris suggested to convert the bytes to Base64 string.

PDFBox : Converting to image : Quality loss when converting PDF containing scanned documents

My use case is pretty simple. I need to convert the PDFs to images.I tried using apache pdfbox and i am having some trouble in converting pdfs which contains scanned images. when i convert scanned image the image clarity is lost due to compression/scaling. So i was trying to extract the image data from the PDF and then store it. But the problem is i may get PDF files which will contain images and text in which case i would need to fallback to image conversion mode. The problem is how to differentiate between the pages/documents having only image and the ones with composite data. I was thinking i could use ProcSet defenition for this purpose but looks like it is marked as obsolete and non-reliable according to PDF specifications. Other possibility is to check all the objects linked to that page and see if it contains anything other than images. Please let me know if there is an easier way of doing this
Thanks
If your intention is convert pdf to image, It is better to use ImageMagick for that. If you use ImageMagick, there is a lot options to change the quality of the image. And converting pdf to image is pretty simple using ImageMagick.

Magick++ - Reading JPEG2000 images

I'm trying to read JPEG2000 images in Magick++ (the C++ API of ImageMagick). To read an image I use the following code:
Image img("path/to/my/image.jp2");
But when I try to do this, ImageMagick throws an Exception and doesn´t load the image.
I extract the images out of PDF files. Could it be that something´s different to normal JPEG2000 images? To extract the images I read the stream of Image objects which have a JPXDecode-filter and save them to a file.
Hope someone can help me!
ImageMagick uses a package called JasPer to handle JPEG2000's. According to the wikipedia page on OpenJpeg, JasPer does not completely support the JPEG2000 specification. I have several extrected JPEG2000 that open fine in QuickTime, but fail to decode with ImageMagick.
I have had better results using OpenJpeg to decode the the Jpeg2000. The interface is less flexible, it will convert to PNG and BMP.

xslt/xml byte array, to a image

I am getting back a image from SQL server as a byte[]. Can I use xsl transform to convert it into an actual image for a webpage? How, may I do so if this is possible?
Ok, so I got around via a recomendation by my coworker using:
return File(myImage.ImageBinary, "image/gif");
Your question is not clear. I can't see a relation between an image and an XSL transformation. Are you using an SVG image?
If you are storing something like a JPEG image, you could create an ASP.NET Handler that fetches that from DB as a byte[] and use Response.BinaryWrite method to stream that to the client.