フィルターのクリア

Warning: PNG library warning: Incorrect sRGB chunk length.

16 ビュー (過去 30 日間)
Salad Box
Salad Box 2017 年 11 月 28 日
回答済み: Walter Roberson 2017 年 11 月 28 日
Hi
I have a number of .png image files in a folder. A few of them can be broken .png files which can't be opened by photo-editing softwares such as photoshop. I would like to rename all the valid .png files with temporary names and leave all the broken .png files' names unchanged so that I can easily tell which ones are broken files. The code were written below:
clear
Index=0;
A=dir('*.png');
filenames={A.name};
for i=1:numel(A)
try
I=imread(filenames{i});
Index=Index+1;
newname=sprintf('temp%03d.png',Index);
movefile(filenames{i},newname);
catch
% do nothing
end
end
Then it came up with some warning texts in orange colour as below.
Warning: PNG library warning: Incorrect sRGB chunk length.
> In readpngutil (line 9)
In readpng (line 32)
In imread/call_format_specific_reader (line 410)
In imread (line 403)
I wonder what this message 'PNG library warning: Incorrect sRGB chunk length.' means. What are the things that I need to be aware of in this case? Could anyone help?
Many thanks

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 28 日
You are working with broken png files. The particular way that they are broken happens to be that they have incorrect length information for an sRGB chunk; MATLAB is giving you a warning that this is happening.
You do need to be careful because this is coming out as a warning instead of an error, so your "catch" statement is not necessarily being triggered when these warnings are encountered. You might want to set lastwarn before you do the imread() and then check lastwarn afterwards to see if it has become the above.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by