Recent

Author Topic: Read 1 bit tiff file  (Read 5419 times)

SteenJorgensen

  • Jr. Member
  • **
  • Posts: 68
Read 1 bit tiff file
« on: October 20, 2019, 09:48:46 am »
I have a problem reading a 1.bit compress tiff file.


Using IntfGraphics, FPReadTiff, FPWriteTiff units.
My code is:
Code: Pascal  [Select][+][-]
  1.     img := TLazIntfImage.Create(0,0);
  2.     img.DataDescription := GetDescriptionFromDevice(0);
  3.     rt := TFPReaderTiff.create;
  4.     img.LoadFromFile(FileName,rt);
  5.     Image2.Picture.Bitmap.LoadFromIntfImage(img);
  6.     rt.free;
  7.     img.free;
  8.  

I get this excpetion:
compression CCITT Group 4 fax encoding not supported yet at position 59222

How to read this???
----------------------------------------
Lazarus version 2.0.12 64-bit
FPC 3.2.0

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Read 1 bit tiff file
« Reply #1 on: October 20, 2019, 10:00:08 am »
> compression CCITT Group 4 fax encoding not supported yet

I suspect it means what it says.

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #2 on: October 20, 2019, 12:05:03 pm »
There is no support for it in BGRABitmap and as far as I can see Vampyre Imagine Library doesn't either. On the other hand LibTIFF seem to read it.

Or you can try and write the decoding function from the documentation. I guess I found the specifications:
https://www.itu.int/rec/T-REC-T.6-198811-I/en

The decoding function basically would take a memory block as parameter (pointer and size) and return a new memory block.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #3 on: October 20, 2019, 12:40:28 pm »
Hi!

Use the ImageMagick package. You don't need to download anything.
It is installed in the fpc sources in /packages/imagemagick/

Documentation at https://wiki.freepascal.org/PascalMagick

Winni

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #4 on: October 20, 2019, 09:50:00 pm »
Hmm it seems that only the headers (PascalMagick) are included in fpc, you still need to download/install the ImageMagick library.

And in fact this library itself depends on LibTiff.
https://imagemagick.org/script/formats.php
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #5 on: October 20, 2019, 10:36:26 pm »
@circular

I have already converted Faxes with ImageMagick.

And indeed: exactly on the ImageMagick page you linked is also the format FAX which is a shortcut for TIFF with a lot of parameters.FAX is Fax Group 3. I don't know if they meanwhile implemented Fax Group 4.

Winni


circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #6 on: October 20, 2019, 11:59:41 pm »
Yes LibTiff handles fax group 4 as well and ImageMagick use LibTiff.

Si you never installed ImageMagick but used it?
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #7 on: October 21, 2019, 12:41:01 am »
Yes.

At the linux command line and in shell scripts.

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #8 on: October 21, 2019, 04:02:32 pm »
Hmm ok. Well it is then part of the Linux distribution. Though on Windows, that wouldn't be the case.

How do you call it from the command line? Even though the package is installed on my distro (Linux Mint Xfce), the command "magick" is not recognized.

Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #9 on: October 21, 2019, 04:21:38 pm »
Hmm apparently, it is because I have version 6 in my distro. The other commands like display, identify etc. seem to work though.

There's a nice tutorial here for ImageMagick:
https://www.youtube.com/watch?v=LWwdNoh2aIA
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #10 on: October 21, 2019, 05:07:14 pm »
Hi!

ImageMagick at the command line for linux and little bit later for windows exist since the beginning of the 90s.

The package is called ImageMagick.
On the command line you call it with magick and a lot of parameters.
But there are a lot of commands more like animate, composite and montage.
See the "Tools" page at https://imagemagick.org

On Suse and on Apple it is included in the standard instalation.

One reason to put magick into a shell script is the horrible amount of possible parameters. So you can write a script for your special needs.

The other reason is doing some loop stuff  for great quantity of images. "Please help me to downsize these 600 photos for the web" - asked me a friend. She owns a Graphic Studio. 5 Minutes searching the terminal on an Apple (unknown OS!), 10 minutes writing a script including magick. Then you can go smoking. While the computer works.

The pascal interface  came a lot of time later than the command line version - I think.

Winni

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #11 on: October 21, 2019, 10:27:35 pm »
That's all great.

Well, maybe I'd rather eat some vegetables than smoke.  :-[

Though I am not sure you read what I wrote. On my distro "magick" is not recognized as a command.

But to go back to the first query, SteenJorgensen, it depends what you want to do. Is it a Linux program or cross-platform? Is it ok using an external library in the case of Windows?

Because of course, one simple solution would be to convert it using an external program, like ImageMagick command line for example.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #12 on: October 21, 2019, 11:45:08 pm »
Hi!

Just tested magick on a terminal - no problems. Reinstall the package??
And what distro??
Or: Is the path to the magick binary set?
And: Has the binary enough rights???
Hmmm.

ImageMagick was developed with Linux, but a year later the delivered the first windows version. But I never worked on windows with it. I don't know what dll are used.

1-Bit-Tiff to another file format: On the job I made 10 years ago (or more) a little script for faxes:

Hylafax delivers a 1Bit Class 3 Tif. My script converts it to Postscript and sends it to the printer. Never had problems in all those years. Nearly forgot it.

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Read 1 bit tiff file
« Reply #13 on: October 21, 2019, 11:59:15 pm »
HI

ImageMagick without magic!?

There are some versions of ImageMagick delivered without magick!
You should use convert ! For whatever  reasons.

See discussion at: http://www.imagemagick.org/discourse-server/viewtopic.php?t=31986

Strange.

Winni

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Read 1 bit tiff file
« Reply #14 on: October 22, 2019, 09:58:23 am »
Relax.

In this discussion you linked they seem to say that it is in version 6 that magick command doesn't exist as I supposed earlier. To be precise I have version 6.9.7. Again my distro is Linux Mint Xfce, nothing too fancy.

convert and identify do work though.

What's surprising as well is that python command points to version 2.7.15+ but there is python3 as well which points to version 3.6.7.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018