Recent

Author Topic: libTIFF for Lazarus - reading and writing TIF images  (Read 1528 times)

Tomxe

  • New Member
  • *
  • Posts: 37
libTIFF for Lazarus - reading and writing TIF images
« on: February 16, 2025, 04:07:25 am »
https://github.com/Xelitan/TIFF-for-Delphi-Lazarus-Free-Pascal/
License: MIT

Usage examples

Code: Pascal  [Select][+][-]
  1.   Image1.Picture.LoadFromFile('test.tif');


Code: Pascal  [Select][+][-]
  1. var t: TTifImage;
  2. begin
  3.  Image1.Picture.LoadFromFile('test.bmp');
  4.  
  5.  t := TTifImage.Create;
  6.  t.Assign(Image1.Picture.Bitmap);
  7.  t.SetCompression(COMPRESSION_LZW);
  8.  t.SaveToFile('out.tif');
  9.  t.Free;

- uncompressed
- CCITT3
- CCITT4
- LZW   
- JPEG 
- ADOBE DEFLATE
- PACKBITS
- DEFLATE (aka ZIP)
- LZMA2     //rare
- Zstandard //rare
- WebP      //rare

It can read formats that Lazarus' TIFF library doesn't support, like CCIT3.
« Last Edit: February 16, 2025, 08:05:44 pm by Tomxe »

Thaddy

  • Hero Member
  • *****
  • Posts: 16652
  • Kallstadt seems a good place to evict Trump to.
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #1 on: February 16, 2025, 10:25:07 am »
Why would we need that?
Tiff support (read and write, most formats) is in fcl-image, so in the default dfistribution. And it is fully native Pascal.
But I am sure they don't want the Trumps back...

Tomxe

  • New Member
  • *
  • Posts: 37
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #2 on: February 16, 2025, 10:34:37 am »
Great question, Thaddy!
I just updated my post. This is the reference TIFF implementation and it supports way more TIFF formats than TIFF library available in Lazarus.

Hartmut

  • Hero Member
  • *****
  • Posts: 893
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #3 on: February 16, 2025, 11:02:21 am »
Why would we need that?
Tiff support (read and write, most formats) is in fcl-image, so in the default dfistribution. And it is fully native Pascal.

I see 2 reasons:
1) TIF support in fcl-image cannot read all TIF-Images, only some
2) if you write a TIF-Image with fcl-image, then it cannot be read by fcl-image again (returns Error "Tags must be in ascending order")

Thaddy

  • Hero Member
  • *****
  • Posts: 16652
  • Kallstadt seems a good place to evict Trump to.
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #4 on: February 16, 2025, 11:04:02 am »
CCITT group 3 is - has always been - supported by fcl-image. Only quirkyness is it it implementated at group member level.
It is also less relevant because these are older formats like rle and fax.
But I am sure they don't want the Trumps back...

Thaddy

  • Hero Member
  • *****
  • Posts: 16652
  • Kallstadt seems a good place to evict Trump to.
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #5 on: February 16, 2025, 11:06:42 am »
2) if you write a TIF-Image with fcl-image, then it cannot be read by fcl-image again (returns Error "Tags must be in ascending order")
I have no opinion about that since I never use any of the TIFF formats myself.
They are also disappearing in the wild.
But I am sure they don't want the Trumps back...

Tomxe

  • New Member
  • *
  • Posts: 37
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #6 on: February 16, 2025, 11:07:49 am »
Test yourself

Tomxe

  • New Member
  • *
  • Posts: 37
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #7 on: February 16, 2025, 11:11:26 am »
TIFF in my opinion is a terrible format and people who designed it shouldn't allowed to touch computers. But it is still popular among graphic artists, publishers and academics. Luckily most of them use LZW, None or JPEG compressions. But once in a while you might stumble upon something more exotic and it good to have a solution.

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #8 on: February 16, 2025, 04:56:23 pm »
your sample contains virus. it is not downloading

Tomxe

  • New Member
  • *
  • Posts: 37
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #9 on: February 16, 2025, 05:28:32 pm »
It doesn't contain a virus. You should switch to better antivirus or browser.
https://www.virustotal.com/gui/file/40d28aa23e78f771a7a786e532cd2d49b3cf891d959e4b0454ee148ecd03812f
In case of browser- Firefox is great.

Attached the same archive but without 2 "problematic" files.
« Last Edit: February 16, 2025, 05:30:51 pm by Tomxe »

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #10 on: February 17, 2025, 03:38:24 am »
Please share the library and sample for windows.

TRon

  • Hero Member
  • *****
  • Posts: 4140
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #11 on: February 17, 2025, 04:35:47 am »
Please share the library and sample for windows.
What exactly do you not understand about repositories ?

libTiff can be build and how it works by reading its API. Pascal header is provided by OP in his repository. Really,  what more is needed ?

On a more general note, this anti virus thing going bananas on something as simple as embedded tags is hilarious 🍌🍌
Today is tomorrow's yesterday.

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #12 on: February 17, 2025, 05:24:49 am »
Thank you Sir.

It is working .

but image is showing reverse order . I have shared the screen shot

Tomxe

  • New Member
  • *
  • Posts: 37
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #13 on: February 17, 2025, 05:33:17 am »
Please edit TifImage.pas and change "if Orient = 0 then" to "if Orient = 1 then"

d2010

  • Full Member
  • ***
  • Posts: 117
Re: libTIFF for Lazarus - reading and writing TIF images
« Reply #14 on: February 17, 2025, 06:06:46 am »
CCITT group 3 is - has always been - supported by fcl-image. Only quirkyness is it it implementated at group member level.
It is also less relevant because these are older formats like rle and fax.

Can you replace CCITT inside TIFF with PDF ?
I known Lazarus contnin very-good PDF reader or write.
And the file.PDF is good feature for any programming language.

 

TinyPortal © 2005-2018