简体   繁体   English

如何将八位字节流转换为图像

[英]How to convert octet-stream to images

I have a bunch of files in.ikc format:我有一堆 .ikc 格式的文件:

File Type: data MIME;文件类型:数据 MIME;

Type: application/octet-stream;类型:应用程序/八位字节流;

Suggested file extension(s): bin lha lzh exe class so dll img iso.建议的文件扩展名:bin lha lzh exe class so dll img iso.

They should have been svg images, supposedly, but I couldn't find an online converter that worked.据推测,它们应该是 svg 张图像,但我找不到有效的在线转换器。 Is there a way to convert octet-stream to svg or png images?有没有办法将八位字节流转换为 svg 或 png 图像?

Aside from online converters, I tried:除了在线转换器,我还尝试过:

(async () => {
  const res = await fetch('https://httpbin.org/image/png')
  const blob = await res.blob()
  const img = new Image()
  img.src = URL.createObjectURL(blob)

  // newer promise based version of img.onload
  await img.decode()
  
  document.body.append(img)

  // Don't forget to revoke the blob url when 
  // you no longer need it (to release memory)
  URL.revokeObjectURL(img.src)
})()

Nothing happened, but I don't know how to adapt this better to my case.什么都没发生,但我不知道如何更好地适应我的情况。

First few lines of one of my files:我的一个文件的前几行:

J�@^)T����
��;�\�E$��,SwU�KI
�x���j�4�.�V�   �
_�ؑiY�=l����<�M7l�Xq�f�~�x�@ɷ���|>���=UO#$nr����V38GQK��p

Used tomeko.net to convert the file to hexadecimal使用tomeko.net将文件转换为十六进制

0x4A, 0xEB, 0x13, 0x00, 0x40, 0x5E, 0x29, 0x1E, 0x54, 0xF6, 0xF6, 0xC0, 0xC2, 0x0F, 0x0A, 0xFB, 
0x90, 0x3B, 0xDB, 0x5C, 0xB9, 0x45, 0x24, 0x8A, 0xDA, 0x0B, 0x2C, 0x53, 0x77, 0x55, 0xBD, 0x4B, 
0x49, 0x7F, 0x0A, 0xC7, 0x1F, 0x78, 0x96, 0xFD, 0xFA, 0x6A, 0xA5, 0x34, 0x8C, 0x2E, 0x9C, 0x0C, 
0x56, 0x9D, 0x09, 0xB4, 0x0A, 0x5F, 0xE9, 0xD8, 0x91, 0x69, 0x59, 0xBB, 0x3D, 0x6C, 0xB2, 0x80, 

Does anyone know what to do with this?有谁知道该怎么办?

You don't have to fetch the source and convert it yourself, you can use the Image API regularly:您不必自己获取源代码并进行转换,您可以定期使用图像 API:

 const image = new Image(); image.src = "https://httpbin.org/image/png"; image.decode().then(() => { document.body.append(image); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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