Skip to content

Updating IPTC fields with blank values #121

@tedca77

Description

@tedca77

I have been using the insertIPTC method:

Metadata.insertIPTC(fin1, fout1,iptcs,true);

I have created an new List of IPTCDatasets (iptcs) with only the properties I want to change. This works fine for updating the fields but does not work if you want to blank out (or remove) one of the fields.

So I am creating a List of all the IPTC metadata and removing the fields I want to blank out.

Metadata.insertIPTC(fin1, fout1,iptcs,false); i.e. with append =false

It would be nice if there was a easy way to create an IPTCDataset of all existing IPTC metadata - or maybe there is and I have not found it...
This is the approach I have taken.

 } else if (meta instanceof IPTC) {
                    iptc = (IPTC) meta;
                    Map<IPTCTag, List<IPTCDataSet>> datasets = iptc.getDataSets();
                    for (Map.Entry<IPTCTag, List<IPTCDataSet>> entrymap : datasets.entrySet()) {
                       List<IPTCDataSet> sdsd = entrymap.getValue();
                        for (IPTCDataSet s : sdsd) {
                            if (s.getRecordNumber() == 1) {
                                IPTCEnvelopeTag tag = (IPTCEnvelopeTag) s.getTagEnum();
                                alliptc.add(new IPTCDataSet(IPTCRecord.fromRecordNumber(s.getRecordNumber()), s.getTag(), s.getData()));
                            }
                            if (s.getRecordNumber() == 2) {
                                IPTCApplicationTag tag = (IPTCApplicationTag) s.getTagEnum();
                                alliptc.add(new IPTCDataSet(tag, s.getDataAsString()));
                            }

                           ... etc for the other IPTC Record Tpes

                        }


                    }
                    return alliptc;

,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions