Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 76929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:45:01+00:00 2026-05-10T20:45:01+00:00

-Edit- FYI.. I am converting b&w documents scanned in as greyscale or color. 1)The

  • 0

-Edit- FYI.. I am converting b&w documents scanned in as greyscale or color.

1)The first solution worked, it just reversed black & white (black background, white text). It also took nearly 10 minutes.
2)The JAI solution in the 2nd answer didn’t work for me. I tried it before posting here.

Has anyone worked with other libraries free or pay that handle image manipulation well?

-Original- I am trying to convert an PNG to a bitonal TIFF using Java ImageIO. Has anyone had any luck doing this? I have got it to convert from PNG to TIFF. I am not sure if I need to convert the BufferedImage (PNG) that I read in or convert on the TIFF as I write it. I have searched and searched but nothing seems to work? Does anyone have an suggestions where to look?

Here is the code that converts…

public static void test() throws IOException {      String fileName = '4848970_1';     // String fileName = 'color';     String inFileType = '.PNG';     String outFileType = '.TIFF';      File fInputFile = new File('I:/HPF/UU/' + fileName + inFileType);     InputStream fis = new BufferedInputStream(new FileInputStream(fInputFile));     ImageReaderSpi spi = new PNGImageReaderSpi();     ImageReader reader = spi.createReaderInstance();     ImageInputStream iis = ImageIO.createImageInputStream(fis);     reader.setInput(iis, true);     BufferedImage bi = reader.read(0);      int[] xi = bi.getSampleModel().getSampleSize();      for (int i : xi) {         System.out.println('bitsize ' + i);     }      ImageWriterSpi tiffspi = new TIFFImageWriterSpi();     TIFFImageWriter writer = (TIFFImageWriter) tiffspi.createWriterInstance();      // TIFFImageWriteParam param = (TIFFImageWriteParam) writer.getDefaultWriteParam();     TIFFImageWriteParam param = new TIFFImageWriteParam(Locale.US);     String[] strings = param.getCompressionTypes();     for (String string : strings) {         System.out.println(string);     }      param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);     param.setCompressionType('LZW');      File fOutputFile = new File('I:\\HPF\\UU\\' + fileName + outFileType);     OutputStream fos = new BufferedOutputStream(new FileOutputStream(fOutputFile));     ImageOutputStream ios = ImageIO.createImageOutputStream(fos);      writer.setOutput(ios);     writer.write(null, new IIOImage(bi, null, null), param);      ios.flush();     writer.dispose();     ios.close();  } 

I have tried changing the compression to type ‘CCITT T.6’ as that appears to be what I want, but I get an error ‘ Bits per sample must be 1 for T6 compression! ‘ Any suggestion would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:45:02+00:00Added an answer on May 10, 2026 at 8:45 pm

    Most likely, you want something like this to convert to 1 bit before you save to TIFF with CCITT compression.

    To expound a little bit – be aware that converting from other bit depths to 1 bit is non-trivial. You are doing a data reduction operation and there are dozens of domain specific solutions which vary greatly in output quality (blind threshold, adaptive threshold, dithering, local threshold, global threshold and so on). None of them are particularly good at all image types (adaptive threshold is pretty good for documents, but lousy for photographs, for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Try using an abstract class for your domain object. class… May 11, 2026 at 8:58 am
  • added an answer The append method expects a string or DOM node as… May 11, 2026 at 8:58 am
  • added an answer Passes it by reference. Huh? Passing by reference means that… May 11, 2026 at 8:58 am

Related Questions

-Edit- FYI.. I am converting b&w documents scanned in as greyscale or color. 1)The
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT What small things which are too easy to overlook do I need to
Edit : Solved, there was a trigger with a loop on the table (read
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.