강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

웹에서 동적이미지 생성을 위한 gd 설치

작성자 정보

  • 관리자 작성
  • 작성일

컨텐츠 정보

본문

웹에서 동적이미지 생성을 위한 gd 설치

 

 

 

 

 

동적이미지 생성 ANSI C라이브러리로서 PNG, JPEG, GIF의 포맷으로된 이미지들을 생성할 수 있는 유용한 툴이다.

 

 

 

 홈페이지에서 동적인 이미지구현을 하기위한 가장 대표적인 도구이다.

 

 

 

 예를들어 홈페이지에서 이미지를 다른이미지와 합성하거나 특정로고이미지를 다른 이미지에 부착하는 등의 작업을 위해서 많이 사용한다.

 

 

 

 그리고 GD설치시에는 GD의 버전에 대한 다음 사항을 고려하기 바란다.

 

 

 

 GD버전이 2.0.28이전 버전에서는 gif이미지에 대한 READ만 가능하였고 WRITE는 불가능하였다.

 

 

 

 하지만 2.0.28이후 버전부터는 gif이미지파일의 READ WRITE가 모두 가능하게 되었다.

 

 

 

 따라서 가능하면 2.0.28이후버전을 설치하는 것이 좋다.

 

 

 

 

 

그리고 GD를 사용하기 위해서는 앞에서 이미 설치했던 zlib, libpng, freetype, jepg등이 먼저 설치되어있어야 한다.

 

 

 



 

 

 

 

 

홈페이지 : http://www.libgd.org

 

 f626a104e0c090a148359de2dcc6d85b_1687931913_0489.png




f626a104e0c090a148359de2dcc6d85b_1687931931_7103.png
 



 

 

 

, 그럼 gd라이브러리를 설치해보도록 하겠다.

 

 

 

 wget을 이용하여 다음과 같이 gd압축소스파일을 가져온다.

 

 

 

 

 

[root@RockyLinux local]# wget https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz

--2023-06-28 11:07:17--  https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz

Resolving github.com (github.com)... 20.200.245.247

Connecting to github.com (github.com)|20.200.245.247|:443... connected.

HTTP request sent, awaiting response... 302 Found

Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/29669711/e144095a-e8eb-4b36-8a43-b607c43c10e2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20230628/us-east-1/s3/aws4_request&X-Amz-Date=20230628T020717Z&X-Amz-Expires=300&X-Amz-Signature=33b6c7e3990ab6e59463981f634d2da2b1ec71eff98fd545a8ae7e098e168d84&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=29669711&response-content-disposition=attachment; filename=libgd-2.3.3.tar.gz&response-content-type=application/octet-stream [following]

--2023-06-28 11:07:18--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/29669711/e144095a-e8eb-4b36-8a43-b607c43c10e2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20230628/us-east-1/s3/aws4_request&X-Amz-Date=20230628T020717Z&X-Amz-Expires=300&X-Amz-Signature=33b6c7e3990ab6e59463981f634d2da2b1ec71eff98fd545a8ae7e098e168d84&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=29669711&response-content-disposition=attachment; filename=libgd-2.3.3.tar.gz&response-content-type=application/octet-stream

Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.108.133, ...

Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 3593182 (3.4M) [application/octet-stream]

Saving to: `libgd-2.3.3.tar.gz'

 

libgd-2.3.3.tar.gz            100%[=================================================>]   3.43M  12.0MB/s    in 0.3s

 

2023-06-28 11:07:18 (12.0 MB/s) - `libgd-2.3.3.tar.gz' saved [3593182/3593182]

 

[root@RockyLinux local]#

[root@RockyLinux local]# ls -l libgd-2.3.3.tar.gz

-rw-r--r-- 1 root root 3593182 12  8  2021 libgd-2.3.3.tar.gz

[root@RockyLinux local]#

 

 

 

 

가져온 gd압축소스파일을 tar를 이용하여 아래와 같이 압축해제한다.

 

 

 

 압축해제되면 “gd-버전이름으로된 디렉토리가 생성되고 생성된 디렉토리내에는 압축해제된 모든 파일들이 복사된다.

 

 

 

 

 

[root@RockyLinux local]# tar xvfz libgd-2.3.3.tar.gz

libgd-2.3.3/

libgd-2.3.3/src/

libgd-2.3.3/src/pngtogd.c

libgd-2.3.3/src/gdfontmb.c

libgd-2.3.3/src/gdcmpgif.c

libgd-2.3.3/src/gd_transform.c

libgd-2.3.3/src/gdfontg.h

libgd-2.3.3/src/gd_bmp.c

libgd-2.3.3/src/gdxpm.c

libgd-2.3.3/src/gdfonts.c

libgd-2.3.3/src/gd_jpeg.c

libgd-2.3.3/src/fontconfigtest.c

libgd-2.3.3/src/gdtestft.c

libgd-2.3.3/src/gd_crop.c

libgd-2.3.3/src/gdpp.cxx

libgd-2.3.3/src/entities.h

