Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Created June 14, 2013 05:50
Show Gist options
  • Save aanoaa/5779743 to your computer and use it in GitHub Desktop.
Save aanoaa/5779743 to your computer and use it in GitHub Desktop.
$ cpanm Image::ExifTool

제 경우에는 문제없이 설치 되었습니다.

#!/usr/bin/env perl
use strict;
use warnings;
use Image::ExifTool;

my $exifTool = new Image::ExifTool;
$exifTool->ExtractInfo('a.jpg');
print "Software: ", $exifTool->GetValue('Software'), "\n";

$exifTool->SetNewValue( 'Software', 'Image::ExitTool' );
if ( $exifTool->WriteInfo( 'a.jpg', 'b.jpg' ) ) {
    print "success for WriteInfo\n";
    $exifTool->ExtractInfo('b.jpg');
    print "Software: ", $exifTool->GetValue('Software'), "\n";
}
~/Desktop $ ls -l *.jpg
-rw-r--r--   1 hshong         hshong      87482  7월 23  2008 a.jpg
-rw-r--r--   1 hshong         hshong      87468  6월 14 14:28 b.jpg

WriteInfo 를 사용했을 때 바뀐 메타데이터 입니다.

BlueTRC
FileAccessDate
FileInodeChangeDate
FileModifyDate
FileName    <- 제가 바꾼거
GreenTRC
RedTRC
Software    <- 제가 바꾼거

Image::ExifTool 에서는 MIME type 이 application/dicomDICOMwrite 기능이 지원되지 않습니다. 문서에도 그렇고 테스트 결과도 그렇습니다. 다른 write 가 지원되는 포맷과 어떻게 다른지 탐구생활 해보도록 하겠습니다.

@aanoaa
Copy link
Author

aanoaa commented Jun 14, 2013

지금은 변경된 데이터를 고정된 header 의 Value-Length 만큼 자르고 대입합니다. 즉 헤더길이에 몸을 맞춥니다.
이렇게 하면 편리합니다.

VR(Value Representation) 는 고정인 것과 가변인 것이 있는데, 가변에 대한 계산을 고려하지 않아도 되기 때문입니다.
이를 지원하려면 가변인 VR 일때에 spec 에 정의된 MAX 값을 넘지 않는 범위내에서 Value-Field 를 설정하고 DataElement 의 Value-Length 를 다시 써주면 됩니다.

근데 또 조심해야 될것이 VR 에 따라 ByteSwap 이 이루어지는 것들이 있습니다.

@aanoaa
Copy link
Author

aanoaa commented Jun 16, 2013

위에 두개 사용하니까 잘됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment