Skip to content

Commit b7e6700

Browse files
fix(pdf): ext-gd を必須から推奨へ移す
GD を使うのは FPDF の GIF/WebP 解析だけで, コアの src/ は GD 関数を 1 つも 呼んでいない。既定のロゴは PNG で, PNG/JPEG の解析に GD は要らないため, 必須にすると GD の無い環境をインストール時点で弾いてしまう。 - composer.json の require から ext-gd を外す(lock は content-hash と platform が元へ戻るだけ) - InstallController の必須モジュールから推奨モジュールへ移す - GIF は FPDF の _parsegif が imagecreatefromgif を呼び, 無いと Error で PDF 全体が落ちるため, GD 不在時は解析不能な形式と同じくロゴを省いて出力する getimagesize() は ext-standard の関数で GD が無くても使えるため, 形式判定は そのまま。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 9f06e47 commit b7e6700

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"php": "^8.2",
1616
"ext-curl": "*",
1717
"ext-filter": "*",
18-
"ext-gd": "*",
1918
"ext-intl": "*",
2019
"ext-json": "*",
2120
"ext-mbstring": "*",

composer.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Eccube/Controller/Install/InstallController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ class InstallController extends AbstractController
8181
'fileinfo',
8282
'intl',
8383
'sodium',
84-
'gd',
8584
];
8685
/**
8786
* @var string[]
8887
*/
8988
protected array $recommendedModules = [
9089
'hash',
90+
// 納品書 PDF の GIF ロゴを描くときだけ使う. 無い場合はロゴを省いて出力する
91+
'gd',
9192
];
9293
/**
9394
* @var string[]

src/Eccube/Service/Pdf/PdfWriter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,13 @@ public function image(string $file, float $x, float $y, float $width): void
482482
$type = match ($size[2]) {
483483
IMAGETYPE_PNG => 'png',
484484
IMAGETYPE_JPEG => 'jpg',
485-
IMAGETYPE_GIF => 'gif',
485+
// GIF の解析だけ FPDF が GD へ委譲する(_parsegif が imagecreatefromgif を呼び,
486+
// 無ければ Error で PDF 全体が落ちる)。ext-gd は推奨止まりなので自前で弾く
487+
IMAGETYPE_GIF => \function_exists('imagecreatefromgif') ? 'gif' : null,
486488
default => null,
487489
};
488490
if ($type === null) {
489-
// FPDF が解析できない形式。ロゴを描かないだけにして帳票自体は出す
491+
// FPDF が解析できない形式, または GD 不在の GIF。ロゴを描かないだけにして帳票自体は出す
490492
return;
491493
}
492494

0 commit comments

Comments
 (0)