Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: warz on April 07, 2010, 01:19:17 pm

Title: Create a tiff image of any file type?
Post by: warz on April 07, 2010, 01:19:17 pm
I've been writing various revisions of an application that I use at work on a regular basis. The application's purpose is to convert any file type to a tiff image. In other words, create a tiff image of that file.

Originally, I used the Windows Imaging Printer Driver, or whatever it is called. It's the built in Windows printer driver that converts what you print to an image output file. This does tiff, and it was fast. The problem with this was that it was finicky. The application has to run in the background and require no user intervention. The Windows Imaging printer would often error out and I don't think it was able to convert "anything" to an output image.

I looked for toolkit solutions that I could use with C# and that wouldn't require an external printer driver. I found one (http://www.aspose.com/) toolkit, but it didn't support a wide range of file types - lacked Visio, most notably. I believe the lack of file type support is because it doesn't require Office to print, so they're somehow imeplementing their own print rendering methods for each type, or however that works. I didn't find many others that looked professional enough to use.

I went back to the printer driver solution, but this time found a printer driver (http://www.print-driver.com/sdk/) written for my exact purpose. It can take most any input that I've tried, so far, and converts it to an output image. It still relies on host applications to provide the print feature, but can supposedly be fed raw file data and determine how to render it on it's own. I've tried this and haven't been able to get it to print anything, yet. It just enters and leaves the print spool.

Anyways, I'm just wondering if anyone knows of a toolkit that can essentially do this. I know I could just as easily use Adobe to convert anything to a PDF, but TIFF is a standard we have to follow.
Title: Re: Create a tiff image of any file type?
Post by: rabbit on April 07, 2010, 01:28:01 pm
ImageMagick :D
Title: Re: Create a tiff image of any file type?
Post by: warz on April 07, 2010, 01:44:51 pm
I've seen that before, and I think it only does mostly image to image converstions. Like png to tiff.
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 07, 2010, 01:48:58 pm
I'm pretty sure ImageMagick can do PDF => TIFF:

^_^[@rhubarb][~][1006][Wed Apr 07, 11:48:27]
$ ll WALKING_CATFISH.*
-rw------- 1 mullins under 137K 2010-03-13 00:25 WALKING_CATFISH.pdf

^_^[@rhubarb][~][1007][Wed Apr 07, 11:48:28]
$ convert WALKING_CATFISH.pdf WALKING_CATFISH.tiff; ll WALKING_CATFISH.*
-rw------- 1 mullins under 137K 2010-03-13 00:25 WALKING_CATFISH.pdf
-rw------- 1 mullins under 6.5M 2010-04-07 11:48 WALKING_CATFISH.tiff


I have no clue why I have that file...
Title: Re: Create a tiff image of any file type?
Post by: warz on April 08, 2010, 07:35:56 pm
^ ugliest console prompt ever lol.

anyways, image magick only works for image file types. not things like word, excel, etc. i may have to mix and match a bunch of crap together.

on a different note, ive found a completely undocumented function in Microsoft's Office Interop dll for Excel in C#. cant even figure out how to properly call it based on the params, and the VB documentation for something similar. =(
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 08, 2010, 07:44:41 pm
You said you could "just as easily have Adobe convert everything to PDF".  This is a trivial additional step.
Title: Re: Create a tiff image of any file type?
Post by: MyndFyre on April 08, 2010, 09:35:05 pm
If you can go to pdf first, you can use ABCpdf from WebSuperGoo to convert a lot of formats to PDF.
Title: Re: Create a tiff image of any file type?
Post by: warz on April 09, 2010, 10:31:28 am
You said you could "just as easily have Adobe convert everything to PDF".  This is a trivial additional step.

Yea, the step is trivial but include it in a process that involves converting 800GB of files to TIFF. That's going to like double the amount of time it takes. Basically, when I said that, I was just acknowledging the fact that I had already thought about the Everything -> PDF -> TIFF process and dismissed it.

There are plenty of projects that do individual file types to TIFF. I'm just going to have to continue integrating them all into my project. I was just hoping that somebody had possibly done exactly what I'm doing already.
Title: Re: Create a tiff image of any file type?
Post by: Joe on April 09, 2010, 12:17:43 pm
You could just do it the way you're doing it right now and add PDF as the uhoh clause.
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 09, 2010, 01:05:27 pm
You said you could "just as easily have Adobe convert everything to PDF".  This is a trivial additional step.

Yea, the step is trivial but include it in a process that involves converting 800GB of files to TIFF. That's going to like double the amount of time it takes. Basically, when I said that, I was just acknowledging the fact that I had already thought about the Everything -> PDF -> TIFF process and dismissed it.

There are plenty of projects that do individual file types to TIFF. I'm just going to have to continue integrating them all into my project. I was just hoping that somebody had possibly done exactly what I'm doing already.

Ah.  I guess I didn't understand.

Sorry, then.  Good luck!
Title: Re: Create a tiff image of any file type?
Post by: nslay on April 13, 2010, 08:38:51 am
Code: [Select]
#!/bin/sh

for dir
do
        for img in $dir/*.jpg $dir/*.jpeg $dir/*.png $dir/*.bmp
        do  
                [ ! -f "$img" ] && continue
                tiff=`echo $img | sed 's/\\.[^.]*$/.tiff/'`
                echo "$img -> $tiff"
                convert "$img" "$tiff"
        done
done

./mkeverythingtiff.sh dir1 dir2 dir3 ...

EDIT: Made regex more robust, changed 'break' to 'continue'
Title: Re: Create a tiff image of any file type?
Post by: warz on April 13, 2010, 12:26:31 pm
Yes, that's great for doing image type -> image type conversions. I've had that under control. My main concern was other file types, such and Word and Excel documents -> tiff. I've got those converting to tiff, also, but I was curious if anyone knew of other "all in one" integration tools for this.
Title: Re: Create a tiff image of any file type?
Post by: nslay on April 13, 2010, 05:17:56 pm
Yes, that's great for doing image type -> image type conversions. I've had that under control. My main concern was other file types, such and Word and Excel documents -> tiff. I've got those converting to tiff, also, but I was curious if anyone knew of other "all in one" integration tools for this.
ImageMagick can also convert some document formats like pdf or postscript.  Don't use it to convert vector formats to other vector formats though ... it needlessly rasterizes vector images so that you end up with a very large and useless output vector format.

For other formats, basically it boils down to pdf or postscript.  Just print Excel, Word, etc... files to pdf or postscript.
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 13, 2010, 06:51:07 pm
Yes, that's great for doing image type -> image type conversions. I've had that under control. My main concern was other file types, such and Word and Excel documents -> tiff. I've got those converting to tiff, also, but I was curious if anyone knew of other "all in one" integration tools for this.
ImageMagick can also convert some document formats like pdf or postscript.  Don't use it to convert vector formats to other vector formats though ... it needlessly rasterizes vector images so that you end up with a very large and useless output vector format.

For other formats, basically it boils down to pdf or postscript.  Just print Excel, Word, etc... files to pdf or postscript.

Someone didn't read some of the other posts. ;)
Title: Re: Create a tiff image of any file type?
Post by: iago on April 13, 2010, 09:05:27 pm
Hey, why don't you use imagemagick?
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 13, 2010, 09:14:20 pm
Hey, why don't you use imagemagick?
/me punches iago
Title: Re: Create a tiff image of any file type?
Post by: nslay on April 14, 2010, 01:08:41 am
Yes, that's great for doing image type -> image type conversions. I've had that under control. My main concern was other file types, such and Word and Excel documents -> tiff. I've got those converting to tiff, also, but I was curious if anyone knew of other "all in one" integration tools for this.
ImageMagick can also convert some document formats like pdf or postscript.  Don't use it to convert vector formats to other vector formats though ... it needlessly rasterizes vector images so that you end up with a very large and useless output vector format.

For other formats, basically it boils down to pdf or postscript.  Just print Excel, Word, etc... files to pdf or postscript.

Someone didn't read some of the other posts. ;)
I read other posts.  I emphasized that you really have no choice for non-image formats except to print them to postscript or pdf ... not that ImageMagick could or could not convert pdf to tiff.  Someone didn't read other posts carefully.

P.S. Printing systems such as CUPS invoke ghostscript in the background and do deal with postscript implicitly ... hence the word "print" as opposed to "using Adobe to convert them to PDF".  So anything that is printable, that isn't an image, can be converted to tiff by way of ImageMagick.  Again, not the same as "I'm pretty sure ImageMagick can do PDF".
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 14, 2010, 01:15:14 am
I read other posts.  I emphasized that you really have no choice for non-image formats except to print them to postscript or pdf ... not that ImageMagick could or could not convert pdf to tiff.  Someone didn't read other posts carefully.

warz said a few times that he's already considered going from X -> pdf/ps -> tiff, and that it's an unacceptable solution because the files he's converting are huge.  He's also said he's encountered some software that uses printer drivers (as most X -> pdf/ps applications do) to do X -> tiff, and that he was wondering if anyone had had previous experience with similar software.

That's why I said that.  Everything you said had already been considered.  I'm not complaining.  I'm just saying I don't think the solution you provided will work for warz for reasons he's already mentioned.
Title: Re: Create a tiff image of any file type?
Post by: nslay on April 14, 2010, 01:36:32 am
I read other posts.  I emphasized that you really have no choice for non-image formats except to print them to postscript or pdf ... not that ImageMagick could or could not convert pdf to tiff.  Someone didn't read other posts carefully.

warz said a few times that he's already considered going from X -> pdf/ps -> tiff, and that it's an unacceptable solution because the files he's converting are huge.  He's also said he's encountered some software that uses printer drivers (as most X -> pdf/ps applications do) to do X -> tiff, and that he was wondering if anyone had had previous experience with similar software.
Too bad.  He wants an image from a non-image format.  The corresponding programs usually only deliver graphic output through the print system so he doesn't really have a choice does he?
Quote
That's why I said that.  Everything you said had already been considered.  I'm not complaining.  I'm just saying I don't think the solution you provided will work for warz for reasons he's already mentioned.
Not really, because you didn't mention he didn't really have a choice.  I suppose he could find/write a tiff printer driver (would probably convert to tiff from an intermediate format anyways).  I mean, he has to go through the print system for non-image formats ... only those programs understand how to generate graphical outputs for those non-image formats and most of them deliver that output through the print system.  Too bad ... it sucks, but there you go.
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 14, 2010, 01:42:27 am
Too bad.  He wants an image from a non-image format.  The corresponding programs usually only deliver graphic output through the print system so he doesn't really have a choice does he?

Not really, because you didn't mention he didn't really have a choice.  I suppose he could find/write a tiff printer driver (would probably convert to tiff from an intermediate format anyways).  I mean, he has to go through the print system for non-image formats ... only those programs understand how to generate graphical outputs for those non-image formats and most of them deliver that output through the print system.  Too bad ... it sucks, but there you go.

He seems to suggest that he's found an exception to the "usually" ...?  It wasn't just me, FYI.  I didn't respond to say "I ALREADY SAID THAT JERK"... was just saying that your proposed solution didn't match the criteria he had provided.  Also, you didn't say "you don't have a choice".  You just suggested X -> ps/pdf -> tiff like everyone else had.  If you were meaning to "emphasize" the fact that he was stuck, you didn't do a very good job. ;)

If that's true, then it sounds like he's SOL... he seemed to suggest otherwise, and that he was just looking for someone who'd dealt with the problem before.
Title: Re: Create a tiff image of any file type?
Post by: nslay on April 14, 2010, 01:48:14 am
Too bad.  He wants an image from a non-image format.  The corresponding programs usually only deliver graphic output through the print system so he doesn't really have a choice does he?

Not really, because you didn't mention he didn't really have a choice.  I suppose he could find/write a tiff printer driver (would probably convert to tiff from an intermediate format anyways).  I mean, he has to go through the print system for non-image formats ... only those programs understand how to generate graphical outputs for those non-image formats and most of them deliver that output through the print system.  Too bad ... it sucks, but there you go.

He seems to suggest that he's found an exception to the "usually" ...?  It wasn't just me, FYI.  I didn't respond to say "I ALREADY SAID THAT JERK"... was just saying that your proposed solution didn't match the criteria he had provided.  Also, you didn't say "you don't have a choice".  You just suggested X -> ps/pdf -> tiff like everyone else had.  If you were meaning to "emphasize" the fact that he was stuck, you didn't do a very good job. ;)

If that's true, then it sounds like he's SOL... he seemed to suggest otherwise, and that he was just looking for someone who'd dealt with the problem before.

I'm sorry.  I'm just in a bad mood.

The best he can do is a tiff printer driver (and they are all over Google).  The only program that understands how to render a non-image format is that program itself and it usually exports that through the print system.  I don't see how you can avoid printing aside of writing your own reader that can render the non-image format.
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 14, 2010, 01:53:03 am
Aah, okay.  Seems like pretty good evidence of being screwed, then. :)
Title: Re: Create a tiff image of any file type?
Post by: warz on April 23, 2010, 07:31:11 pm
Too bad.  He wants an image from a non-image format.  The corresponding programs usually only deliver graphic output through the print system so he doesn't really have a choice does he?

Nope, not accurate. I have found one toolkit that does do Word, Excel and PowerPoint to TIFF without using a printer driver. It does conversions without even requiring Office or a printer. I have no clue how it works, but I know that it does work. So, I do have a choice.

He seems to suggest that he's found an exception to the "usually" ...?  It wasn't just me, FYI.  I didn't respond to say "I ALREADY SAID THAT JERK"... was just saying that your proposed solution didn't match the criteria he had provided.  Also, you didn't say "you don't have a choice".  You just suggested X -> ps/pdf -> tiff like everyone else had.  If you were meaning to "emphasize" the fact that he was stuck, you didn't do a very good job. ;)

If that's true, then it sounds like he's SOL... he seemed to suggest otherwise, and that he was just looking for someone who'd dealt with the problem before.

Correct.

The best he can do is a tiff printer driver (and they are all over Google).  The only program that understands how to render a non-image format is that program itself and it usually exports that through the print system.  I don't see how you can avoid printing aside of writing your own reader that can render the non-image format.

Nope.

Aah, okay.  Seems like pretty good evidence of being screwed, then. :)

Nope. :P
Title: Re: Create a tiff image of any file type?
Post by: Sidoh on April 30, 2010, 12:08:12 am
Hmm... what nslay said made sense to me, but that's probably because I don't know much about how printer drivers work.  It seemed to indicate that everything goes to postscript anyway, so at some level, you're still converting from postscript.

I guess I misunderstood. :)