How to convert TIFFG4 compressed 1-bit bilevel to gray

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
pictogram
Posts: 17
Joined: 2010-03-23T14:19:21-07:00
Authentication code: 8675308

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by pictogram »

Wow 4mins. is way to long for what i need to do with this.
So what options do i may have to reduce this time dramatically?
Is the compression or the internal data structure (tiled,strips, or whatever) critical?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by fmw42 »

If your version of IM is still at 6.3.7 per your earlier message, then perhaps you really need to upgrade. You are over 200 versions behind.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by snibgo »

It was faster for me under Windows than Ubuntu. Oddly, the G4 version was quicker than uncompressed.

I would expect Q8 to be quicker than Q16. If you can chop up the file before IM sees it, that might help.
snibgo's IM pages: im.snibgo.com
pictogram
Posts: 17
Joined: 2010-03-23T14:19:21-07:00
Authentication code: 8675308

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by pictogram »

fmw42 wrote:If your version of IM is still at 6.3.7 per your earlier message, then perhaps you really need to upgrade. You are over 200 versions behind.
Well i guess you're right. But there is no more recent version available, so i think i had to compile it from source... if no one knows a repository holding a backport of 6.6 on Lenny.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by fmw42 »

FYI:

recent versions of IM are multiprocessor compatible. so if you have dual core or more then you should see speedups with OpenMP enabled (by default)
pictogram
Posts: 17
Joined: 2010-03-23T14:19:21-07:00
Authentication code: 8675308

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by pictogram »

I'm one step further. After compiling a current version from source, it works!
On my 3.4ghz Xeon it takes about 4 minutes (like stated before) to create the preview.
Even the preview contains a big black area (something is wrong), it is faaar to slow.

So, what can i do to find the source of this slowness and may speed things up.
It must not take more than 10 or 20 seconds.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by snibgo »

Q8 might double the speed.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by fmw42 »

On some machines with multiple processors it actually runs slower with OpenMP enable than without. You might try disabling OpenMP if you have multiple processors and see if that helps.
danbaatar

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by danbaatar »

I am trying to do this same thing, but I cannot get ImageMagick to output a grayscale tiff. I've tried -type Grayscale and -colorspace Gray, and the output is always a bi-level image. Could there be something I'm doing wrong?

I've tried to explicitly set the depth, and I get this output:

Code: Select all

$ ./convert page_1_subsampled.tiff -depth 8 -colorspace Gray page_1_grayscale.tiff
lt-convert: Bits/sample must be 1 for Group 3/4 encoding/decoding. `page_1_grayscale.tiff' @ error/tiff.c/TIFFErrors/494.
Version: ImageMagick 6.6.5-1 2010-10-20 Q16
also tried ImageMagick 6.5.7-8 2009-11-26 Q16 on Ubuntu

Thanks in advance,
dan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by fmw42 »

If you tiff is binary then you may not be able to get it to grayscale depending upon the compression in the file unless you change the compression. You can try adding -type grayscale.

You might post a link to your tiff file so others can examine it. (or at least post result from:

identify -verbose page_1_subsampled.tiff

also see http://www.imagemagick.org/Usage/formats/#tiff
danbaatar

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by danbaatar »

I have tried -type grayscale, but it gives me the same results. Changing the compression would be fine with me, but I haven't seen how to specify the compression on the output tiff.

Here is a link to my test tiff:
http://www.danandchoka.net/page_1.tiff

Thanks again,
dan
danbaatar

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by danbaatar »

Ah, never mind. I see that the link you sent talks about how to change the compression level. Just in case anyone else runs across this in the future, the command that works for me is:

Code: Select all

$ ./convert page_1_subsampled.tiff -compress lzw -depth 8 -colorspace Gray page_1_grayscale.tiff
For some reason, if I don't specify depth it still doesn't change from bilevel.

Thanks a ton for taking the time to help!

--dan
pictogram
Posts: 17
Joined: 2010-03-23T14:19:21-07:00
Authentication code: 8675308

Re: How to convert TIFFG4 compressed 1-bit bilevel to gray

Post by pictogram »

I've ended up with the fact that IM is not able to handle Group4-Compressed Bilevel files of that size. Or, to be more gently, it makes no sense to do it with IM.

I finally found a suiteable tool called thumbnail (bundled for Debian in "libtiff-tools") which uses the libtiff, a specialized library for TIFF file handling.
Making thumbs of an arbitrary size takes only seconds without consuming any noticeable memory.
Post Reply