【问题标题】:Imagemagick depth convertImagemagick 深度转换
【发布时间】:2018-10-04 09:31:44
【问题描述】:

有一个图像in.png。现在做下一个:

$ convert in.png -strip out.tiff     #convert to tiff
$ convert out.tiff -strip out.png    #and back
$ cmp in.png out.png
$#no output - the images has no difference - theyre same

$ identify in.png out.png
in.png PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out.png[1] PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000

现在通过eps 尝试这个。所以:

$ convert in.png -strip out2.eps        #convert to eps
$ convert out2.eps -strip out2.png      #back

而且图片不一样。

$ identify in.png out.png out2.png
in.png PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out.png[1] PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out2.png[2] PNG 300x300 300x300+0+0 8-bit sRGB 4c 321B 0.000u 0:00.009

如您所见,转换 eps -> png 会创建 8 位 png。

好奇心加 - EPS 是 16 位的!

$ identify out2.eps 
out2.eps PS 300x300 300x300+0+0 16-bit sRGB 1.42KB 0.000u 0:00.000

问题:

  • 为什么eps->png 转换会改变位深度?
  • 如何将 eps 转换为 png 以获得 16 位 png? (来自 tiff)。

编辑

经过测试的@Rachel 推荐:

$ convert out2.eps -depth 16 out3.png
$ identify out3.png 
out3.png PNG 300x300 300x300+0+0 8-bit sRGB 4c 518B 0.000u 0:00.000

又是 8 位。

我的 ImageMagick 版本:

$ convert --version
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-06-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib djvu fftw fontconfig freetype gslib gvc jng jp2 jpeg lcms ltdl lzma pangocairo png ps tiff webp wmf x xml zlib

如果有人想测试,这是我的测试图像:

最终

所以,@Mark Setchell 和@Rachel Gallen 的推荐很好。 @Marks 命令有效,所以关键是 PNG48。

$ convert out2.eps -depth 16 PNG48:out7.png
$ identify out7.png
out7.png PNG 300x300 300x300+0+0 16-bit sRGB 1.86KB 0.000u 0:00.000

终于 16位png。我会ask it in another question,为什么下一个:

$ mogrify -strip out7.png
$ identify out7.png 
out7.png PNG 300x300 300x300+0+0 8-bit sRGB 4c 321B 0.000u 0:00.000

又是 8 位。 -strip 应该只删除元数据并且应该更改图像本身。

【问题讨论】:

  • 你没有放入 PNG16: 选项

标签: image image-processing imagemagick


【解决方案1】:

我认为你需要一些类似的东西来获得 16 位 PNG

convert a.png -depth 16 PNG48:b.png

【讨论】:

  • 所以应该先转换eps->png(获取8bit)然后再从8bit png转换为16 bit png?这并不意味着eps->png 的损失?
  • 我只是在说明真正的概念,即生成 16(或 48 位)PNG。我想你可以把这些参数和开关直接放在 EPS->PNG 转换上。
  • OK - 再次测试
【解决方案2】:

我认为通过查看docs 你可以做到

   convert -depth 16 image.eps image2.png[16]

语法是

   convert [ options … ] file [file …] file

This site 表示“使用文件名后括号中的可选索引来指定所需的多分辨率图像格式的子图像,例如 Photo CD(例如 img0001.pcd[4])或 MPEG 图像的范围(例如 video.mpg[50-75])。

所以也许把 [16] 放在 image2.png 之后

【讨论】:

  • 它创建了一个文件名:PNG16:out6.png 和标识打印:PNG16:out6.png PNG 300x300 300x300+0+0 8-bit sRGB 4c 518B 0.000u 0:00.000。我的 ImageMagick 有问题吗?
  • :) 是的,一个小时尝试了很多变种,但没有得到任何好处。
  • 根据sites.google.com/site/scientificsimulation/other-software/… imagemagick 不支持 16 位 png!!!
  • hm.. 但是从 tiff 文件转换有效 - 请参阅第一个示例。
  • 好点 - 解决方案是 PNG16 需要使用 PNG48 和 @Mark 推荐。谢谢你。 ;)
猜你喜欢
  • 1970-01-01
  • 2013-07-18
  • 2015-06-29
  • 1970-01-01
  • 1970-01-01
  • 2011-11-04
  • 2011-09-10
  • 2011-10-18
  • 2011-10-18
相关资源
最近更新 更多