Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Saved image metadata??
Tue, Dec 15 2020 8:26 PMPermanent Link

Ian Branch

Avatar

Hi team,
   If I have an image/picture saved to a Blob field, is there any metadata I can retrieve to identify the image?  i.e.
Filename or something.

Regards & TIA,
Ian
Wed, Dec 16 2020 4:05 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


There will only be metadata if its been created at the same time as the image (probably in exif). You can find out the type (I wouldn't call it metadata)

function ImageFileTypeFromStream(ms: TMemoryStream; const default: string = 'jpg'): string;
var
ChkChars: array[0..20] of char;
jpgCheck: array[0..4] of char;
CharsToRead: integer;
begin
Result := default;
ms.Seek(0, soFromBeginning);
if ms.Size > 20 then CharsToRead := 20 else CharsToRead := ms.Size;
ms.ReadBuffer(ChkChars, CharsToRead);
if Pos('BM', ChkChars) = 1 then Result := 'bmp'
else if Pos('GIF', ChkChars) = 1 then Result := 'gif'
else if Pos(#137 + 'PNG' + #13#10, ChkChars) = 1 then Result := 'png'
else if (Copy(ChkChars, 1, 2) = 'II') and (ChkChars[3] = '*') then Result := 'tiff'
else if (Copy(ChkChars, 1, 2) = 'MM') and (ChkChars[4] = '*') then Result := 'tiff'
else if (ms.Size > 10) and
 (Ord(ChkChars[0]) = 255) and
 (Ord(ChkChars[1]) = 216) and
 (Ord(ChkChars[2]) = 255) and
 (Ord(ChkChars[3]) in [219, 224, 225]) then Result := 'jpg';
ms.Seek(0, soFromBeginning);
end;

exif can be identified by if Pos('Exif', ChkChars) = 7 then Result := 'Exif' ; getting the rest of the metadata from the exif chunk is sonmething I never bothered with.

Roy Lambert
Wed, Dec 16 2020 4:25 AMPermanent Link

Ian Branch

Avatar

Tks Roy,
A little more complicated than I thought and it looks like what I want isn't in there anyway.
All I want to recover is the file name of the image that has been stored.

Ian
Wed, Dec 16 2020 4:30 AMPermanent Link

Ian Branch

Avatar

Basically, I think I am out of luck.  Frown
Wed, Dec 16 2020 5:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian

>Basically, I think I am out of luck. Frown

You are Smiley

Only way to do that is to store the filename yourself, and then I'd ask which of the copies of the image I've made do you want to use as the filename?

Roy
Image