Michal Josef Špaček

NAME

Dicom::File::Detect - Detect DICOM file through magic string.

SYNOPSIS

 use Dicom::File::Detect qw(dicom_detect_file);
 my $dcm_flag = dicom_detect_file($file);

DESCRIPTION

This Perl module detect DICOM file through magic string. DICOM (Digital Imaging and Communications in Medicine) is a standard for handling, storing, printing, and transmitting information in medical imaging. See DICOM on Wikipedia.

SUBROUTINES

dicom_detect_file($file)
 Detect DICOM file.
 Returns 1/0.

ERRORS

 dicom_detect_file():
         Cannot close file '%s'.
         Cannot open file '%s'.

EXAMPLE1

 # Pragmas.
 use strict;
 use warnings;

 # Modules.
 use Dicom::File::Detect qw(dicom_detect_file);
 use File::Temp qw(tempfile);
 use IO::Barf qw(barf);
 use MIME::Base64;

 # Data in base64.
 my $data = <<'END';
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 AAAAAAAAAAAAAAAAAABESUNNCg==
 END

 # Temp file.
 my (undef, $temp_file) = tempfile();

 # Save data to file.
 barf($temp_file, decode_base64($data));

 # Check file.
 my $dcm_flag = dicom_detect_file($temp_file);

 # Print out.
 if ($dcm_flag) {
         print "File '$temp_file' is DICOM file.\n";
 } else {
         print "File '$temp_file' isn't DICOM file.\n";
 }

 # Output like:
 # File '%s' is DICOM file.

EXAMPLE2

 # Pragmas.
 use strict;
 use warnings;

 # Modules.
 use Dicom::File::Detect qw(dicom_detect_file);

 # Arguments.
 if (@ARGV < 1) {
         print STDERR "Usage: $0 file\n";
         exit 1;
 }
 my $file = $ARGV[0];

 # Check file.
 my $dcm_flag = dicom_detect_file($file);

 # Print out.
 if ($dcm_flag) {
         print "File '$file' is DICOM file.\n";
 } else {
         print "File '$file' isn't DICOM file.\n";
 }

 # Output:
 # Usage: dicom-detect-file file

DEPENDENCIES

Error::Pure, Exporter, Readonly.

SEE ALSO

File::Find::Rule::Dicom

Common rules for searching for DICOM things.

Task::Dicom

Install the Dicom modules.

REPOSITORY

https://github.com/tupinek/Dicom-File-Detect

AUTHOR

Michal Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

 © 2014-2015 Michal Špaček
 BSD 2-Clause License

VERSION

0.03