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
 Multiple Tiff To Single Files

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
Bill Posted - Oct 21 2016 : 17:40:02
Hello,

I have a Tif file that has multiple pages (it can be 2 or 3 or I do not know the number of pages). I want Devide these pages into separate files: is to say, each page in a file, so from a TIF file (which consists for example of 5 pages) at the end I will have 5 files each file contains an image.

How to do this please? with an example please.
thank you in advance

Thank you in advance .


Bill
11   L A T E S T    R E P L I E S    (Newest First)
Bill Posted - Nov 07 2016 : 15:13:47
Thank you very much for your HELP !
w2m Posted - Nov 04 2016 : 12:33:46
Here is a demo you can use:
unit Unit1;
{$WARN SYMBOL_PLATFORM OFF}
{$WARN UNIT_PLATFORM OFF}

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    ProcessFiles1: TButton;
    procedure ProcessFiles1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Winapi.ShlObj, iexBitmaps;

function DesktopFolder: string;
var
  iResult: bool;
  iPath: array [0 .. MAX_PATH] of Char;
begin
  iResult := Winapi.ShlObj.ShGetSpecialFolderPath(0, iPath,
    CSIDL_DESKTOP, False);
  if not iResult then
    raise Exception.Create('Could not find Desktop folder location.');
  Result := IncludeTrailingPathDelimiter(iPath);
end;

function GetAllFiles(AMask: string; AStringList: TStringList): integer;
{ Get all files matching mask (*.bmp) and add them to a stringlist }
var
  iSearch: TSearchRec;
  iDirectory: string;
  iCount: integer;
  iFileAttrs: integer;
begin
  iCount := 0;
  iDirectory := ExtractFilePath(AMask);
  iFileAttrs := $23 - faHidden;
  { Find all files }
  if FindFirst(AMask, iFileAttrs, iSearch) = 0 then
  begin
    repeat
      { Add the files to the stringlist }
      AStringList.Add(iDirectory + iSearch.name);
      Inc(iCount);
    until FindNext(iSearch) <> 0;
  end;
  { Subdirectories }
  if FindFirst(iDirectory + '*.*', faDirectory, iSearch) = 0 then
  begin
    repeat
      if ((iSearch.Attr and faDirectory) = faDirectory) and
        (iSearch.name[1] <> '.') then
        GetAllFiles(iDirectory + iSearch.name + '\' + ExtractFileName(AMask),
          AStringList);
    until FindNext(iSearch) <> 0;
    FindClose(iSearch);
  end;
  Result := iCount;
end;

function GetFilesMatchingMask(const APathName: string;
  const AExtensions: string; var AStringList: TStringList): integer;
{ Given a pathname, this function fills AStringList with filenames matching the extensions mask (*.bmp;*.jpg;*.png) }
const
  iFileMask = '*.*';
var
  iSearchRec: TSearchRec;
  iPath: string;
  iCount: integer;
begin
  iCount := 0;
  iPath := IncludeTrailingBackslash(APathName);
  if FindFirst(iPath + iFileMask, faAnyFile - faDirectory, iSearchRec) = 0 then
    try
      repeat
        if AnsiPos(ExtractFileExt(iSearchRec.name), AExtensions) > 0 then
        begin
          AStringList.Add(iPath + iSearchRec.name);
          Inc(iCount);
        end;
      until FindNext(iSearchRec) <> 0;
    finally
      System.SysUtils.FindClose(iSearchRec);
    end;
  if FindFirst(iPath + '*.*', faDirectory, iSearchRec) = 0 then
    try
      repeat
        if ((iSearchRec.Attr and faDirectory) <> 0) and (iSearchRec.name <> '.')
          and (iSearchRec.name <> '..') then
          GetFilesMatchingMask(iPath + iSearchRec.name, AExtensions,
            AStringList);
      until FindNext(iSearchRec) <> 0;
    finally
      FindClose(iSearchRec);
    end;
  Result := iCount;
end;

function JustFilename(const APathName: string): string;
{ Return a filename from a string }
var
  iString: string;
  i: integer;
  { Turn }
  { Reverse characters in a string ABCD -> DCBA }

  function Turn(const AString: string): string;
  var
    i: integer;
  begin
    Result := '';
    if AString <> '' then
      for i := 1 to Length(AString) do
        Result := AString[i] + Result;
  end;

