public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: TIFF I/O, netpbm
@ 1998-10-29  9:39 Stephen E. Schweibinz
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen E. Schweibinz @ 1998-10-29  9:39 UTC (permalink / raw)
  To: gnu-win32; +Cc: plan

In response to my own question, my problem was that
I was expecting TIFF output while apparently the output
is PGM.  Thus, my 
tiffcut 100 100 200 200 input.tif > output.tif
obviously wouldn't work since it should be 'output.pgm'.

HOWEVER, the additions of the line 
setmode(fd, O_BINARY);
was critical to making this work and may be useful to
someone else working with the libtiff utilities.

Later,
Steve Schweibinz

__________
/*******************************************************

   Stephen E. Schweibinz
   Planning Support Systems Group, MCP candidate, MIT
   (617) 679-0360
   plan@mit.edu
   http://www.vcp.com

*******************************************************/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: TIFF I/O, netpbm
  1998-10-28 23:22 Stephen E. Schweibinz
@ 1998-10-30  5:08 ` Mumit Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Mumit Khan @ 1998-10-30  5:08 UTC (permalink / raw)
  To: Stephen E. Schweibinz; +Cc: gnu-win32

"Stephen E. Schweibinz" <plan@mit.edu> writes:
> 
> 
> However the output TIFF file cannot be opened properly in a viewer.
> I have a feeling I need to add the following
> 
> setmode(fileno(stdout), O_BINARY);
> 
> where the output of the TIFF is occuring, but I am not sure where
> I should stick this line or if this is even the problem.  

Do yourself a favor and simply add a '--output ofile' or '-o ofile'
option and just use that instead of writing to standard output. 
Make life a little easier (that patch I had sent had an example of
that -- see ppm_openw).

If you want to use file redirection or piping and get the right output,
you'll need to do what you suggest above. Just stick the setmode before 
any write to stdout.
  
  fflush (stdout);
  setmode (fileno (stdout), O_BINARY);

or, you can use binary mounts.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* TIFF I/O, netpbm
@ 1998-10-28 23:22 Stephen E. Schweibinz
  1998-10-30  5:08 ` Mumit Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen E. Schweibinz @ 1998-10-28 23:22 UTC (permalink / raw)
  To: gnu-win32; +Cc: jdevans, plan

Thanks for the response concerning my question about
"undefined reference to 'errno'."  As it turned out
the problem was in fact that

>(the problem) is because of non-ANSI behaviour in lots of old code 
>where instead of include errno.h, the code declares an 
>"extern int errno" which is wrong.

The "netpbm" graphics utilities suite compiled fine after the change.

**********************************************************************

However, I have run into difficulty getting the TIFF I/O utilities
to work.  I am running a program called tiffcut.c that inputs a TIFF
image and outputs a clipped TIFF given your clipping parameters.


After drilling down through the code I finally found the unix like i/o
calls in tif_unix.c.

/*
 * Open a TIFF file for read/writing.
 */
TIFF*
TIFFOpen(const char* name, const char* mode)
{
	static const char module[] = "TIFFOpen";
	int m, fd;

	m = _TIFFgetMode(mode, module);
	if (m == -1)
		return ((TIFF*)0);
#ifdef _AM29K
	fd = open(name, m);
/*I added the following line to open the tiff in binary form*/
	setmode(fd, O_BINARY);


 
#else
	fd = open(name, m, 0666);
/*I added the following line to open the tiff in binary form*/
	setmode(fd, O_BINARY);

#endif
	if (fd < 0) {
		TIFFError(module, "%s: Cannot open", name);
		return ((TIFF *)0);
	}
	return (TIFFFdOpen(fd, name, mode));
}

I checked the archives of the Gnu-Win32 mailing list and found that
I needed to add "setmode(fd, O_BINARY)" (which I did above)
for the open statement to properly read in the binary TIFF.  
This got rid of the error
"Can not read TIFF directory."

However the output TIFF file cannot be opened properly in a viewer.
I have a feeling I need to add the following

setmode(fileno(stdout), O_BINARY);

where the output of the TIFF is occuring, but I am not sure where
I should stick this line or if this is even the problem.  

If anyone using netpbm and the libtiff utilities has come across
porting problems inputing and outputing TIFFs using the libtiff
included in netpbm,  please let me know your solutions.

Thanks much,
Stephen Schweibinz
__________
/*******************************************************

   Stephen E. Schweibinz
   Planning Support Systems Group, MCP candidate, MIT
   (617) 679-0360
   plan@mit.edu
   http://www.vcp.com

*******************************************************/


















-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-10-30  5:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-29  9:39 TIFF I/O, netpbm Stephen E. Schweibinz
  -- strict thread matches above, loose matches on Subject: below --
1998-10-28 23:22 Stephen E. Schweibinz
1998-10-30  5:08 ` Mumit Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).