ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Multipage TIFF compression change

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Isaev Posted - Sep 02 2014 : 03:45:43
Hi to all,

I have a Multipage-TIFF-File(2.07MB) with LZW compression and will this convert such as to JPEG with Quality XX%
if I use XnConvert have I for:
25% - 694kB
50% - 939kB
75% - 1.18MB

if I use ImageEn have I for:
25% - 2.258MB
50% - 2.268MB
75% - 2.272MB

what do I make wrong?


var
  Image:        TIETIFFHandler;
  Stream:       TStream;
  Bitmap:       TIEBitmap;
  IO:           TImageEnIO;

begin
....
        Image  := TIETIFFHandler.Create;
        Stream := TMemoryStream.Create;
        Bitmap := TIEBitmap.Create;
        IO     := TImageEnIO.CreateFromBitmap(Bitmap);
        try
          if not Image.ReadFile(List[i]) or (Image.GetPagesCount <= 0) then
            raise Exception.Create('Fehler beim Lesen von Datei.');

          for i2 := 0 to Image.GetPagesCount - 1 do begin
            Stream.Size := 0;
            Image.WriteStream(Stream, i2);
            Stream.Position := 0;
            IO.LoadFromStream(Stream);
            if IO.Aborting then
              raise Exception.CreateFmt('Seiten-Ladefehler (%d)', [i2]);

            // JPEG Quality 25%
            IO.Params.TIFF_Compression    := ioTIFF_JPEG;
            IO.Params.TIFF_JPEGQuality    := 25;

            Stream.Size := 0;
            IO.SaveToStreamTIFF(Stream);
            Stream.Position := 0;
            if not Image.InsertPageAsStream(Stream, i2) then
              raise Exception.CreateFmt('Seiten-Speicherfehler (%d)', [i2]);
          end;

          try
            Image.WriteFile(Temp);
            TFile.SetLastWriteTimeUtc(Temp, TFile.GetLastWriteTimeUtc(List[i]));
          except
            on E: Exception do
              raise Exception.Create('Fehler beim Speichern der Datei.' + E.Message);
          end;
        finally
          Image.Free;
          Stream.Free;
          Bitmap.Free;
          IO.Free;
        end;
....
end;
8   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 10 2014 : 13:44:58
Hi
quote:
yes, but the file of the bigger size turns out, in properties is written "without compression"

I do not see that. Before it was 677KB, after it is 204KB.

If you open the file in Windows notepad you will see that it is JPEG ("JFIF"). Also you can see the compression artefacts in an image viewer.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Isaev Posted - Sep 10 2014 : 00:18:18
37.tiff is not a TIFF file, it is a JPEG file.
thanks, I have overlooked

14625.unkown.tiff converted without error using the above code.
yes, but the file of the bigger size turns out, in properties is written "without compression"
xequte Posted - Sep 09 2014 : 20:13:42
Hi

37.tiff is not a TIFF file, it is a JPEG file.

14625.unkown.tiff converted without error using the above code.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Isaev Posted - Sep 08 2014 : 01:35:58
With the source code the compression with the majority of the files is correct
I have another 2 "file groups".
when reading the first I receive an "Error reading from file"
the second are saved without compression despite parameters
IO.Params.TIFF_Compression := ioTIFF_JPEG;
IO.Params.TIFF_JPEGQuality := 25;

why it can be?
Example files: https://cloud.mail.ru/public/28f5f52ea3b7%2Fexamples.rar
Isaev Posted - Sep 04 2014 : 04:45:41
xequte,
exactly! Thank you very much! =)
xequte Posted - Sep 03 2014 : 17:34:39
Hi

In your code to are adding images to the original file, rather than replacing them, so naturally the file will be bigger than the original.

If you want to convert the TIFF try using:


var
  InImage,
  OutImage :    TIETIFFHandler;
  Stream:       TStream;
  Bitmap:       TIEBitmap;
  IO:           TImageEnIO;
  i2: Integer;
begin
  InImage  := TIETIFFHandler.Create;
  OutImage  := TIETIFFHandler.Create;
  Stream := TMemoryStream.Create;
  Bitmap := TIEBitmap.Create;
  IO     := TImageEnIO.CreateFromBitmap(Bitmap);
  try
    if not InImage.ReadFile(In_File) or (InImage.GetPagesCount <= 0) then
      raise Exception.Create('Fehler beim Lesen von Datei.');

    for i2 := 0 to InImage.GetPagesCount - 1 do
    begin
      Stream.Size := 0;
      InImage.WriteStream(Stream, i2);
      Stream.Position := 0;
      IO.LoadFromStream(Stream);
      if IO.Aborting then
        raise Exception.CreateFmt('Seiten-Ladefehler (%d)', [i2]);

      // JPEG Quality 25%
      IO.Params.TIFF_Compression    := ioTIFF_JPEG;
      IO.Params.TIFF_JPEGQuality    := 25;

      Stream.Size := 0;
      IO.SaveToStreamTIFF(Stream);
      Stream.Position := 0;
      if not OutImage.InsertPageAsStream(Stream, i2) then
        raise Exception.CreateFmt('Seiten-Speicherfehler (%d)', [i2]);
    end;

    try
      OutImage.WriteFile(Out_File);
      TFile.SetLastWriteTimeUtc(Temp, TFile.GetLastWriteTimeUtc(List[i]));
    except
      on E: Exception do
        raise Exception.Create('Fehler beim Speichern der Datei.' + E.Message);
    end;
  finally
    InImage.Free;
    OutImage.Free;
    Stream.Free;
    Bitmap.Free;
    IO.Free;
  end;
end;



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Isaev Posted - Sep 03 2014 : 00:25:18
xequte,
I do not say that the size should be exactly like with XnConvert, but
if I make quality worse, filesize must not become bigger, in any case.
look attentively, even if the quality is 25%, file is bigger than original!
xequte Posted - Sep 02 2014 : 22:17:36
Hi

Have you compared the properties of both the ImageEn and XnConvert images to see in what ways they differ?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com