libgd-2.3.3/src/gdtopng.c

libgd-2.3.3/src/config.h.cmake

libgd-2.3.3/src/gdpp.h

libgd-2.3.3/src/gdfonts.h

libgd-2.3.3/src/gddemo.c

libgd-2.3.3/src/annotate.c

libgd-2.3.3/src/gd_filter.c

libgd-2.3.3/src/CMakeLists.txt

libgd-2.3.3/src/gd_io_stream.cxx

이하생략..

 

 

 

 

그리고 컴파일하기 위하여 다음과 같이 생성된 디렉토리로 이동하였다.

 

 

 

 

 

[root@RockyLinux local]# cd libgd-2.3.3/

[root@RockyLinux libgd-2.3.3]#

 

 

 

 

그리고 다음과 같이 configure를 실행하였다.

 

 

 

 간혹 csh쉘을 지원하는 시스템(SYSTEM V)에서는 “sh ./configure”를 실행해야 할 경우도 있다.

 

 

 

 여러분들의 시스템 상황에 맞는 configure작업을 선택하면 된다.

 

 

 

 

 

[root@RockyLinux libgd-2.3.3]# ./configure

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /usr/bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking whether make supports nested variables... yes

checking whether make supports the include directive... yes (GNU style)

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking whether gcc understands -c and -o together... yes

checking dependency style of gcc... gcc3

이하생략..

 

 

 

 

 

GD configure과정을 잘 살펴보면 configure작업이 끝나기 바로전에 다음 그림과 같은 안내문을 출력한다.

 

 

 

 위의 내용을 잘 살펴보면  GD가 지원하는 라이브러리들에 대한 안내문이다.

 

 

 

 PNG 라이브러리, JPEG라이브러리, Freetype 2.x 라이브러리등을 지원하고 있음을 알 수 있다.

 

 

 

 앞서 우리가 GD 이전에 설치했던 라이브러리들과 비교하면서 보기 바란다.

 

 

 

 

 

그리고 GD configure작업시에 사용할 수 있는 다음과 같은 configure옵션들도 함께 알아두기 바란다.

 

 

 

 

--with-png=DIR
png
관련 라이브러리가 설치된 디렉토리를 지정한다.

 

 

 

 만약 디렉토리위치를 지정하지 않는다면 png 헤드파일과 라이브러리들을 기본위치에서 찾는다.

 

 

 

 만약  png를 지원하지 않도록하려면 “--without-png”를 사용하거나 “--with-png=no”를 사용하면 된다.

 

 

 

 

 

--with-freetype=DIR

freetype 2.X버전을 지원하기 위한 옵션이다.

 

 

 

 freetype관련파일들은 여기서 지정한 디렉토리(DIR)내의 “DIR/include/freetype2”에서 찾는다.

 

 

 

 

 

--with-jpeg=DIR

jpeg라이브러리를 지원하기 위한 옵션이다.

 

 

 

 지정된 디렉토리위치에서 jpeg관련파일들을 찾는다.

 

 

 

 

 

--with-xpm=DIR

xpm라이브러리를 지원하기 위한 옵션이다.

 

 

 

 지정된 디렉토리위치에서 xpm라이브러리파일등을 검색하게 된다.

 

 

 

 

 

, 그럼 이제 컴파일을 해보도록 하겠다.

 

 

 

 다음과 같이 make를 실행하여 컴파일을 수행한다.

 

 

 

 

 

[root@RockyLinux libgd-2.3.3]# make

Making all in src

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/src' 들어감

make  all-am

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/src' 들어감

depbase=`echo gdcmpgif.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\

gcc -DHAVE_CONFIG_H -I.     -g -O2 -fvisibility=hidden -Wall -MT gdcmpgif.o -MD -MP -MF $depbase.Tpo -c -o gdcmpgif.o gdcmpgif.c &&\

mv -f $depbase.Tpo $depbase.Po

depbase=`echo gd.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -fvisibility=hidden -Wall -MT gd.lo -MD -MP -MF $depbase.Tpo -c -o gd.lo gd.c &&\

mv -f $depbase.Tpo $depbase.Plo

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd.lo -MD -MP -MF .deps/gd.Tpo -c gd.c  -fPIC -DPIC -o .libs/gd.o

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd.lo -MD -MP -MF .deps/gd.Tpo -c gd.c -o gd.o >/dev/null 2>&1

depbase=`echo gd_avif.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -fvisibility=hidden -Wall -MT gd_avif.lo -MD -MP -MF $depbase.Tpo -c -o gd_avif.lo gd_avif.c &&\

mv -f $depbase.Tpo $depbase.Plo

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd_avif.lo -MD -MP -MF .deps/gd_avif.Tpo -c gd_avif.c  -fPIC -DPIC -o .libs/gd_avif.o

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd_avif.lo -MD -MP -MF .deps/gd_avif.Tpo -c gd_avif.c -o gd_avif.o >/dev/null 2>&1

depbase=`echo gd_bmp.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -fvisibility=hidden -Wall -MT gd_bmp.lo -MD -MP -MF $depbase.Tpo -c -o gd_bmp.lo gd_bmp.c &&\

