Solved

Ghostscript Tiff Conversion from PDF

Posted on 2014-10-09
16
624 Views
Last Modified: 2014-10-17
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
0
Comment
Question by:dguy101
  • 8
  • 8
16 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40372477
which is word

Why? Why post a proprietary format when your actual format is an open one??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40372490
Try -sDEVICE=tiff24nc
0
 

Author Comment

by:dguy101
ID: 40372569
I cannot use tiff24nc, size gets bigger and also we only want greyscale.


Also can I remove tiff tags in ghoscript.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 86

Expert Comment

by:CEHJ
ID: 40372585
Use imagemagick?
0
 

Author Comment

by:dguy101
ID: 40372607
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40372608
Try -sDevice=tiffgray
0
 

Author Comment

by:dguy101
ID: 40372611
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40372657
tiffgray attached
tiffgray.tif
0
 

Author Comment

by:dguy101
ID: 40373503
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.
0
 

Author Comment

by:dguy101
ID: 40373505
So I need to remove that Tag in Ghostscript if possible or different tiff device which is grayscale that does not add this tag.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40373646
Try this afterwards:

tiffset -s 262 0 image.tif

Open in new window

0
 

Author Comment

by:dguy101
ID: 40373774
where do i run this command.
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();
                }

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40373786
That's another program. I think you could do it with JAI too - try googling it (JAI BalckIsZero)
0
 

Author Comment

by:dguy101
ID: 40383313
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
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 40383792
Not that i can find
0
 

Author Closing Comment

by:dguy101
ID: 40386797
Good to have this done in ghostscript or replace ghostscript with some other framework
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 62
tomcat administrtor 12 61
How to configure empty element in XML Document parser? 15 36
Java class and jar 3 24
In a previous article here at Experts Exchange (http://www.experts-exchange.com/articles/18414/Create-a-PDF-file-with-Contact-Sheets-montage-of-thumbnails-for-all-JPG-files-in-a-folder-and-each-of-its-subfolders-using-an-automated-batch-method.html)…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Microsoft Office Picture Manager is not included in Office 2013. This comes as quite a surprise to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This video expla…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question