Skip to content

ImageMagick

이미지 매직(ImageMagick)은 그래픽 이미지를 새로 만들거나, 고치는 데 사용되는 자유 소프트웨어이다. 이미지 매직은 대부분의 이미지 형식을 읽고, 변환하거나 쓸 수 있다. 이미지의 외곽을 자르거나, 색을 바꾸는 것을 비롯한 다양한 효과를 줄 수 있으며, 이미지의 회전, 합치기, 문자삽입, 선, 다각형, 타원, 베지에 곡선을 그려넣거나, 이미지 늘이기 등의 작업을 할 수 있다.

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), Lua, NMagick (Neko/haXe), Magick.NET (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.

ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may use, copy, modify, and distribute in both open and proprietary applications. It is distributed under the Apache 2.0 license, approved by the OSI and recommended for use by the OSSCC.

How to Install

CentOS에서는 아래와 같이 설치하면 된다.

$ yum install ImageMagick

Example

Example of the JPEG quality Convert

  • Download: Imagemagick_-_jpeg_convert_sample.zip

ImageMagick를 사용하여 JPEG 품질을 일괄적으로 변환하는 Windows 배치파일 샘플코드는 아래와 같다.

SET MGD_IMAGE_DIR=.\convert_image
SET CONVERTER_NAME=convert.exe
SET CONVERTER_OPTION=-resize 260x350 -quality 92 -depth 24
SET TEMP_DIR=.\.temp
SET OUTPU_EXT=.jpg
SET OUTPUT_FILE=mgd-search.ggii

IF NOT EXIST "%TEMP_DIR%" MKDIR "%TEMP_DIR%"
FOR /R "%MGD_IMAGE_DIR%" %%i IN (*.jpg *.JPG) DO "%CONVERTER_NAME%" %CONVERTER_OPTION% "%%i" "%TEMP_DIR%\%%~ni%OUTPU_EXT%"

Concat image

아래와 같은 방법으로 이미지를 연결할 수 있다.

$ convert image1.jpeg image2.jpeg image3.jpeg -append output.jpeg

For vertical stacking (top to bottom):

$ convert -append 1.jpg 2.jpg out.jpg

For horizontal stacking (left to right):

$ convert +append 1.jpg 2.jpg out.jpg

Convert format

간단한 포맷변환은 INPUT과 OUTPUT만 넘겨줘도 된다.

$ convert image.jpeg image.png

명시적인 방법:

$ convert image.jpeg -format png image.png

Crop Image

then you could do it with (width x height + left + top / wxh+l+t format):

convert image.jpg -crop 703x470+3+5 output.jpg

아이콘 파일 만드는 방법

convert -define icon:auto-resize=16,32,54,128,256 -compress zip logo-1024.png favicon.ico

그 밖의 참고용 커맨드 목록:

convert -background transparent -define 'icon:auto-resize=16,24,32,64' logo.svg favicon.ico
convert -transparent white -format ico -resize 64x64 logo.svg favicon.ico

이미지 회전

convert input_image.jpg -rotate 180 output_image.jpg

See also

  • Cascade - GPU가속되는 노드 기반 이미지 에디터
  • ImaginAIry - AI로 이미지 수정하기
  • BackgroundRemover - 이미지/영상에서 배경지우기 오픈소스
  • pypipo - 피포페인팅 이미지 자동변환 영상처리 기술
  • img2pdf - 이미지를 PDF로 변환.

Favorite site