简体   繁体   English

png文件iOS罕见

[英]Uncommon png file iOS display

In this post , i was wondering why my png files were badly displayed on retina displays. 这篇文章中 ,我想知道为什么我的png文件无法在视网膜显示器上正确显示。

I finaly found that the problem came from the PNG file itself: when I open it and save it again with photoshop or something else, the problem disapear. 我最终发现问题出在PNG文件本身:当我打开它并再次用Photoshop或其他东西保存时,问题消失了。

As this post proposed, I used sips command to see what exactly were formed my PNG file. 正如这篇文章所建议的,我使用sips命令来查看我的PNG文件的确切格式。 I have the original-image.png (with the glitch) and the photoshoped-image.png 我有original-image.png (有毛刺)和photoshoped-image.png

The command 命令

sips original-image.png -g all

Gives me 给我

  pixelWidth: 256
  pixelHeight: 256
  typeIdentifier: public.png
  format: png
  formatOptions: default
  dpiWidth: 72.000
  dpiHeight: 72.000
  samplesPerPixel: 3
  bitsPerSample: 8
  hasAlpha: no
  space: RGB

And

sips photoshoped-image.png -g all

Gives me 给我

  pixelWidth: 256
  pixelHeight: 256
  typeIdentifier: public.png
  format: png
  formatOptions: default
  dpiWidth: 72.000
  dpiHeight: 72.000
  samplesPerPixel: 4
  bitsPerSample: 8
  hasAlpha: yes
  space: RGB
  profile: HD 709-A

So 3 differences : 所以有3个差异:

  • samplePerPixel samplePerPixel
  • hasAlpha hasAlpha
  • the photoshoped file has a profile. Photoshop文件具有配置文件。

But these properies are read-only in sips and I wonder how can I change them to understand exactly where the bug comes from. 但是这些属性在sip中是只读的,我想知道如何更改它们以准确了解错误的来源。

Any idea ? 任何想法 ?

So using sips you can output a different file. 因此,使用Sip可以输出其他文件。 Take the photoshop file and start modifying it. 取得photoshop文件并开始对其进行修改。 First remove the profile, then remove the alpa channel (which will affect the first two variables). 首先删除配置文件,然后删除Alpa通道(这将影响前两个变量)。

Its quite possible that this image works. 该图像很有可能起作用。 PNG has many options, and the original image may have some other feature not visible using these tools. PNG有许多选项,原始图像可能具有使用这些工具不可见的其他功能。 Photoshop is obviously re-writing the image completely, using the RGB values as the only common attribute between the files. Photoshop显然使用RGB值作为文件之间的唯一通用属性来完全重写图像。

I suspect that when you do the above, that image will work too. 我怀疑当您执行上述操作时,该图像也会起作用。 There is just something odd about the originals. 原始作品有些奇怪。

In any case, you make it easier on iOS if you use pngs with an alpha channel, as it will convert them to have one if the base image does not have one. 无论如何,如果您将png与alpha通道一起使用,则可以在iOS上更轻松,因为如果基础图像没有png,它将把它们转换为png。

On some files, this works: 在某些文件上,这可行:

sips -s format png '/Volumes/HD/Optimized PNG/TXT - Section Depth copy.png' --out '/Volumes/HD/Optimized PNG/TXT - Section Depth copy-.PNG' /Volumes/HD/Optimized PNG/TXT - Section Depth copy.png /Volumes/HD/Optimized PNG/TXT - Section Depth copy-.PNG mis-bhayward61p-swk:~ zav$ sips -s format png'/ Volumes / HD / Optimized PNG / TXT-Section Depth copy.png'--out'/ Volumes / HD / Optimized PNG / TXT-Section Depth copy-.PNG'/ Volumes / HD / Optimized PNG / TXT-Section Depth copy.png /卷/高清/优化的PNG / TXT-Section Depth copy-.PNG mis-bhayward61p-swk:〜zav $

But also, sometimes it doesn't: 但是,有时却没有:

sips -s format png --setProperty hasAlpha 0 '/Volumes/HD/Optimized PNG/Subsection copy 2/Section Depth Text.png' --out '/Volumes/HD/Optimized PNG/Subsection copy 2/Section Depth Text-.PNG' /Volumes/HD/Optimized PNG/Subsection copy 2/Section Depth Text.png Error: Cannot do --setProperty hasAlpha on file /Volumes/HD/Optimized PNG/Subsection copy 2/Section Depth Text-.PNG mis-bhayward61p-swk:~ zav$ sips -s格式png --setProperty hasAlpha 0'/卷/ HD /优化的PNG /小节副本2 / Section Depth Text.png'--out'/卷/ HD /优化的PNG /小节副本2 / Section Depth Text-。 PNG'/卷/ HD /优化的PNG /分段复制2 / Section Depth Text.png错误:不能--setProperty hasAlpha在文件/ Volumes / HD /优化的PNG /分段复制2 /分段深度Text-.PNG mis-bhayward61p -swk:〜zav $

Hope this gets you a little farther. 希望这能使您走得更远。

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

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