
회색조 PNG가 있는데 ImageMagick(버전 7.1.1-28)을 사용하려고 하면ICO 파일 생성항상 다음과 같은 경고가 표시됩니다.
$ convert favicon.png -define icon:auto-resize=16,32,48,64,256 favicon.ico
convert: Cannot write image with defined png:bit-depth or png:color-type. `' @ warning/png.c/MagickPNGWarningHandler/1526.
나는 그것이 내 원본 PNG의 색상 프로파일일지도 모른다고 생각하여 ImageMagick을 사용하여 이미지를 강제로 RGB 색상 공간으로 만든 다음 해당 중간 파일에서 ICO 파일을 만들려고 시도했지만 정확한 결과를 얻었습니다. 같은 오류.
$ convert favicon.png +profile "*" -colorspace RGB ico-temp.png
$ convert ico-temp.png -define icon:auto-resize=16,32,48,64,256 favicon.ico
convert: Cannot write image with defined png:bit-depth or png:color-type. `' @ warning/png.c/MagickPNGWarningHandler/1526.
내가 여기서 뭘 잘못하고 있는 걸까요? 이 작업을 수행하기 위해 추가할 수 있는 플래그가 있습니까?
그리고 재현을 시도하려는 분들을 위해 ICO 파일로 변환되는 회색조 SVG 또는 PNG에 이 오류가 발생하는 것을 발견했습니다. 이것은 이것을 재현하기 위해 만든 SVG의 예입니다(이 소스를 사용하여 PNG로 변환하는 경우에도 작동함).
<svg xmlns="http://www.w3.org/2000/svg"
width="100mm"
height="100mm"
viewBox="0 0 100 100">
<circle cx="25" cy="75" r="20" style="fill:#ccc"/>
<circle cx="65" cy="35" r="30" style="fill:#4d4d4d"/>
</svg>
답변1
-compress none
다음 과 같이 사용할 솔루션이라고 생각합니다 .여기에 설명되어 있습니다; macOS에 ImageMagick 7.1.1-28을 설치하여 테스트했습니다.
convert favicon.png -compress none -define icon:auto-resize=16,32,48,64,256 favicon.ico
favicon.svg
귀하의 예제를 로 변환하여 그렇게 하면 문제 없이 favicon.png
깔끔하게 생성됩니다 favicon.ico
.
아래의 다른 시도.
에서 제안한대로 이것은 어떻습니까?이 답변:
convert -background transparent "favicon.png" -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "favicon.ico"
-define profile:skip=ICC
아니면 다음 과 같이 사용하라는 제안이 있을 수도 있습니다.여기에 제안됨와 함께 -background transparent
:
convert -background transparent "favicon.png" -define profile:skip=ICC -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "favicon.ico"
또는 없이 -background transparent
:
convert "favicon.png" -define profile:skip=ICC -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "favicon.ico"