Sponsored Content
Full Discussion: Perl Text Manipulation
Top Forums Shell Programming and Scripting Perl Text Manipulation Post 302404931 by durden_tyler on Wednesday 17th of March 2010 02:20:41 PM
Old 03-17-2010
Maybe something like this ?

Code:
C:\>
C:\> REM your data file is saved as "tiff_output.txt"
C:\> REM I don't show it here in order to save space
C:\> REM display the contents of the Perl program
C:\>
C:\> type tiff_process.pl
#!perl -w
# pass the filename as first argument; set the variable $infile to it
$infile = $ARGV[0];
# open the file
open (IN, $infile) or die "Can't open $infile: $!";
# loop through it
while (<IN>) {
  chomp;
  # if we've reached the "record-delimiter i.e. TYPE:" or EOF
  if (/^TYPE:/ or eof) {
    # check if array "@line" is defined; if so, print it after
    # appending the additional information after filetype i.e. 2nd element
    if (@line) {
      $line[1] .= "$cs:$r:$pi:$iw:$il:";
      foreach (@line) {print $_,"\n"}
      # Important - reset the array
      @line = ();
    }
  } else {
    # check for compression scheme, resolution, photometric interpretation,
    # image width and image length, and set the variables $cs, $r, $pi, $iw, $il
    if (/^\s*Compression Scheme:\s*(.*?)$/) {$cs = $1}
    elsif (/^\s*Resolution:\s*(.*?)$/) {$r = $1}
    elsif (/^\s*Photometric Interpretation:\s*(.*?)$/) {$pi = $1}
    elsif (/^\s*Image Width:\s*(.*?)\s*$/) {$iw = $1}
    elsif (/^\s*Image Length:\s*(.*?)$/) {$il = $1}
  }
  # add the current line to the array @line
  push @line, $_;
}
# clean up after we're done
close (IN) or die "Can't close $infile: $!";
C:\>
C:\>
C:\> REM execute the Perl program
C:\>
C:\> perl tiff_process.pl tiff_output.txt
TYPE:
filename.tif:CCITT Group 4:200, 200 pixels/inch:min-is-white:1728:2376:
TIFF Directory at offset 0x10eb4
  Image Width: 1728
  Image Length: 2376
  Resolution: 200, 200 pixels/inch
  Bits/Sample: 1
  Compression Scheme: CCITT Group 4
  Photometric Interpretation: min-is-white
  FillOrder: lsb-to-msb
  Document Name: "Standard Input"
  Image Description: "converted PBM file"
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 2376
  Planar Configuration: single image plane
TYPE:
filename2.tif:CCITT Group 4:200, 200 pixels/inch:min-is-white:1728:2376:
TIFF Directory at offset 0x4aac
  Image Width: 1728
  Image Length: 2376
  Resolution: 200, 200 pixels/inch
  Bits/Sample: 1
  Compression Scheme: CCITT Group 4
  Photometric Interpretation: min-is-white
  FillOrder: lsb-to-msb
  Document Name: "Standard Input"
  Image Description: "converted PBM file"
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 2376
  Planar Configuration: single image plane
TYPE:
filename3.tif:None:31, 31 pixels/inch:RGB color:124:124:
TIFF Directory at offset 0x8
  Subfile Type: (0 = 0x0)
  Image Width: 124
  Image Length: 124
  Resolution: 31, 31 pixels/inch
  Bits/Sample: 8
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Software: "╝"
  Samples/Pixel: 3
  Rows/Strip: 55
  Planar Configuration: single image plane
TYPE:
filename4.tif:LZW:300, 300 pixels/inch:RGB color:1419:1001:
TIFF Directory at offset 0x8
  Subfile Type: (0 = 0x0)
  Image Width: 1419
  Image Length: 1001
  Resolution: 300, 300 pixels/inch
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 1
  Planar Configuration: single image plane
  Photoshop Data: <present>, 410 bytes
C:\>
C:\>

HTH,
tyler_durden

Last edited by durden_tyler; 03-17-2010 at 04:17 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Text Manipulation.

Hi I have only ever used awk and sed for basic requirements up until now. I have had to break a log down for multiple purposes. Using awk, sed and a date script. I am left with this: (message id, time of msg attempt, message id, domain name, time of msg completion) ... (4 Replies)
Discussion started by: Icepick
4 Replies

2. UNIX for Dummies Questions & Answers

Help with text manipulation

Hi there, I have some text files in unix format that processed by a program in windows, and when I open them with less or vi in linux, a warn for opening binary file is prompted, and as shown in vi, between every two characters there was inserted a "^@". How can I fix this. Plus, there are over... (2 Replies)
Discussion started by: dustinwang2003
2 Replies

3. Shell Programming and Scripting

Perl Text manipulation

Hello All, I have been working on a great script to remotely gather server info and store it in a .txt that can be imported to .xls I have been reading the hostnames that are in the /.shh/known_hosts file so I don't have to mess with passing a password - via ssh (not easy to do , by the... (1 Reply)
Discussion started by: dfezz1
1 Replies

4. Shell Programming and Scripting

text manipulation

Hi All; i need to do text processing : I have a file: file1.txt >>>>>>>>>>>> 30 2 23 some 30 2 22 text 30 2 21 xyz 30 2 20 ttttt 30 2 19 ttttt-1 30 2 18 xryz 30 2 17 xyzr 30 2 16 xy111z 30 2 15 xanyyz 30 2 14 xzz 30 2 13 xyy 30 2 0 zzz-w 50 3 25 zzz-w 50 3 12 productw 50 3 10... (4 Replies)
Discussion started by: unlx
4 Replies

5. Shell Programming and Scripting

Text Manipulation Help

Hello unix.com people! How can I modify a text in format: A:B:C A:B:C A:B:C into C/A/B C/A/B C/A/B Note: Text is line by line and "C", "B", "A" fields are different each row. Thanks in advance. (7 Replies)
Discussion started by: galford
7 Replies

6. UNIX for Dummies Questions & Answers

text manipulation help

Hello again unix.com How can I extract from a large file in format: steve@aol.com steve hawkins Location of this member is bla bla bla sun@hotmail.com Sun Ying This member is using browser bla bla bla to another text in format: steve@aol.com steve hawkins sun@hotmail.com sun ying ... (5 Replies)
Discussion started by: galford
5 Replies

7. UNIX for Dummies Questions & Answers

Text Manipulation Help

Hello Unix.com, I have a text in format: john sara lee How can I make it: john:john john:john1 john:john12 john:john123 sara:sara sara:sara12 sara:sara123 and so on (2 Replies)
Discussion started by: galford
2 Replies

8. UNIX for Dummies Questions & Answers

Text manipulation help

Hello unix.com users, I have a ip file (line-by-line). How can I delete the ips that keep repeating by mark XXX.XXX.XXX.* ... I want to erase only the lines that keep repeating more than 2 times. Example: 1.2.3.1 1.2.3.2 1.2.3.3 I want to erase all ips blocks that are repeating by C... (1 Reply)
Discussion started by: galford
1 Replies

9. UNIX for Dummies Questions & Answers

Text manipulation help

Hello unix.com I'm having trouble with a text file. It looks like this: Alvaro Costa Daldit Kaur Sings Brian G Heward Desmond Ogilvie John Der William Gherasim Lance Mackey Donald Kopplin Robert Mckinlay Jahir Hussain Mohamed Jack Benaim Abraham Weiss I want... (7 Replies)
Discussion started by: galford
7 Replies

10. UNIX for Dummies Questions & Answers

Text manipulation

i want to generate a list line-by-line of normal characters using letters . for example : dnds gnos mgod pets jnfp etc... i want to use all letters with all the posibilities is there a script that can do this ? (3 Replies)
Discussion started by: suppliernr1
3 Replies
tiffcp(1)							   User Commands							 tiffcp(1)

NAME
tiffcp - copy, and possibly convert, a TIFF file SYNOPSIS
tiffcp [options] src1.tif... srcN.tif dest.tif DESCRIPTION
tiffcp combines one or more files created according to the Tag Image File Format, Revision 6.0 into a single TIFF file. The output file might be compressed using a different algorithm than the input files. Therefore. tiffcp is most often used to convert between different compression schemes. By default, tiffcp copies all of the understood tags in a TIFF directory of an input file, to the associated directory in the output file. tiffcp can be used to reorganize the storage characteristics of data in a file, but is explicitly intended to not alter or convert the image data content in any way. OPTIONS
The following options are supported: -B Force output to be written with Big-Endian byte order. This option only has an effect when the output file is created or overwritten. This option has no effect when you append to the output file. -C Suppress the use of "strip chopping" when reading images that have a single strip or tile of uncompressed data. -c Specify a compression scheme to use when writing image data: -c g3 CCITT Group 3 compression algorithm. -c g4 CCITT Group 4 compression algorithm. -c jpeg Baseline JPEG compression algorithm. -c lzw Lempel-Ziv and Welch algorithm. -c none No compression. -c packbits PackBits compression algorithm. -c zip Deflate compression algorithm. By default, tiffcp compresses data according to the value of the Compression tag found in the source file. -f Specify the bit fill order to use to write output data. By default, tiffcp creates a new file with the same fill order as the original. Specify -f lsb2msb to force data to be written with the FillOrder tag set to LSB2MSB. Specify -f msb2lsb to force data to be written with the FillOrder tag set to MSB2LSB. -l Specify the length of a tile in pixels. tiffcp attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile. -L Force output to be written with Little-Endian byte order. This option only has an effect when the output file is created or overwritten. This option has no effect when you append to the output file. -M Suppress the use of memory-mapped files when reading images. -p Explicitly select the planar configuration used to write image data that has one 8-bit sample per pixel. By default, tiffcp creates a new file with the same planar configuration as the original. -p contig Samples are packed contiguously. -p separate Samples are stored separately. -r Write data with a specified number of rows per strip. By default, the number of rows per strip is selected so that each strip is approximately 8 kilobytes. -s Force the output file to be written with data organized in strips instead of tiles. -t Force the output file to be written with data organized in tiles instead of strips. -w Specify the width of a tile in pixels. tiffcp attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile. OPERANDS
The following operands are supported: src.tif The name of the source file. dest.tif The name of the destination file. EXTENDED DESCRIPTION
The CCITT Group 3 and Group 4 compression algorithms can only be used with bilevel data. Group 3 compression can be specified together with several T.4-specific options: 1d 1-dimensional encoding 2d 2-dimensional encoding fill Force each encoded scanline to be zero-filled so that the terminating EOL code lies on a byte boundary. Group 3-specific options are specified by appending a colon-separated list to the g3 option. For example, specify -c g3:2d:fill to get 2D- encoded data with byte-aligned EOL codes. LZW compression can be specified together with a predictor value. A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before being encoded. A predictor value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a colon-separated list to the lzw option. For example, specify -c lzw:2 for LZW compression with horizontal differencing. EXAMPLES
Example 1: Concatenating Two Files and Writing the Result Using LZW Encoding example% tiffcp -c lzw a.tif b.tif result.tif Example 2: Converting a G3 1d-Encoded TIFF to a Single Strip of G4-Encoded Data example% tiffcp -c g4 -r 10000 g3.tif g4.tif In this example, 1000 is a number that is larger than the number of rows in the source file. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWTiff | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
pal2rgb(1), tiffinfo(1), tiffcmp(1), tiffmedian(1), tiffsplit(1), libtiff(3) NOTES
Updated by Breda McColgan, Sun Microsystems Inc., 2004. SunOS 5.10 26 Mar 2004 tiffcp(1)
All times are GMT -4. The time now is 08:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy