php / php/php-src

Suppress Warnings From libpng

オープン
#23,674 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Extension: gd Feature Good first issue Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

PNG files exported from some applications, most notably Photoshop, are written with an sRGB profile that libpng sees as invalid. Any attempt to load a file like this using the GD library causes a warning to be written to the PHP error log. It is not possible to suppress this warning.

The following code:

<?php
$image = imagecreatefrompng('clouds.png');

Results in this warning:

Warning: imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile

Please see the attached file as an example of one that has the issue.

The only solution I have found so far is to post-process the PNG to remove the sRGB profile. This is not ideal for workflow with large numbers of files. Whilst it is possible to disable all warnings, they are often on in production so this is not a desirable solution.

I would like a method to suppress all libpng warnings. This could be implemented as a gd_ prefixed method that takes an optional bool parameter to toggle warnings on or off. If no parameter is passed it could return the current state.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、imagecreatefrompng の背後にある GD の実装と、libpng の警告処理を探します。既存の PHP GD API が画像読み込みの動作をどのように公開しているか、また関連するテストで警告がカバーされているかを確認します。完了条件は、オプションの状態クエリを含め、libpng の警告を切り替えるために要求された方法を提供し、提示された無効なプロファイルのケースをカバーすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
computer-graphics
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。