•  
  •  
  •  
 

CopyJPEGMetadataToFile problem

Last post 25 Jun 2008, 4:45 PM by weso. 5 replies.
Sort Posts: Previous Next
  •  20 Jun 2007, 3:02 PM 12227

    CopyJPEGMetadataToFile problem

    Hi,

    this is rather urgent:

    I try to write iptc information to an existing image without having to open and recompress the jpg data when writing.

    What I do is this:

        * start with new image
        imgx.JPGMarkersToSave = hex2dec("1000")

        imgx.import.fromnew(1,1)
        imgx.image.iptc.PopulateStandardTags()
        imgx.image.iptc.SaveIPTCChanges = .T.  

       * create iptc data
        imgx.image.iptc.add(ixitCaptionWriter)
        imgx.image.iptc.item(ixitCaptionWriter,0).text = "myapplication"
        imgx.image.iptc.add(ixitCaption)
        imgx.image.iptc.item(ixitCaption,0).text = "images.caption"
       
        ...

        * save iptc to temp file
        imgx.export.tofile(tempfile,ixfsJPG)

        * copy iptc from temp file to original file
        imgx.image.CopyJPEGMetadataToFile(tempfile,existingfile)

     

    In words: start a new image, write iptc data to it, save it as a temp image, and then use CopyJPEGMetadataToFile to transfer the data to an existing file.

    The problem is, that the image data is also transferred. When I open the existing image, it has size 1x1, like the new image I used.

    How do I achieve what I want to do? That is, write iptc data to an image without ever opening or recompressing the jpg data? I have to update an archive of > 150000 images, up to 100MB uncompressed in size each. Opening all this files just for the iptc would take ages...


     


     

  •  21 Jun 2007, 6:04 AM 12236 in reply to 12227

    Re: CopyJPEGMetadataToFile problem

    Hello guys,

    no comment on this one?

    If I can't get this working, ImgX is useless to me. I really need help on this one.
  •  21 Jun 2007, 7:05 PM 12240 in reply to 12227

    Re: CopyJPEGMetadataToFile problem

    This was answered in a support case, but I will repeat it here in case others would like to know.

    The CopyJPEGMetadataToFile is used to combine the metadata currently loaded in an ImgX object and the image data from an existing file into a new file.  So you would change the call to:

    imgx.Image.CopyJPEGMetadataToFile(existingfile, newfile)

    This will copy the image data from existingfile into newfile and add the currently loaded metadata into newfile.

  •  26 Jun 2007, 8:21 AM 12255 in reply to 12240

    Re: CopyJPEGMetadataToFile problem

    (posted to support case, copied here for general interest)

    A new, very critical problem came up: after embedding the iptc data and saving the image, the embedded color profile is lost. It is absolutely critical for us to retain the profile, is there a way to do this?

  •  25 Jun 2008, 4:09 PM 14526 in reply to 12255

    Re: CopyJPEGMetadataToFile problem

    I am having a very similar problem. When I save an image, the color profile data is lost. This is a critical problem for me as well. Any help would be greatly appreciated.
  •  25 Jun 2008, 4:45 PM 14527 in reply to 14526

    Re: CopyJPEGMetadataToFile problem

    Hi Damian,

     

    the key line is this (VFP syntax):

    * This tells imgx to save all exif-data as well, which is where the color profiles are stored.

    this.imgx.JPGMarkersToSave = hex2dec("3FFF")

    * Then simply import your image from whereever, for example

     this.imgx.import.fromfile(_file)

    * and set the iptc tags as you wish, like

    this.imgx.image.iptc.add(ixitCaptionWriter)
    this.imgx.image.iptc.item(ixitCaptionWriter).text = "MyApp"

     * save original image data and iptc data to tempfile

    this.imgx.image.CopyJPEGMetadataToFile(_file,tempfile)

     This should do it, it worked for me.

     

    Regards,

    Werner

     

View as RSS news feed in XML