`imagecropauto()` not working with transparent background
オープン
まだ誰も着手していません。
Bug
Extension: gd
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
$gdImage = imagecreatetruecolor(100,100);
imagesavealpha($gdImage, true);
imagefill($gdImage, 0, 0, imagecolorallocatealpha($gdImage, 0, 0, 0, 127));
// imagepng($gdImage, '/tmp/image_transparent.png');
$result = imagecropauto($gdImage, IMG_CROP_TRANSPARENT);
var_dump($result); // object(GdImage)#2 (0) { }
// imagepng($result, '/tmp/image_black.png');
Resulted in this output:
object(GdImage)#2 (0) { }
But I expected this output instead:
bool(false)
Docs at https://www.php.net/manual/en/function.imagecropauto.php are saying:
If the complete image was cropped,
imagecrop()returns false
And this should be the case here IMO.
When doing the same with white background, it works as expected:
<?php
$gdImage = imagecreatetruecolor(100,100);
imagesavealpha($gdImage, true);
imagefill($gdImage, 0, 0, imagecolorallocate($gdImage, 255, 255, 255));
// imagepng($gdImage, '/tmp/image_white.png');
$result = imagecropauto($gdImage, IMG_CROP_WHITE);
var_dump($result); // bool(false)
PHP Version
PHP 8.3.1
Operating System
Kubuntu 22.04
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された PHP スニペットを IMG_CROP_TRANSPARENT で実行し、完全に透明な 100x100 の画像と完全に白い 100x100 の画像で IMG_CROP_WHITE のケースと比較します。imagecropauto() のエントリーポイントを追跡し、透明なケースのカバレッジを追加します。完全にトリミングされた透明な画像が、ドキュメントに記載された動作と一致して false を返せば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- computer-graphics
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100