Writing EXIF tags (date time stamps) into JPEG file

Discussions about image processing and document imaging.
Post Reply
JeroenB
Posts: 2
Joined: Wed Jun 20, 2007 3:52 pm
Location: Groningen, Netherlands

Writing EXIF tags (date time stamps) into JPEG file

Post by JeroenB » Wed Jun 20, 2007 5:17 pm

Hi,

I want to change the date-time related EXIF tags of some of my pictures because the time of my camera wasn't adjusted to daylight saving time. In trying to do so with GdPicture Pro OCX and the 4GL Progress everything goes fine except for 1 thing. It seems that the EXIF info isn't written back to the original file. If I use the "SaveAsJpeg"-method the EXIF data of the newly created file is set correctly, but the size of the picture is also increased. And I dont't want to change the picture at all. I only want to correct the EXIF-tags...

Where do I go wrong? Can anybody help me out?

TIA

Jeroen

PS 1: my Progress sample code, you should be able to read it! :D

Code: Select all

  define variable chPicture as com-handle  no-undo.
  define variable iTags     as integer     no-undo.
  define variable iCurTag   as integer     no-undo.
  define variable iTagId    as integer     no-undo.
  define variable cTagValue as character   no-undo.
  define variable cNewValue as character   no-undo.
  define variable iResult   as integer     no-undo.

  create "GdpicturePro.cGdPicture" chPicture.
  chPicture:SetLicenceNumber ("0332966657783387670301864").     /* June 2007 trial number */
  chPicture:CreateImageFromFile ("C:\TestPic.jpg").
  
  iTags = chPicture:TagsCount().                                /* get the total number of tags present */
  do iCurTag = 1 to iTags:

    iTagId = chPicture:TagsGetId(iCurTag).                      /* Get the tag ID of the current Tag */ 
                                                               
    case iTagId:                                               
                                                               
      when 306   or                                             /* Tag: DateTime */
      when 36867 or                                             /* Tag: ExifDtOrig */
      when 36868 then                                           /* Tag: ExifDtDigitized */
      do:                                                      
                                                               
        cTagValue = chPicture:TagsGetValue(iCurTag).            /* Example: "2007:05:27 17:32:11" */
        cNewValue = "2007:05:27 18:32:11".                      /* Add an hour to the timestamp */
        
        iResult = chPicture:TagsWriteTypeASCII
          ( input-output iTagId    by-pointer
          , input-output cNewValue by-pointer
          ).
        if iResult <> 0 then                                    /* in case of an error...  */
          message "Error TagsWriteTypeASCII" view-as alert-box  /* ... give message */ 
          
      end. /* when 306 or when 36867 or when 36868 */ 
    end. /* case iTagId: */
  end. /* do iCurTag = 1 to iTags: */
  
  iResult = chPicture:SaveAsJpeg 
	  ( "C:\TestPicNew.jpg"
	  , 100
	  ).
  if iResult <> 0 then                                          /* in case of an error...  */  
    message "Error SaveAsJpeg" view-as alert-box                /* ... give message */         

  iResult = chPicture:CloseNativeImage().
  if iResult <> 0 then                                          /* in case of an error...  */  
    message "Error CloseNativeImage" view-as alert-box.         /* ... give message */         
  
  release object chPicture.                                     /* Free the memory */

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Post by Loïc » Thu Jun 21, 2007 7:01 pm

Hi,

Code: Select all

but the size of the picture is also increased.

To decrease the resulting image file size you need to use a smalest value for the second parameter when you call the SaveAsjpeg method.

You can try to replace this line:

Code: Select all

iResult = chPicture:SaveAsJpeg
     ( "C:\TestPicNew.jpg"
     , 100
     ). 

by this one:

Code: Select all

iResult = chPicture:SaveAsJpeg
     ( "C:\TestPicNew.jpg"
     , 75
     ). 

Best regards,

Loïc Carrère

JeroenB
Posts: 2
Joined: Wed Jun 20, 2007 3:52 pm
Location: Groningen, Netherlands

Post by JeroenB » Fri Jun 22, 2007 1:56 pm

Hi,

Thnx for the reply, but it isn't what I want. I only want to change the EXIF information in the orifinal picture, without changing the picture itself. So it must be a kind of "lossless JPEG operation". Is there a method to write back the changed EXIF tags to the original picture? If not... I would like it to be part of a next release of GdPicture Pro OCX.

Grtz

Jeroen

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Post by Loïc » Fri Jun 22, 2007 2:45 pm

Ok I've understood :idea:


Please download this edition: https://www.gdpicture.com/ressources/betas/

And call

Code: Select all

iResult = chPicture:SaveAsJpeg 
     ( "C:\TestPicNew.jpg" 
     , -1
     ). 
-1 means no additive lossless compression.

Best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest