본문 바로가기
프로그램개발/Linux(Apache.vim)

리눅스에서 이미지 정보 알아내기

by 크레도스 2019. 9. 24.

출처 : https://ngee.tistory.com/262


리눅스에서, 이미지 파일에 대한 정보를 커맨드라인으로 알아내기 위한 몇 가지 간단한 방법을 소개하려구요.


이미지 이름은 white.png를 사용합니다.


1. 진짜 간단하게


file white.png 이라고 커맨드라인을 입력하시면 다음과 같이 이미지에 대한 간략한 정보가 프린트되요.


....$ file white.png 


white.png: PNG image data, 256 x 256, 8-bit/color RGB, non-interlaced


2. gdalinfo 이용

gdal은 라이브러리인데요. 
다양한 이미지 관련 포멧의 입출력을 지원해주는 라이브러리입니다. 
사실 이미지라고 하기 보다는 공간정보를 담고 있는 데이터에 대한 라이브러리가 더 알맞은 설명이겠네요.

아무튼 gdal을 설치한 경우 gdalinfo 라는 커맨드라인 명령어를 사용 하실 수 있는데.
공간정보를 담고 있는 경우에는 더 자세한 정보가 출력되요. 
white.png는 그냥 일반 png라서 아래와 같이 이미지 정보가 출력되는 것을 확인 하실 수 있습니다.

....$ gdalinfo white.png 
Driver: PNG/Portable Network Graphics
Files: white.png
Size is 256, 256
Coordinate System is `'
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  256.0)
Upper Right (  256.0,    0.0)
Lower Right (  256.0,  256.0)
Center      (  128.0,  128.0)
Band 1 Block=256x1 Type=Byte, ColorInterp=Red
Band 2 Block=256x1 Type=Byte, ColorInterp=Green
Band 3 Block=256x1 Type=Byte, ColorInterp=Blue

3. identify 이용

imagemagick을 설치하신 경우에 사용하 실 수 있는 identify 라는 명령어를 통해서도 이미지에 대한 정보를 얻는 것이 가능해요.

$ identify white.png 
white.png PNG 256x256 256x256+0+0 8-bit DirectClass 3.29KB 0.000u 0:00.000

4. exiv2 이용

exiv2는 이미지 메타데이터 관리 도구인데요.

이것을 설치하신 경우에는 아래와 같이 출력되는 화면을 보실 수 있어요.


$ exiv2 white.png 

File name       : white.png

File size       : 3287 Bytes

MIME type       : image/png

Image size      : 256 x 256

white.png: No Exif data found in the file




출처: https://ngee.tistory.com/262 [ngee]