I need to send the details of a jpg file to an array any windows api to do this or get me started?

busycoder
busycoder used Ask the Experts™
on
I would like to be able to drag a picture to an image object in foxpro and on the OLEDragDrop event get from the jpg file what camera was used date it was taken etc. windows can read these easy enough, I was hoping there was an API call or somthing simular to be able to work with these property values.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Olaf DoschkeSoftware Developer
Commented:
This is EXIF informations embedded within the file. Drag&Drop of files won't give you that info, but look here:
http://www.tek-tips.com/viewthread.cfm?qid=1173924

look into craigsboyds answer.

Bye, Olaf.
You have several options...

1) Study the EXIF info structure (you may start here: http://en.wikipedia.org/wiki/Exchangeable_image_file_format) and write your own code to retrieve the EXIF info.

2) Download EXIF Control ActiveX component, e.g. from http://www.watermarker.com/exif-iptc-gps/ and use it to retrieve the EXIF info (see code sample)

3) Use some Windows scripting to obtain file extended information (not necessary because above option works prefectly)

*-- Suppose the EXIF Control ActiveX is installed already
oX  = CreateObject("AiSExif.ExifControl")
oX.ReadExifInfo("<YourFileName>")

? oX.GetParam("Image.Make")  && Camera producer
? oX.GetParam("Image.Model")  && Camera model name
? oX.GetParam("Photo.ExposureTime")
? oX.GetParam("Photo.FNumber")  

? oX.GetAllExifData()  &&  lists all EXIF data

Open in new window

