du0923 2012-03-19 13:18
浏览 92
已采纳

如何将保存为ascii的图像转换为二进制?

i used ftp-get function to download images from server. But by accident i used FTP_ASCII mode, so i have a problem. Images couldn't be read, there is some error.

I have no option to download images again. Anyone knows how to convert these files into binary form, or how to repair these files?

  • 写回答

2条回答 默认 最新

  • dongxiong1941 2012-03-19 13:41
    关注

    There is no guaranteed way to repair the files because of the nature of the way ASCII mode works compared to Binary mode.

    FTP ASCII mode is designed to convert line endings to the appropriate type between the source and destination operating systems. The most common conversion that is done here is (0x0a) becomes (0x0d0a) and vice versa, when transferring between *nix and Windows.

    Lets say that we are transferring some images from a Linux server to a Windows machine, and we accidentally use ASCII mode. The FTP client is looking out for any sequences in the incoming data and converting them to in the data it saves to disk. This means that anywhere in the binary data there is a 0x0a it becomes 0x0d0a in the new data. But it won't convert an existing to - this will be left intact. No problem, you might think, I'll just convert all the 0x0d0a back to 0x0a and the file will be repaired. But wait... if the existing sequences weren't converted, then they will be converted the wrong way in this new conversion pass.

    The long of the short of it is you data is irrevocably corrupted. The only 100% guaranteed way to get the correct data back is to copy them off the server again, in binary mode.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料