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 依据报错在原代吗格式的基础上解决问题
  • ¥15 在虚拟机中安装flash code
  • ¥15 单片机stm32f10x编写光敏电阻调节3.3伏大功率灯亮度(光强越大灯越暗,白天正常光强灯不亮,使用ADC,PWM等模块)望各位找一下错误或者提供一个可实现功能的代码
  • ¥20 verilog状态机方法流水灯
  • ¥15 pandas代码实现不了意图
  • ¥15 GD32H7 从存储器到外设SPI传输数据无法重复启用DMA
  • ¥25 LT码在高斯信道下的误码率仿真
  • ¥45 渲染完成之后将物体的材质贴图改变,自动化进行这个操作
  • ¥15 yolov5目标检测并显示目标出现的时间或视频帧
  • ¥15 电视版的优酷可以设置电影连续播放吗?