1 頁 (共 1 頁)

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

發表於 : 2018-10-17 14:21:08
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


中文字形

發表於 : 2018-10-17 15:01:34
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');