dguy101
asked on
Ghostscript Tiff Conversion from PDF
I am using ghostscript to convert pdf to tiff. I am using v9.04. I am converting to tiff using -sDevice=tiffg4 with 200 resolution.
But sometimes our pdf has grey background. And the image output is not dithered right. Is there a way to improve grey background.
FYI... tiffg4 produces only black and white image.
Other option is using different output device such as tiffgray. But this adds some photometric tiff tag which I don't want. Is there a way to remove this tag in ghostscript.
See the sample document which is word but I have pdf for my test.
SAMPLE-DOCUMENT.docx
But sometimes our pdf has grey background. And the image output is not dithered right. Is there a way to improve grey background.
FYI... tiffg4 produces only black and white image.
Other option is using different output device such as tiffgray. But this adds some photometric tiff tag which I don't want. Is there a way to remove this tag in ghostscript.
See the sample document which is word but I have pdf for my test.
SAMPLE-DOCUMENT.docx
Try -sDEVICE=tiff24nc
ASKER
I cannot use tiff24nc, size gets bigger and also we only want greyscale.
Also can I remove tiff tags in ghoscript.
Also can I remove tiff tags in ghoscript.
Use imagemagick?
ASKER
How hard is to change to Imagemagick from ghostscript. ? I am using ghostscript in Java using ghost4j.
We have to use either tiffg4 or tiffscaed with g4compression and ability to remove tiff tags such as photometric.
We have to use either tiffg4 or tiffscaed with g4compression and ability to remove tiff tags such as photometric.
Try -sDevice=tiffgray
ASKER
I have tried all greyscale but it makes the tiff images inverted since it sets photometricinterpreation tag to blackiszero, which in some of the viewers will make image look inverted like a negative.
tiffgray attached
tiffgray.tif
tiffgray.tif
ASKER
Problem is with the attached image that it adds following Tiff Tag - PhotometricInterpretation= BlackIsZero.
This causes Image to inverted in our down stream application viewer called Daeja Viewer. We cannot change that.
This causes Image to inverted in our down stream application viewer called Daeja Viewer. We cannot change that.
ASKER
So I need to remove that Tag in Ghostscript if possible or different tiff device which is grayscale that does not add this tag.
Try this afterwards:
tiffset -s 262 0 image.tif
ASKER
where do i run this command.
this is what i have in java
this is what i have in java
Ghostscript gs = Ghostscript.getInstance();
if (gsArgs == null) {
gsArgs = new ArrayList<String>(15);
gsArgs.add("-dQUIET");
gsArgs.add("-dNOPAUSE");
gsArgs.add("-dBATCH");
gsArgs.add("-dSAFER");
if (GSThreadCount > 1) gsArgs.add("-dNumRenderingThreads=" + GSThreadCount);
gsArgs.add("-dPDFFitPage");
gsArgs.add("-sPAPERSIZE=" + input.getImportPaperSize());
gsArgs.add("-sDEVICE=tiffscaled");
// gsArgs.add("-sDEVICE=tiffscaled");
gsArgs.add("-sCompression=g3");
gsArgs.add("-sOutputFile=" + fileNamePrefix + "%06d" + System.currentTimeMillis() + ".tif");
// gsArgs.add("-c \"<< /Install { { 0.85 gt { 1 } { 0 } ifelse } settransfer } >> setpagedevice\"");
gsArgs.add("-r" + 150);
// gsArgs.add("-c '100 100 {dup mul exch dup mul add 2 div 1 exch sub} setscreen currenthalftone /Default exch /Halftone defineresource pop'");
}
gsArgs.add("-f");
gsArgs.add(file.getAbsolutePath());
try {
synchronized (gs) {
gs.initialize(gsArgs.toArray(new String[gsArgs.size()]));
gs.exit();
}
That's another program. I think you could do it with JAI too - try googling it (JAI BalckIsZero)
ASKER
I know I can use JAI to remove it, but wanted to see if anything is out there using ghostscript so I don't have to recreate image again using JAI since we upload like 1000 of images
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good to have this done in ghostscript or replace ghostscript with some other framework
Why? Why post a proprietary format when your actual format is an open one??