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
 Preserving Exif tags

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
yeohray2 Posted - Nov 16 2021 : 09:13:11
Hi, not sure if this is the right way, but I'm trying to preserve the Exif tags after adding an image layer. Currently, I'm saving and loading the params to a stream like this:

  procedure ApplyImageOverlay(const ImageFileName: string);
  var
    AStream: TMemoryStream;
  begin
    if FileExists(ImageFileName) then
    begin
      AStream := TMemoryStream.Create;
      try
        AView.IO.Params.SaveToStream(AStream);

        LayerIndex := AView.LayersAdd(ImageFileName);
        AView.Layers[LayerIndex].Opacity := 0.5;

        AStream.Position := 0;
        AView.IO.Params.LoadFromStream(AStream);
      finally
        AStream.Free;
      end;
    end;
  end;


Is this the correct way? Thanks.
5   L A T E S T    R E P L I E S    (Newest First)
yeohray2 Posted - Nov 26 2021 : 11:08:49
Noted, Nigel, thanks.
xequte Posted - Nov 25 2021 : 16:18:59
Hi Ray

So, as it turns out any loading of image layers become the params in TImageEnView by default.

There are two ways to maintain the existing params.

1. Store the params in the TIEBitmap object:

var
  ImageHeight, ImageWidth, LayerIndex: Integer;
begin
  viewMain.LockUpdate;
  viewMain.LayersClear();

  // For Layer 0 use the params of the bitmap, rather than the embedded TImageEnIO
  viewMain.IEBitmap.ParamsEnabled := True;

  viewMain.IO.LoadFromFile('SAM_4783.JPG');
  ImageHeight := viewMain.IEBitmap.Height;
  ImageWidth  := viewMain.IEBitmap.Width;
  viewMain.Fit();

  Log('Loading image');
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);

  Log('Loading overlay');
  LayerIndex := viewMain.LayersAdd('overlay.png');
  viewMain.Layers[LayerIndex].Width  := ImageWidth;
  viewMain.Layers[LayerIndex].Height := ImageHeight;
  viewMain.Layers[LayerIndex].Opacity := 0.5;

  viewMain.UnlockUpdate;

  viewMain.LayersCurrent := 0;
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);
end;


2. Store desired params in an object and assign them back after loading:

var
  ImageHeight, ImageWidth, LayerIndex: Integer;
  params: TIOParams;
begin
  params := TIOParams.Create();
  viewMain.LockUpdate;

  viewMain.IO.LoadFromFile('SAM_4783.JPG');
  ImageHeight := viewMain.IEBitmap.Height;
  ImageWidth  := viewMain.IEBitmap.Width;
  viewMain.Fit();

  // Store image params
  params.Assign( viewMain.IO.Params );
  Log('Loading image');
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);

  Log('Loading overlay');
  LayerIndex := viewMain.LayersAdd('overlay.png');
  viewMain.Layers[LayerIndex].Width := ImageWidth;
  viewMain.Layers[LayerIndex].Height := ImageHeight;
  viewMain.Layers[LayerIndex].Opacity := 0.5;

  viewMain.UnlockUpdate;

  viewMain.LayersCurrent := 0;

  // Retore image params
  viewMain.IO.Params.Assign( params );

  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);
  params.Free;
end;



Nigel
Xequte Software
www.imageen.com
xequte Posted - Nov 23 2021 : 00:25:05
Hi Ray

Can you send me a simple demo that reproduces the issue?

With regard to your query, a simpler method to pass the params between objects is:

var
  params: TIOParams;
begin
  params := TIOParams.Create();
  params.Assign( AView.IO.Params );

  ... Do something that affects the params???
 
  AView.IO.Params.Assign( params );
  params.Free;
end;


Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Nov 17 2021 : 01:59:29
I should have mentioned that after adding the image layer, I did try to set LayersCurrent := 0 to retrieve the Exif values, but it was all empty e.g.

AValue := AView.IO.Params.EXIF_Make;
OutputDebugString(PWideChar(AValue)); // has the correct value

ApplyImageOverlay('overlay.png'); // the function I posted earlier

AView.LayersCurrent := 0;

AValue := AView.IO.Params.EXIF_Make;
OutputDebugString(PWideChar(AValue)); // is empty if I don't save and load the params in ApplyImageOverlay

What I'm trying to do is to place a watermark-like image using a layer over the original image, then read the Exif values. I can't read first then apply the overlay because of some other requirements.

Thanks in advance.

Ray
xequte Posted - Nov 17 2021 : 01:11:26
Hi

AView.IO.Params is the params of the current layer (or the background layer if you have not yet added any layers).

So, the code above assigns the parameters of the current layer to that of the new layer (the loaded image). It does not replace the params of the original layer, which should not change when loading a new layer.

Can you let me know more about what you are looking to achieve?

Nigel
Xequte Software
www.imageen.com