libpng 경고 : iCCP : 알려진 잘못된 sRGB 프로파일
SDL을 사용하여 PNG 이미지를로드하려고하는데 프로그램이 작동하지 않고이 오류가 콘솔에 나타납니다.
libpng 경고 : iCCP : 알려진 잘못된 sRGB 프로파일
이 경고가 나타나는 이유는 무엇입니까? 이 문제를 해결하려면 어떻게해야합니까?
Libpng-1.6은 이전 버전보다 ICC 프로파일을 확인하는 데 더 엄격합니다. 경고를 무시해도됩니다. 이를 제거하려면 PNG 이미지에서 iCCP 청크를 제거하십시오.
일부 응용 프로그램은 경고를 오류로 취급합니다. 이러한 응용 프로그램을 사용하는 경우 청크를 제거해야합니다. ImageMagick과 같은 다양한 PNG 편집기로이를 수행 할 수 있습니다.
convert in.png out.png
폴더 (디렉토리)의 모든 PNG 파일에서 잘못된 iCCP 청크를 제거하려면 mogrifyImageMagick에서 사용할 수 있습니다 .
mogrify *.png
이를 위해서는 ImageMagick이 libpng16으로 빌드되어야합니다. 다음을 실행하여 쉽게 확인할 수 있습니다.
convert -list format | grep PNG
맹목적으로 모든 파일을 처리하는 대신 수정해야 할 파일을 찾으려면 다음을 실행할 수 있습니다.
pngcrush -n -q *.png
여기서 -n수단은 파일을 다시 쓰지 않으며 -q경고를 제외한 대부분의 출력을 억제합니다. 죄송합니다. pngcrush에는 아직 경고 이외의 모든 항목을 표시하지 않는 옵션이 없습니다.
ImageMagick의 바이너리 릴리스는 여기
Android 프로젝트 (Android Studio)의 경우 res폴더 로 이동하십시오 .
예를 들면 다음과 같습니다.
C:\{your_project_folder}\app\src\main\res\drawable-hdpi\mogrify *.png
pngcrushpng 파일에서 잘못된 sRGB 프로파일을 제거하는 데 사용하십시오 .
pngcrush -ow -rem allb -reduce file.png
-ow입력 파일을 덮어 씁니다.-rem allbtRNS 및 gAMA를 제외한 모든 보조 청크를 제거합니다.-reduce무손실 색상 유형 또는 비트 심도 감소
콘솔 출력에는 Removed the sRGB chunk청크 제거에 대한 메시지 가 표시 되고 가능하면 더 많은 메시지가 표시됩니다. 작고 최적화 된 PNG 파일이 생깁니다. 명령이 원본 파일을 덮어 쓰므로 백업을 만들거나 버전 관리를 사용해야합니다.
해결책
잘못된 프로파일은 다음과 같이 수정 될 수 있습니다.
- QPixmap :: load를 사용하여 잘못된 프로파일로 이미지 열기
- QPixmap :: save를 사용하여 이미지를 디스크에 다시 저장 (올바른 프로파일과 함께)
참고 : 이 솔루션은 Qt 라이브러리를 사용합니다 .
예
다음은 제안 된 솔루션을 구현하는 방법을 보여주기 위해 C ++로 작성한 최소 예입니다.
QPixmap pixmap;
pixmap.load("badProfileImage.png");
QFile file("goodProfileImage.png");
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "PNG");
이 예제를 기반으로 한 GUI 애플리케이션의 전체 소스 코드는 GitHub에서 사용 가능합니다 .
당신은 또한 포토샵에서 이것을 고칠 수 있습니다 ... CC2015를 가지고 있지만 이것이 모든 버전에서 동일하다고 확신합니다.
- .png 파일을여십시오.
- 파일-> 다른 이름으로 저장 및 대화 상자가 열리면 "ICC 프로파일 : sRGB IEC61966-2.1"을 선택 취소하십시오.
- "사본으로"를 선택 해제하십시오.
- 원본 .png를 용감하게 저장하십시오.
- 당신이 세상에서 그 작은 악을 제거했다는 것을 알고 당신의 인생을 계속하십시오.
Glenn의 훌륭한 답변을 추가하기 위해 결함이있는 파일을 찾기 위해 수행 한 작업은 다음과 같습니다.
find . -name "*.png" -type f -print0 | xargs \
-0 pngcrush_1_8_8_w64.exe -n -q > pngError.txt 2>&1
pngcrush가 많은 인수를 처리 할 수 없기 때문에 find와 xargs를 사용했습니다 (에 의해 반환 된 **/*.png). -print0과는 -0공백이 포함 된 핸들 파일 이름이 필요합니다.
그런 다음 출력에서 다음 행을 검색하십시오 iCCP: Not recognizing known sRGB profile that has been edited..
./Installer/Images/installer_background.png:
Total length of data found in critical chunks = 11286
pngcrush: iCCP: Not recognizing known sRGB profile that has been edited
그리고 그들 각각을 위해, 그것을 고치기 위해 그것에 mogrify를 실행하십시오.
mogrify ./Installer/Images/installer_background.png
Doing this prevents having a commit changing every single png file in the repository when only a few have actually been modified. Plus it has the advantage to show exactly which files were faulty.
I tested this on Windows with a Cygwin console and a zsh shell. Thanks again to Glenn who put most of the above, I'm just adding an answer as it's usually easier to find than comments :)
Thanks to the fantastic answer from Glenn, I used ImageMagik's "mogrify *.png" functionality. However, I had images buried in sub-folders, so I used this simple Python script to apply this to all images in all sub-folders and thought it might help others:
import os
import subprocess
def system_call(args, cwd="."):
print("Running '{}' in '{}'".format(str(args), cwd))
subprocess.call(args, cwd=cwd)
pass
def fix_image_files(root=os.curdir):
for path, dirs, files in os.walk(os.path.abspath(root)):
# sys.stdout.write('.')
for dir in dirs:
system_call("mogrify *.png", "{}".format(os.path.join(path, dir)))
fix_image_files(os.curdir)
There is an easier way to fix this issue with Mac OS and Homebrew:
Install homebrew if it is not installed yet
$brew install libpng
$pngfix --strip=color --out=file2.png file.png
or to do it with every file in the current directory:
mkdir tmp; for f in ./*.png; do pngfix --strip=color --out=tmp/"$f" "$f"; done
It will create a fixed copy for each png file in the current directory and put it in the the tmp subdirectory. After that, if everything is OK, you just need to override the original files.
Another tip is to use the Keynote and Preview applications to create the icons. I draw them using Keynote, in the size of about 120x120 pixels, over a slide with a white background (the option to make polygons editable is great!). Before exporting to Preview, I draw a rectangle around the icon (without any fill or shadow, just the outline, with the size of about 135x135) and copy everything to the clipboard. After that, you just need to open it with the Preview tool using "New from Clipboard", select a 128x128 pixels area around the icon, copy, use "New from Clipboard" again, and export it to PNG. You won't need to run the pngfix tool.
some background info on this:
Some changes in libpng version 1.6+ cause it to issue a warning or even not work correctly with the original HP/MS sRGB profile, leading to the following stderr: libpng warning: iCCP: known incorrect sRGB profile The old profile uses a D50 whitepoint, where D65 is standard. This profile is not uncommon, being used by Adobe Photoshop, although it was not embedded into images by default.
(source: https://wiki.archlinux.org/index.php/Libpng_errors)
Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad profiles that were previously accepted are now rejected, in particular the very old broken Microsoft/HP sRGB profile. The PNG spec requirement that only grayscale profiles may appear in images with color type 0 or 4 and that even if the image only contains gray pixels, only RGB profiles may appear in images with color type 2, 3, or 6, is now enforced. The sRGB chunk is allowed to appear in images with any color type.
Using IrfanView image viewer in Windows, I simply resaved the PNG image and that corrected the problem.
After trying a couple of the suggestions on this page I ended up using the pngcrush solution. You can use the bash script below to recursively detect and fix bad png profiles. Just pass it the full path to the directory you want to search for png files.
fixpng "/path/to/png/folder"
The script:
#!/bin/bash
FILES=$(find "$1" -type f -iname '*.png')
FIXED=0
for f in $FILES; do
WARN=$(pngcrush -n -warn "$f" 2>&1)
if [[ "$WARN" == *"PCS illuminant is not D50"* ]] || [[ "$WARN" == *"known incorrect sRGB profile"* ]]; then
pngcrush -s -ow -rem allb -reduce "$f"
FIXED=$((FIXED + 1))
fi
done
echo "$FIXED errors fixed"
Extending the friederbluemle solution, download the pngcrush and then use the code like this if you are running it on multiple png files
path =r"C:\\project\\project\\images" # path to all .png images
import os
png_files =[]
for dirpath, subdirs, files in os.walk(path):
for x in files:
if x.endswith(".png"):
png_files.append(os.path.join(dirpath, x))
file =r'C:\\Users\\user\\Downloads\\pngcrush_1_8_9_w64.exe' #pngcrush file
for name in png_files:
cmd = r'{} -ow -rem allb -reduce {}'.format(file,name)
os.system(cmd)
here all the png file related to projects are in 1 folder.
Here is a ridiculously brute force answer:
I modified the gradlew script. Here is my new exec command at the end of the file in the
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" **| grep -v "libpng warning:"**
참고URL : https://stackoverflow.com/questions/22745076/libpng-warning-iccp-known-incorrect-srgb-profile
'IT story' 카테고리의 다른 글
| WHERE 절에서 열 별명 참조 (0) | 2020.06.10 |
|---|---|
| 오라클은 제약 조건 찾기 (0) | 2020.06.10 |
| 로컬 Git 리포지토리를 백업하는 방법? (0) | 2020.06.10 |
| @@ variable은 Ruby에서 무엇을 의미합니까? (0) | 2020.06.10 |
| asp.net MVC의 @RenderSection는 무엇입니까 (0) | 2020.06.10 |