mv -f $depbase.Tpo $depbase.Plo

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd_bmp.lo -MD -MP -MF .deps/gd_bmp.Tpo -c gd_bmp.c  -fPIC -DPIC -o .libs/gd_bmp.o

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -fvisibility=hidden -Wall -MT gd_bmp.lo -MD -MP -MF .deps/gd_bmp.Tpo -c gd_bmp.c -o gd_bmp.o >/dev/null 2>&1

depbase=`echo gd_color.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -fvisibility=hidden -Wall -MT gd_color.lo -MD -MP -MF $depbase.Tpo -c -o gd_color.lo gd_color.c &&\

mv -f $depbase.Tpo $depbase.Plo

이하생략..

 

 

 

 

 

그리고 다음과 같이 “make install”을 실행하여 컴파일된 결과파일들을 설치한다.

 

 

 

 

 

[root@RockyLinux libgd-2.3.3]# make install

Making install in src

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/src' 들어감

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/src' 들어감

 /usr/bin/mkdir -p '/usr/local/lib'

 /bin/sh ../libtool   --mode=install /usr/bin/install -c   libgd.la '/usr/local/lib'

libtool: install: /usr/bin/install -c .libs/libgd.so.3.0.11 /usr/local/lib/libgd.so.3.0.11

libtool: install: (cd /usr/local/lib && { ln -s -f libgd.so.3.0.11 libgd.so.3 || { rm -f libgd.so.3 && ln -s libgd.so.3.0.11 libgd.so.3; }; })

libtool: install: (cd /usr/local/lib && { ln -s -f libgd.so.3.0.11 libgd.so || { rm -f libgd.so && ln -s libgd.so.3.0.11 libgd.so; }; })

libtool: install: /usr/bin/install -c .libs/libgd.lai /usr/local/lib/libgd.la

libtool: install: /usr/bin/install -c .libs/libgd.a /usr/local/lib/libgd.a

libtool: install: chmod 644 /usr/local/lib/libgd.a

libtool: install: ranlib /usr/local/lib/libgd.a

libtool: finish: PATH="/root/.local/bin:/root/bin:/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin/:/sbin" ldconfig -n /usr/local/lib

----------------------------------------------------------------------

Libraries have been installed in:

   /usr/local/lib

 

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the '-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the 'LD_RUN_PATH' environment variable

     during linking

   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

 

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

 /usr/bin/mkdir -p '/usr/local/bin'

  /bin/sh ../libtool   --mode=install /usr/bin/install -c gdcmpgif gd2copypal gd2togif giftogd2 '/usr/local/bin'

libtool: install: /usr/bin/install -c .libs/gdcmpgif /usr/local/bin/gdcmpgif

libtool: install: /usr/bin/install -c .libs/gd2copypal /usr/local/bin/gd2copypal

libtool: install: /usr/bin/install -c .libs/gd2togif /usr/local/bin/gd2togif

libtool: install: /usr/bin/install -c .libs/giftogd2 /usr/local/bin/giftogd2

 /usr/bin/mkdir -p '/usr/local/bin'

 /usr/bin/install -c bdftogd '/usr/local/bin'

 /usr/bin/mkdir -p '/usr/local/include'

 /usr/bin/install -c -m 644 gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h gd_color_map.h gd_errors.h gdpp.h '/usr/local/include'

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/src' 나감

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/src' 나감

Making install in config

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/config' 들어감

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/config' 들어감

make[2]: 'install-exec-am'() 위해 할 일이 없습니다.

 

 

 

 

 /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'

 /usr/bin/install -c -m 644 gdlib.pc '/usr/local/lib/pkgconfig'

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/config' 나감

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/config' 나감

Making install in tests

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/tests' 들어감

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/tests' 들어감

make[2]: 'install-exec-am'() 위해 할 일이 없습니다.

 

 

 

 

make[2]: 'install-data-am'() 위해 할 일이 없습니다.

 

 

 

 

make[2]: 디렉터리 '/usr/local/libgd-2.3.3/tests' 나감

make[1]: 디렉터리 '/usr/local/libgd-2.3.3/tests' 나감

make[1]: 디렉터리 '/usr/local/libgd-2.3.3' 들어감

make[2]: 디렉터리 '/usr/local/libgd-2.3.3' 들어감

make[2]: 'install-exec-am'() 위해 할 일이 없습니다.

 

 

 

 

make[2]: 'install-data-am'() 위해 할 일이 없습니다.

 

 

 

 

make[2]: 디렉터리 '/usr/local/libgd-2.3.3' 나감

make[1]: 디렉터리 '/usr/local/libgd-2.3.3' 나감

[root@RockyLinux libgd-2.3.3]#

 

 

 

 

이제 GD설치가 끝났다.

 

 

 

 

 

 


관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,035 명
  • 현재 강좌수 :  35,798 개
  • 현재 접속자 :  127 명