What is this kind of jpeg data and how can I use it as an image tag src to display it in a webpage? -- [Question Asked]

Query asked by user

I’m working in Angular trying to display some image data I’m getting from an external api. I’ve tried a few things like converting this data to a Blob to display an image but I’m not having any luck. This is what the data looks like:

ÔøΩÔøΩÔøΩÔøΩJFIFÔøΩÔøΩC\t\t\t\n\n\n\n\n\n\t\n\n\nÔøΩÔøΩ+ÔøΩÔøΩ\t\nÔøΩÔøΩÔøΩ}!1AQa”q2ÔøΩÔøΩÔøΩ#BÔøΩÔøΩRÔøΩÔøΩ$3brÔøΩ\t\n%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩÔøΩ?ÔøΩÔøΩ=ÔøΩÔøΩ[ÔøΩÔøΩ4ÔøΩ\rÔøΩjÔøΩÔøΩÔøΩUÔøΩt{ÔøΩÔøΩ|ÔøΩÔøΩÔøΩ#&@wÔøΩÔøΩZÔøΩÔøΩÔøΩÔøΩÔøΩR.ÔøΩÔøΩ.ÔøΩÔøΩ\r>ÔøΩbÔøΩÔøΩ;2\ÔøΩÔøΩ1#ÔøΩÔøΩ>ÔøΩÔøΩKYÔøΩdÔøΩÔøΩÔøΩÔøΩÔøΩ#ÔøΩ;ÔøΩÔøΩkÔøΩÔøΩY\rÔøΩÔøΩÔøΩ8e8SÔøΩÔøΩuÔøΩÔøΩJZ4ÔøΩpÔøΩÔøΩÔøΩ÷∫?ÔøΩÔøΩÔøΩÔøΩÔøΩ19ÔøΩdkrÔøΩj\rÔøΩÔøΩ÷∞ÔøΩÔøΩ”ÔøΩÔøΩ.\to\bÔøΩ‹óÔøΩÔøΩmÔøΩÔøΩ%ÔøΩ3ÔøΩiIÔøΩÔøΩÔøΩj‚ĶÔøΩÔøΩ?ÔøΩCÔøΩ&kÔøΩÔøΩdÔøΩ=ÔøΩÔøΩÔøΩÔøΩÔøΩ}“Ö@ÔøΩÔøΩÔøΩ5jÔøΩ9mÔøΩ+ÔøΩÔøΩÔøΩÔøΩÔøΩ\LmÔøΩ9ÔøΩÔøΩ~ÔøΩÔøΩlU#,W’iÔøΩÔøΩGnÔøΩD ÔøΩÔøΩ:bÔøΩÔøΩÔøΩÔøΩÔøΩLvÔøΩ’ÔøΩfiµÔøΩÔøΩÔøΩ.ckÔøΩcÔøΩÔøΩ<ÔøΩwÔøΩ$ÔøΩ!UÔøΩÔøΩ#ÔøΩÔøΩfÔøΩÔøΩ_%ÔøΩ8ÔøΩf]jÔøΩ(ÔøΩÔøΩ2ÔøΩÔøΩ\nÔøΩFÔøΩsuu br?ÔøΩMew4ÔøΩÔøΩ3ÔøΩÔøΩr=sÔøΩrÔøΩÔøΩcsÔøΩ#ÔøΩfiëÔøΩ{ÀãÔøΩÔøΩÔøΩ9<qPÔøΩÔøΩ|ÔøΩÔøΩIÔøΩOmZh7ZÔøΩÔøΩÔøΩÔøΩÊ≥ØÔøΩ)ÔøΩÔøΩdÔøΩGR~ÔøΩÔøΩ{}s<gÔøΩÔøΩÔøΩÔøΩÔøΩ+ÔøΩZ)ÔøΩÔøΩÔøΩ'÷¶ÔøΩQÔøΩ;ÔøΩ_ÔøΩÔøΩÔøΩjrÔøΩÔøΩ”ß!'ÔøΩÔøΩ[SÔøΩ/rÔøΩXÔøΩÔøΩÔøΩyÔçµI-ÔøΩ–éOÔøΩÔøΩÔøΩ◊ñÔøΩÔøΩhÔøΩ,ÔøΩÔøΩÔøΩÔøΩ=ÔøΩÔøΩ\nÔøΩ?ÔøΩÔøΩb4{ÔøΩaPÔøΩfxÔøΩÔøΩÔøΩÔøΩÔøΩ?ahÔøΩ-ÔøΩeÔøΩsÔøΩp7qÔøΩÔøΩÔøΩÔøΩ^cÔøΩ,I#ÔøΩÔøΩÔøΩÔøΩÔøΩBÔøΩÔøΩ}ÔøΩÔøΩ\\ÔøΩÔøΩ_VÔøΩzÔøΩÔøΩÔøΩ"iÔøΩÔøΩÔøΩÔøΩZcSÔøΩBT ÔøΩsÔøΩÔøΩÔøΩ}vK(ZYÔøΩÔøΩÔøΩ>ÔøΩ^ÔøΩÔøΩoÔøΩÔøΩzZÔøΩmÔøΩaÔøΩÔøΩqUÔøΩPÔøΩÔøΩrO=ÔøΩ"ÔøΩ'YÔøΩ?ÔøΩÔøΩÔøΩVÔøΩiÔøΩÔøΩ;ÔøΩÔøΩS«µsÔøΩÔøΩÔøΩÔøΩvÔøΩÔøΩÔøΩÔøΩsI</ÔøΩ9'=sUÔøΩ[X)›ÉÔøΩÔøΩkvÔøΩÔøΩ\\d7jÔøΩ”°ÔøΩvÔøΩTÔøΩÔøΩÔøΩ