You can get this imformation with WIA (http://www.microsoft.com/downloads/details.aspx?FamilyID=a332a77a-01b8-4de6-91c2-b7ea32537e29&DisplayLang=en)

Here is a sample code:

Img = CreateObject("WIA.ImageFile")
Img.LoadFile (getpict())
s = "Width = " + TRANSFORM(Img.Width) + chr(13) + ;
    "Height = " + TRANSFORM(Img.Height) + chr(13) + ;
    "Depth = " + TRANSFORM(Img.PixelDepth) + chr(13) + ;
    "HorizontalResolution = " + TRANSFORM(Img.HorizontalResolution) + chr(13) + ;
    "VerticalResolution = " + TRANSFORM(Img.VerticalResolution) + chr(13) + ;
    "FrameCount = " + TRANSFORM(Img.FrameCount) + chr(13)
If Img.IsIndexedPixelFormat
    s = s + "Pixel data contains palette indexes" + chr(13)
EndIf
If Img.IsAlphaPixelFormat
    s = s + "Pixel data has alpha information" + chr(13)
EndIf
If Img.IsExtendedPixelFormat
    s = s + "Pixel data has extended color information (16 bit/channel)" + chr(13)
EndIf
If Img.IsAnimated
    s = s + "Image is animated" + chr(13)
EndIf
if Img.Properties.Exists("271")
  s = s + "EquipMake = " + Img.Properties("271").Value+ chr(13)
endif
if Img.Properties.Exists("272")
  s = s + "EquipModel = " + Img.Properties("272").Value+ chr(13)
endif
if Img.Properties.Exists("274")
  s = s + "Orientation = " + str(Img.Properties("274").Value)+ chr(13)
endif
if Img.Properties.Exists("282")
  s = s + "xResolution = " + transf(Img.Properties("282").Value)+ chr(13)
endif
if Img.Properties.Exists("283")
  s = s + "yResolution = " + transf(Img.Properties("283").Value)+ chr(13)
endif
if Img.Properties.Exists("296")
  s = s + "Resolution Unit= " + transf(Img.Properties("296").Value)+ chr(13)
endif
if Img.Properties.Exists("306")
  s = s + "DateTime= " + transf(Img.Properties("306").Value)+ chr(13)
endif
if Img.Properties.Exists("531")
  s = s + "YCBCRPositionning= " + transf(Img.Properties("531").Value)+ chr(13)
endif
if Img.Properties.Exists("305")
  s = s + "Software Used= " + transf(Img.Properties("305").Value)+ chr(13)
endif
if Img.Properties.Exists("36864")
  s = s + Img.Properties("36864").name +" ="+ transf(Img.Properties("36864").Value)+ chr(13)
endif
if Img.Properties.Exists("36867")
  s = s + Img.Properties("36867").name+" =" + transf(Img.Properties("36867").Value)+ chr(13)
endif
if Img.Properties.Exists("40961")
  s = s + Img.Properties("40961").name+" =" + transf(Img.Properties("40961").Value)+ chr(13)
endif
if Img.Properties.Exists("37121")
  s = s + Img.Properties("37121").name+" =" + transf(Img.Properties("37121").Value)+ chr(13)
endif
if Img.Properties.Exists("40962")
  s = s + Img.Properties("40962").name+" =" + transf(Img.Properties("40962").Value)+ chr(13)
endif
if Img.Properties.Exists("40963")
  s = s + Img.Properties("40963").name+" =" + transf(Img.Properties("40963").Value)+ chr(13)
endif
if Img.Properties.Exists("33434")
  s = s + Img.Properties("33434").name+" =" + transf(Img.Properties("33434").Value)+ chr(13)
endif
if Img.Properties.Exists("37382")
  s = s + Img.Properties("37382").name+" =" + transf(Img.Properties("37382").Value)+ chr(13)
endif
if Img.Properties.Exists("37384")
  s = s + Img.Properties("37384").name+" =" + transf(Img.Properties("37384").Value)+ chr(13)
endif
if Img.Properties.Exists("37385")
  s = s + Img.Properties("37385").name+" =" + transf(Img.Properties("37385").Value)+ chr(13)
endif
if Img.Properties.Exists("20624")
  s = s + Img.Properties("20624").name+" =" + transf(Img.Properties("20624").Value)+ chr(13)
endif
if Img.Properties.Exists("20625")
  s = s + Img.Properties("20625").name+" =" + transf(Img.Properties("20625").Value)+ chr(13)
endif
If Img.Properties.Exists("40091")
            v = Img.Properties("40091").Value
    s = s + "Title = " + v.String + chr(13)
EndIf
If Img.Properties.Exists("40092")
            v = Img.Properties("40092").Value
    s = s + "Comment = " + v.String + chr(13)
EndIf
If Img.Properties.Exists("40093")
            v = Img.Properties("40093").Value
    s = s + "Author = " + v.String + chr(13)
EndIf
If Img.Properties.Exists("40094")
            v = Img.Properties("40094").Value
    s = s + "Keywords = " + v.String + chr(13)
EndIf
If Img.Properties.Exists("40095")
            v = Img.Properties("40095").Value
    s = s + "Subject = " + v.String + chr(13)
EndIf
MESSAGEBOX( s)
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Author

Commented:
I have been looking and looking, but can't seem to find the Date the picture was taken property.

This is not it:
if Img.Properties.Exists("306")
  s = s + "DateTime= " + transf(Img.Properties("306").Value)+ chr(13)
endif

This only gets set it seems if you edit the picture.

Author

Commented:
ok, seems to be Img.Properties("36867").Value

for somereason I couldn't get mikegagnon's progam to run all the way through, I am still trying though, it doesnt like something along the way...
Some images do not contain all the information you are after. 36867 seems to be be the value you might be after, but code for possibly the value being not available.
Olaf DoschkeSoftware Developer

Commented:
Take a look at the full tek-tips thread, there are bugfixes and there was an issue, when using it with VFP7 or older.
If you have an error message and don't know what it means, why not shre here?

There are lot's of Exif informations and cameras might store even such a simple information like date the pic was taken in different image proerty ids. Also these informations can easily be striped off pictures as soon as you edit one with an image processing software, as that might only read in the picture portion of the file and even if it reads in Exif parts, if you SAVE AS to a new JPG or other picture file this does not inherit Exif informations but may be written new without any.

If the cam provides exif informations in it's pics you can only be sure it's in the original camera file.

Bye, Olaf.

Author

Commented:
Thank you all sorry for the delay. As usual I now have multiple solutions, with great value in different situations. THANK YOU!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial