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
 Updating images non-visually

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
RichardLight Posted - Feb 08 2013 : 11:23:07
Hi,

Simple HTTP CGI application: I want to update an image's metadata using ImageEn, and then serve it as an HTTP response. The basic approach, of loading an image file into ImageEnIO and then delivering it as the ContentStream of the HTTP response, is working fine. However, any changes I make to the Params of my ImageEnIO have no effect. Shouldn't this "just work"? :-

{create the bitmap and load the file:}
IEBitmap1 := TIEBitmap.Create;
ImageEnIO1 := TImageEnIO.Create(Self);
ImgStream := TMemoryStream.Create;
OutStream := TMemoryStream.Create;
try
ImageEnIO1.AttachedIEBitmap := IEBitmap1;
if (FileExists(FFileName)) then begin
ImageEnIO1.LoadFromFileAuto(FFileName);
ImageEnIO1.Params.SetProperty('EXIF_XPSubject', 'Dolly');
ImageEnIO1.Params.SetProperty('EXIF_XPTitle', 'Photograph of Dolly');
ImageEnIO1.Params.SetProperty('Width', '100');
ImageEnIO1.Params.SetProperty('Height', '100');
ImageEnIO1.AttachedIEBitmap.Resize(300, 300);
ImageEnIO1.SaveToStream(ImgStream, ioJPEG);
ImgStream.Position := 0;
...
Response.ContentStream := ImgStream;
Response.ContentType := 'image/jpeg';
Response.StatusCode := 200;

The Resize command works, but the SetProperty commands have no effect. I've tried adding an InjectJpegEXIFStream command into the mix, but it makes no difference and I don't see why it should be needed anyway.

Any help will be gratefully received.


Richard Light
2   L A T E S T    R E P L I E S    (Newest First)
RichardLight Posted - Feb 08 2013 : 13:05:02
William,

That was the only line I needed:

iImageEnIO.Params.EXIF_HasEXIFData := True;

does the job a treat. No need for a separate stream or InjectJpegEXIFStream.

Many thanks: I would never have spotted that crucial boolean property lurking amongst the many EXIF parameters.

Richard

Richard Light
w2m Posted - Feb 08 2013 : 12:28:27
Unfortunately, I have never used SetProperty but you might try setting the EXIF data directly and add EXIF_HasEXIFData:= True:

var
  iIEBitmap: TIEBitmap;
  iImageEnIO: TImageEnIO;
  iImgStream: TMemoryStream;
  iOutStream: TMemoryStream;
begin
  iIEBitmap := TIEBitmap.Create;
  try
    iImageEnIO := TImageEnIO.Create(Self);
    try
      iImgStream := TMemoryStream.Create;
      try
        iOutStream := TMemoryStream.Create;
        try
          iImageEnIO.AttachedIEBitmap := iIEBitmap;
          if (FileExists(FFileName)) then
          begin
            iImageEnIO.LoadFromFileAuto(FFileName);
            iImageEnIO.Params.EXIF_XPTitle := 'Photograph of Dolly';
            iImageEnIO.Params.EXIF_XPSubject := 'Dolly';
            // This is important if you want change some EXIF fields
            iImageEnIO.Params.EXIF_HasEXIFData := True;
            iImageEnIO.AttachedIEBitmap.Resize(300, 300);
            iImageEnIO.InjectJpegEXIF(iImgStream, iOutStream);
            iImageEnIO.SaveToStream(iOutStream, ioJPEG);
            iImgStream.Position := 0;
            // ...
            Response.ContentStream := iImgStream;
          end;
        finally
          iOutStream.Free;
        end;
      finally
        iImgStream.Free;
      end;
    finally
      iImageEnIO.Free;
    end;
  finally
    iIEBitmap.Free;
  end;
end;

This code has not been tested.

InjectJpegEXIFStream replaces EXIF information of the InputStream stream (jpeg) with EXIF current in memory without loading or modifying the original image. OutputStream contains the modified stream. The method returns false if it fails.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html