Ubuntu install php freetype

How to Enable GD Library in PHP with LibJPEG, FreeType and LibPNG

In PHP you can manipulate image files using GD library. It support several formats including GIF, PNG, JPEG, etc. You can use LibGD library to stream images directly from your application to the browser. This tutorial explains how to enable GD functionality in PHP.

Download LibJPEG Library

cd /usr/save wget http://www.ijg.org/files/jpegsrc.v9.tar.gz

Install LibJPEG Library

tar xvfz jpegsrc.v9.tar.gz cd jpeg-9 ./configure make make install
# ls /usr/local/lib/*jpeg* /usr/local/lib/libjpeg.a /usr/local/lib/libjpeg.la* /usr/local/lib/libjpeg.so -> libjpeg.so.9.0.0* /usr/local/lib/libjpeg.so.9 -> libjpeg.so.9.0.0* /usr/local/lib/libjpeg.so.9.0.0*

Download FreeType Library

cd /usr/save wget http://iweb.dl.sourceforge.net/project/freetype/freetype2/2.5.0/freetype-2.5.0.1.tar.bz2

Install FreeType Library

tar xvfj freetype-2.5.0.1.tar.bz2 cd freetype-2.5.0.1/ ./configure --without-png make make install

While installing freetype, if you don’t specify without-png flag to the ./configure as shown above, you might get the following error during ./configure

/usr/include/libpng12/pngconf.h:336: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token /usr/include/libpng12/pngconf.h:337: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'include' make: *** [/usr/src/freetype-2.5.0.1/objs/sfnt.lo] Error 1

Install LibPNG

# rpm -qa | egrep 'jpg|png' libpng-devel-1.2.10-7.1.el5_0.1 libpng-1.2.10-7.1.el5_0.1

Compile PHP

Now, download and install PHP from source as we explained earlier. But, this time, make sure to pass the following parameters to the ./configure in your PHP installation.

./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql \ --with-gd \ --with-jpeg-dir \ --enable-gd-native-ttf \ --with-freetype-dir \ make make install

Verify GD is enabled in PHP

Now, create a test php page with the phpinfo(),and view it from the browser. As you see below, you’ll notice that it has the LibGD and related libraries enabled.

Читайте также:  Шрифт

Источник

PHP FreeType Support – Install it with ease

However, enabling Freetype libraries on the server involves a series of steps.

At Bobcares, we receive requests to enable PHP FreeType support on the server as a part of our Server Management Services.

Today, let’s see how our Support Engineers install the FreeType support and fix related errors.

Why PHP FreeType Support?

Basically, FreeType software is a low-level font engine that supports font-related operations. It is efficient, customizable and helps in producing high-quality output. It finds wide usage in graphics libraries, font conversion tools, text image generation tools, and many other products as well.

By default, FreeType 2 support fonts like TrueType fonts, Type 1 fonts, CFF fonts, etc. Also due to its modular design, it is easy to enhance the library through optional APIs.

And, to enable support for FreeType 2 in PHP, we add –with-freetype-dir=DIR. For PHP 7.4.0 we use –with-freetype instead.

Installation of PHP FreeType Support

Now, let’s see how our Support Engineers install FreeType support in PHP. This requires the PHP version to have GD support.

Initially, we use the below command to install FreeType on a CentOS server.

Or in an Ubuntu machine, as a root user, we execute the commands:

apt update && apt install freetype2-demos

This installs the necessary packages. After installing it, we restart the Apache server using the below command:

Also, we restart the php-fpm by executing

This enables the FreeType support in the PHP configuration. We confirm it from the loaded PHP configuration.

A sample output appears as:

[root@xxx ~]# php -i | grep -i freetype | grep -v configure FreeType Support => enabled FreeType Linkage => with freetype FreeType Version => 2.8.0

Additionally, we also check and confirm Freetype support by adding a PHPinfo page on any of the websites.

Support Engineers went troubleshooting this error and fix it.

He got the below error during the construction of the image:

configure: error: freetype-config not found.

We ran the below command that instructs to configure GD with freetype support.

RUN docker-php-ext-configure gd --with-freetype-dir --with-jpeg-dir=/usr/include/

Finally, this fixed the error.

[Need further assistance with PHP FreeType installation or fix its errors? We’ll help you]

Conclusion

In short, the PHP FreeType Support helps in using all font formats on websites. Also, it enables websites to provide higher-level features like text layout or graphics processing. Today, we discussed how our Support Engineers installed the FreeType Support and fixed its error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

1 Comment

Thanks for this post, it helped me a lot, but there is a typo, the docker command should be `RUN docker-php-ext-configure gd –with-freetype –with-jpeg-dir=/usr/include` Reply

Источник

Install GD library and freetype on Linux

Don’t forget to restart apache after that (if you are using apache):

CentOS / RedHat / Fedora :

sudo /etc/init.d/httpd restart 
sudo service httpd restart 

Debian/ubuntu :

sudo /etc/init.d/apache2 restart 
sudo service apache2 restart 

Solution 2

Things are pretty much simpler unless they are made confusing.

To Install GD library in Ubuntu

sudo apt-get install php5-gd 

To Install Freetype in Ubuntu

sudo apt-get install libfreetype6-dev:i386 

Solution 3

For CentOS: When installing php-gd you need to specify the version. I fixed it by running: sudo yum install php55-gd

Solution 4

sudo apt update && sudo apt install freetype2-demos

C A Mc

C A Mc

Updated on February 01, 2020

Comments

C A Mc

I’m trying to use imagefttext. And I need to have GD library and/or freetype installed. I’m new to this kind of stuffs, How can I install GD library and freetype in Linux ?

C A Mc

I’m using ubuntu, so I just tried this with ‘sudo apt-get install php5-gd’. However, it says PHP-GD is already the newest version. I’m guessing this means i have the GD library installed, so now I just need to enable Freetype somehow. The php wiki has this «To enable support for FreeType 2 add —with-freetype-dir=DIR .» but I have no idea what that means.

C A Mc

Alireza Fallah

Im not using ubunto to test it, but its my first result of search how to install freetype in ubunto . you can search too

Paul

In 14.04 LTS, installing php5-gd took care of Freetype as well (so only php5-gd needed to be installed).

I don’t know either, You should ask it from the person who add it on the repository. For all I know It maybe there under the name of «freetype*» instead of «freetype»

Источник

Оцените статью