Another piece of information that could be helpful is when I call the api from Postman, it displays the image correctly in the response body.

Any help is appreciated.

Thanks.

Edit:
Currently what I am doing is converting this jpeg data to a buffer, creating a blob from the buffer, using that blob to create an object url and assigning that object url to the image src. All this does is return the unable to load image icon.

const buffer = Buffer.from(image.data);
const blob = new Blob(buffer.data, { type: 'image/jpeg' });
const image = URL.createObjectURL(blob);
const imageTag = document.getElementById('fullImage');
(imageTag as HTMLImageElement).src = image;

Answer we found from sources

Thanks to the input from Mike and Joosep.P I learned that my image data was getting corrupted as it was passed back from my api. I decided to forgo calling the external api from my api and just did it from my front-end instead. Once I did that converting the blob data was easy.

this.imagingSerivce.getImage(imageId, response.server, response.token).subscribe((response2: any) => {
    const imageTag = document.getElementById('fullImage');
    const reader = new FileReader();
    reader.readAsDataURL(response2);
    reader.onloadend = () => {
        (imageTag as HTMLImageElement).src = '' + reader.result;
    };
});

Answered By – Brad K

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0


What is Angular?

Angular is an open-source, JavaScript outline written in TypeScript. Google keeps up with it, and its basic role is to foster single-page activities. As an edge, Angular enjoys clear benefits while likewise outfitting a standard design for formulators to work with. It empowers stoners to deliver huge tasks in a viable way. textures overall lift web improvement viability and execution by outfitting an agreeable construction so that formulators do n't need to continue to modify regulation from scratch. textures are efficient devices that offer formulators a large group of extra elements that can be added to programming easily.

However, is JavaScript ideal for creating single-sprinter activities that bear particularity, testability, and trend-setter efficiency? maybe not.

JavaScript is the most by and large utilized client-side prearranging language. It's composed into HTML reports to empower relations with web sprinters in endless extraordinary ways. As a genuinely simple to-learn language with inescapable help, creating current operations is appropriate.

Nowadays, we have various textures and libraries intended to give essential outcomes. As for front end web advancement, Angular addresses incalculable, while possibly not all, of the issues formulators face while utilizing JavaScript all alone.
Who we are?

We are team of software engineers in multiple domains like Programming and coding, Fundamentals of computer science, Design and architecture, Algorithms and data structures, Information analysis, Debugging software and Testing software. We are working on Systems developer and application developer. We are curious, methodical, rational, analytical, and logical. Some of us are also conventional, meaning we're conscientious and conservative.

Answer collected from stackoverflow and other sources, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0