Troubles with Docker + PHP7 + GD resulting in “Call to undefined function imagecreatefromjpeg()”

http://laravel.com/

http://kejyun.github.io/Laravel-4-Docum ... roduction/
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Troubles with Docker + PHP7 + GD resulting in “Call to undefined function imagecreatefromjpeg()”

文章 yehlu »

https://stackoverflow.com/questions/472 ... ion-imagec

代碼: 選擇全部

RUN apt-get update && \
    apt-get install -y -qq
        libjpeg62-turbo-dev \
        libfreetype6-dev \
        libmcrypt-dev \
        libpng12-dev \

RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd

yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

中文字形

文章 yehlu »

https://blog.csdn.net/beyond__devil/art ... s/62230610

安裝 mpdf 用他的字形
composer require mpdf/mpdf

https://laravel-china.org/topics/13642/ ... -solutions
uft8 轉 unicode

代碼: 選擇全部

function to_unicode($string)
{
    $str = mb_convert_encoding($string, 'UCS-2', 'UTF-8');
    $arrstr = str_split($str, 2);
    $unistr = '';
    foreach ($arrstr as $n) {
        $dec = hexdec(bin2hex($n));
        $unistr .= '&#' . $dec . ';';
    }
    return $unistr;
}
產生gif圖片

代碼: 選擇全部

        $img = Image::canvas(128, 32, '#FFFFFF');
        $img->text(self::to_unicode($id), 64, 0, function ($font) {
            $font->file(base_path('vendor/mpdf/mpdf/ttfonts/Sun-ExtA.ttf'));
            $font->size(32);
            $font->color('#000000');
            $font->align('center');
            $font->valign('top');
            $font->angle(0);
        });

        return $img->response('gif');
回覆文章

回到「laravel」