begin
  iString := Turn(APathName);
  i := Pos('\', iString);
  if i = 0 then
    i := Pos(':', iString);
  if i = 0 then
    Result := APathName
  else
    Result := Turn(Copy(iString, 1, i - 1));
end;

function JustName(const APathName: string): string;
{ Return just the name from a file string }
var
  iString: string;
begin
  iString := JustFilename(APathName);
  if Pos('.', iString) <> 0 then
    Result := Copy(iString, 1, Pos('.', iString) - 1)
  else
    Result := iString;
end;

procedure TForm1.ProcessFiles1Click(Sender: TObject);
var
  i: integer;
  iFolder: string;
  iNumberofFiles: integer;
  iIsMultiFrameImage: Boolean;
  iSourceFilename: string;
  iExtension: string;
  iDestinationFilename: string;
  iStringList: TStringList;
  iIEMultiBitmap: TIEMultiBitmap;
  j: integer;
  iFrames: integer;
begin
  {Create a string list to hold the filenames in a folder}
  iStringList := TStringList.Create;
  { Set the source folder }
  iFolder := IncludeTrailingPathDelimiter(DesktopFolder);
  { Add the files to the string list }
  iNumberofFiles := GetAllFiles(iFolder + '*.*', iStringList);
  if iNumberofFiles > 0 then
  begin
    for i := 0 to iNumberofFiles - 1 do
    begin
      { Get the source filename }
      iSourceFilename := iStringList[i];
      { Get the extension }
      iExtension := ExtractFileExt(iSourceFilename);
      { Get the number of frames in the file }
      iFrames := IEGetFileFramesCount(iSourceFilename);
      { Does the filename contain multiframe pages }
      iIsMultiFrameImage := iFrames > 1;
      { If the format is known and is a multiframe image }
      if (IsKnownFormat(iSourceFilename)) and (iIsMultiFrameImage) then
      begin
        for j := 0 to iFrames - 1 do
        begin
          { Set the destination Filename }
          iDestinationFilename := iFolder + JustName(iSourceFilename) + ' Page '
            + IntToStr(j + 1) + iExtension;
          { Create the iemultibitmap }
          iIEMultiBitmap := TIEMultiBitmap.Create;
          { Read the bitmap page }
          iIEMultiBitmap.Read(iSourceFilename);
          { Save the bitmap page }
          iIEMultiBitmap.GetImageToFile(j, iDestinationFilename);
          { Free the IEMultibitmap }
          iIEMultiBitmap.Free;
        end;
      end;
    end;
  end;
  { Free the string list }
  iStringList.Free;
end;

end.


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Nov 04 2016 : 05:01:35
Hi Bill

You just need to make a list of all the TIFF files in the folder (there is plenty of delphi code on the web for iterating the files of a folder) then load each in turn into a TIEMultiBitmap and call GetImageToFile for each frame.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Bill Posted - Nov 03 2016 : 15:13:46
Hello,
Thank you for your help!

Please how to extract and save individual frames from a directory.
The directory contains multiple TIFF images.

How to do this please?
if possible with an example please.

Best regards.
Bill
pete Posted - Oct 26 2016 : 08:59:32
Hi Nigel,

That bit of code works well - thank you.

Regards,
Peter.
xequte Posted - Oct 24 2016 : 04:13:47
Hi Peter

How about:

var
  mbmp: TIEMultiBitmap;
begin
  mbmp := TIEMultiBitmap.Create;
  mbmp.Read('input.tiff');
  mbmp.GetImageToFile(1, 'page2.tif');
  mbmp.Free;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
pete Posted - Oct 24 2016 : 03:01:02
I was thinking of a multi-paged tiff rather than the thumbnail frame.
As an example, is there a way to export the second page (as a single page tiff) of a multi-paged tiff?

Regards,
Peter.


w2m Posted - Oct 23 2016 : 09:49:13
Please explain. Here the DPI is the same in the frame as the frame saved to a file.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
pete Posted - Oct 23 2016 : 09:23:36
Sorry to jump in on the thread but I noticed that the saved frame is at the resolution of the ImageEnMView rather than the original image. Is there a way to save it so the resolution is the same as the original image?

Regards,
Peter.
Bill Posted - Oct 22 2016 : 13:59:20
Hello,

Thank you very much! It's what I am looking for.

w2m Posted - Oct 22 2016 : 10:05:41
Here is a demo that shows one way to extract and save individual frames:
attach/w2m/2016102210518_Extract.zip
58.67 KB

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development