两个相同的PNG,其中一个已损坏 [英] Two identical PNGs, one is corrupt

查看:106
本文介绍了两个相同的PNG,其中一个已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个PNG文件,已从Angular前端上传到django REST服务器.大约99.9%的上传图片效果良好;您可以在管理员中查看它们并下载它们.

I have this PNG file, uploaded to a django REST server from an Angular front-end. About 99.9% of uploaded images work fine; you can view them in admin and download them.

但是偶尔我会得到这些损坏的PNG图像.如果将图像URL放在地址栏中,则可以看到该图像,但是在django admin上看不到它,也无法通过右键单击>保存来下载它.

But every once in a while, I get these corrupt PNG images. You can see the image if you put the image URL in the address bar but you can't see it on django admin and you can't download it through right click>save.

我将图像上传并下载到了Imgur,现在看来可以正常工作.将其放在Django开发服务器的媒体目录中后,可以右键单击图像URL下载它.

I uploaded and downloaded the image to Imgur and now it seems to be working. When I put it in the media directory of the Django development server, I can download it with the right click at the image URL.

但是它似乎与原始文件相同!

  • 与diff一无所获
  • 文件大小相同
  • 两个文件似乎都没有打开(已通过lsof检查)
  • I get nothing with a diff
  • File sizes are the same
  • Neither of the files seem to be open (checked with lsof)

我没办法了.我将这两个版本的图片都上传到了我的Google驱动器,并检查了是否下载了图片,但其中一个似乎仍然损坏.也许有人可以弄清楚这些文件之间的区别是什么.

I'm out of options. I uploaded both versions of the images to my google drive and checked that if you download the images, corrupt one still seems to be corrupt. Maybe somebody can figure out what the difference between these files is.

损坏的图像

保存并固定的图像

经过反复试验,我将问题缩小为文件名.显然,某些文件名给出了错误,但我不知道为什么.这是一个有效且无效的文件名列表:

After some trial and error, I narrowed down the problem to the file name. Apparently, some filenames give errors but I have no idea why. Here's a list of filenames that work and don't work:

a-a14.png # Works
a-a10.png # Works
a-010.png # Works
a-ad0.png # Doesn't work
a-ad4.png # Doesn't work

因此,如果第二,第三和第四个字符为-ad,则似乎无法加载文件.

So it seems like if the second, third and fourth characters are -ad, the file can't be loaded.

推荐答案

问题归结为文件名.显然,如果文件名与regexp /.*-ad[0-9].png/相匹配,则不会加载该文件.问题在django和nginx服务文件上仍然存在.

The problem boils down to file name. Apparently if the file name matches the regexp /.*-ad[0-9].png/, it is not loaded. Problem persists both on django and nginx serving files.

我为此打开了一个新问题:

I opened a new question for this: Images that fit the regexp `/.*-ad[0-9]\.png/` can not be loaded in any browser?

这篇关于两个相同的PNG,其中一个已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