前提・実現したいこと
ubuntu16.4&php7.2の環境でWEBサーバを作成しています。
そこでバーコードを表するためにImageBarcode2をPEARでインストールしました。
発生している問題・エラーメッセージ
コマンドでphpを直接実行するとバーコード画像ファイルが作成されるのですが、ブラウザから同じphpファイルを指定するとFatal errorとなってファイル作成がされません
Fatal error: Uncaught Error: Call to undefined function imagefontheight() in /usr/share/php/Image/Barcode2/Writer.php:63 Stack trace: #0 /usr/share/php/Image/Barcode2/Driver/Code128.php(274): Image_Barcode2_Writer->imagefontheight(2) #1 /usr/share/php/Image/Barcode2.php(146): Image_Barcode2_Driver_Code128->draw() #2 /var/www/html/php/testbarcode.php(16): Image_Barcode2::draw('012345', 'Code128', 'png', false) #3 /var/www/html/php/x_testbarcode.php(7): mkBarcode->mkBarcode('012345') #4 {main} thrown in /usr/share/php/Image/Barcode2/Writer.php on line 63
該当のソースコード
<?php ini_set('display_errors', 1); require "testbarcode.php"; $barcode = new mkBarcode("012345"); ?> ****** ***x_testbarcode.php*** <?php require("Image/Barcode2.php"); class mkBarcode{ var $barcode_val; var $image_name; function mkBarcode($barcode_val){ $this->barcode_val=$barcode_val; $this->image_name='barcodeImage/'.$barcode_val.'.png'; $code= new Image_Barcode2(); $image= $code->draw($this->barcode_val,'Code128','png',false); imagepng($image,$this->image_name); } function getBarcodeImage(){ return $this->image_name; } } ?> ***
試したこと
(1)Image_Barcode2のphpファイル内にあるディレクトリ指定を
'Image/Barcode2/~'をルートからの絶対パスに置換してみましたが結果は変わらず
(2)ディレクトリ&ファイルの所有者/権限による制限を疑い、関係のありそうな
・Image_Barcode2のインストールディレクトリ
・自分で作成phpファイル
・画像ファイル作成ディレクトリ
の各箇所を chmod 777 で利用許可を拡大しましたがエラーは出続けます
補足情報(FW/ツールのバージョンなど)
(変更01)ソース内の外部呼出しの概略を説明します
x_testbarcode.php (自作)
・・| calss mkBarcodeを呼出
・・+-testbarcode.php(自作)
・・・・| class Image_Barcode2->drawを呼出
・・・・+-$include_path Image/Barcode2.php
・・・・・・| class Image_Barcode2_Driver_Code128を呼出
・・・・・・ +-$include_path Image/Barcode2/Driver/Code128.php
・・・・・・・・| class Image_Barcode2_Writerを呼出
・・・・・・・・+-$include_path Image/Barcode2/Writer.php
・・・・・・・・・・・・function imagefontheight($font)
外部ファイルの呼び出しとclass、その中のfunctionがゴッチャゴチャ
になっているかもしれませんが、phpファイルの階層が外部ファイルを
呼び出している順です。
不足する情報があればご指摘ください。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー