Hi, I'm somewhat embarrassed since I've been programming Perl for 7+ years now. I can't figure out how to flip a little-endian TIFF file created on a Windows 3.1 machine to a big-endian TIFF file readable on a Sun Solaris machine.

Right now I have this (as little2big), which doesn't work:

#!/usr/bin/perl die "Usage: $0 filename\n" unless @ARGV == 1; my $file = shift; my $buf; open IN, $file or die "Can't read $file: $!\n"; while (read(IN, $buf, 4)) { print pack "N", unpack "V", $buf; } close IN;
Then I try:
little2big little-endian.tif >big-endian.tif
When I do this, all I get is "data" as a file type.

I've also tried reading 2 bytes and then using the pack/unpack templates n/v, but it doesn't flip anything correctly.

What am I missing? I feel like a Dumass. Thanks...

-Nate


In reply to How to flip little-endian TIFF to big-endian? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.