• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libkexiv2/libkexiv2

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libkexiv2
  • libkexiv2
kexiv2iptc.cpp
Go to the documentation of this file.
1 
28 #include "kexiv2.h"
29 #include "kexiv2_p.h"
30 
31 namespace KExiv2Iface
32 {
33 
34 bool KExiv2::canWriteIptc(const QString& filePath)
35 {
36  try
37  {
38  Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
39  (QFile::encodeName(filePath)));
40 
41  Exiv2::AccessMode mode = image->checkMode(Exiv2::mdIptc);
42  return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
43  }
44  catch(Exiv2::Error& e)
45  {
46  std::string s(e.what());
47  kError() << "Cannot check Iptc access mode using Exiv2 (Error #"
48  << e.code() << ": " << s.c_str() << ")";
49  }
50  catch(...)
51  {
52  kError() << "Default exception from Exiv2";
53  }
54 
55  return false;
56 }
57 
58 bool KExiv2::hasIptc() const
59 {
60  return !d->iptcMetadata().empty();
61 }
62 
63 bool KExiv2::clearIptc() const
64 {
65  try
66  {
67  d->iptcMetadata().clear();
68  return true;
69  }
70  catch(Exiv2::Error& e)
71  {
72  d->printExiv2ExceptionError("Cannot clear Iptc data using Exiv2 ", e);
73  }
74  catch(...)
75  {
76  kError() << "Default exception from Exiv2";
77  }
78 
79  return false;
80 }
81 
82 QByteArray KExiv2::getIptc(bool addIrbHeader) const
83 {
84  try
85  {
86  if (!d->iptcMetadata().empty())
87  {
88  Exiv2::IptcData& iptc = d->iptcMetadata();
89  Exiv2::DataBuf c2;
90 
91  if (addIrbHeader)
92  {
93  c2 = Exiv2::Photoshop::setIptcIrb(0, 0, iptc);
94  }
95  else
96  {
97  c2 = Exiv2::IptcParser::encode(d->iptcMetadata());
98  }
99 
100  QByteArray data((const char*)c2.pData_, c2.size_);
101  return data;
102 
103  }
104  }
105  catch(Exiv2::Error& e)
106  {
107  if (!d->filePath.isEmpty())
108  {
109  kError() << "From file " << d->filePath.toAscii().constData();
110  }
111 
112  d->printExiv2ExceptionError("Cannot get Iptc data using Exiv2 ",e);
113  }
114  catch(...)
115  {
116  kError() << "Default exception from Exiv2";
117  }
118 
119  return QByteArray();
120 }
121 
122 bool KExiv2::setIptc(const QByteArray& data) const
123 {
124  try
125  {
126  if (!data.isEmpty())
127  {
128  Exiv2::IptcParser::decode(d->iptcMetadata(), (const Exiv2::byte*)data.data(), data.size());
129  return (!d->iptcMetadata().empty());
130  }
131  }
132  catch(Exiv2::Error& e)
133  {
134  if (!d->filePath.isEmpty())
135  {
136  kError() << "From file " << d->filePath.toAscii().constData();
137  }
138 
139  d->printExiv2ExceptionError("Cannot set Iptc data using Exiv2 ", e);
140  }
141  catch(...)
142  {
143  kError() << "Default exception from Exiv2";
144  }
145 
146  return false;
147 }
148 
149 KExiv2::MetaDataMap KExiv2::getIptcTagsDataList(const QStringList& iptcKeysFilter, bool invertSelection) const
150 {
151  if (d->iptcMetadata().empty())
152  return MetaDataMap();
153 
154  try
155  {
156  Exiv2::IptcData iptcData = d->iptcMetadata();
157  iptcData.sortByKey();
158 
159  QString ifDItemName;
160  MetaDataMap metaDataMap;
161 
162  for (Exiv2::IptcData::iterator md = iptcData.begin(); md != iptcData.end(); ++md)
163  {
164  QString key = QString::fromLocal8Bit(md->key().c_str());
165 
166  // Decode the tag value with a user friendly output.
167  std::ostringstream os;
168  os << *md;
169 
170  QString value;
171 
172  if (key == QString("Iptc.Envelope.CharacterSet"))
173  {
174  value = iptcData.detectCharset();
175  }
176  else
177  {
178  value = QString::fromUtf8(os.str().c_str());
179  }
180 
181  // To make a string just on one line.
182  value.replace('\n', ' ');
183 
184  // Some Iptc key are redondancy. check if already one exist...
185  MetaDataMap::iterator it = metaDataMap.find(key);
186 
187  // We apply a filter to get only the Iptc tags that we need.
188 
189  if (!iptcKeysFilter.isEmpty())
190  {
191  if (!invertSelection)
192  {
193  if (iptcKeysFilter.contains(key.section('.', 1, 1)))
194  {
195  if (it == metaDataMap.end())
196  {
197  metaDataMap.insert(key, value);
198  }
199  else
200  {
201  QString v = *it;
202  v.append(", ");
203  v.append(value);
204  metaDataMap.insert(key, v);
205  }
206  }
207  }
208  else
209  {
210  if (!iptcKeysFilter.contains(key.section('.', 1, 1)))
211  {
212  if (it == metaDataMap.end())
213  {
214  metaDataMap.insert(key, value);
215  }
216  else
217  {
218  QString v = *it;
219  v.append(", ");
220  v.append(value);
221  metaDataMap.insert(key, v);
222  }
223  }
224  }
225  }
226  else // else no filter at all.
227  {
228  if (it == metaDataMap.end())
229  {
230  metaDataMap.insert(key, value);
231  }
232  else
233  {
234  QString v = *it;
235  v.append(", ");
236  v.append(value);
237  metaDataMap.insert(key, v);
238  }
239  }
240 
241  }
242 
243  return metaDataMap;
244  }
245  catch (Exiv2::Error& e)
246  {
247  d->printExiv2ExceptionError("Cannot parse Iptc metadata using Exiv2 ", e);
248  }
249  catch(...)
250  {
251  kError() << "Default exception from Exiv2";
252  }
253 
254  return MetaDataMap();
255 }
256 
257 QString KExiv2::getIptcTagTitle(const char* iptcTagName)
258 {
259  try
260  {
261  std::string iptckey(iptcTagName);
262  Exiv2::IptcKey ik(iptckey);
263  return QString::fromLocal8Bit( Exiv2::IptcDataSets::dataSetTitle(ik.tag(), ik.record()) );
264  }
265  catch (Exiv2::Error& e)
266  {
267  d->printExiv2ExceptionError("Cannot get metadata tag title using Exiv2 ", e);
268  }
269  catch(...)
270  {
271  kError() << "Default exception from Exiv2";
272  }
273 
274  return QString();
275 }
276 
277 QString KExiv2::getIptcTagDescription(const char* iptcTagName)
278 {
279  try
280  {
281  std::string iptckey(iptcTagName);
282  Exiv2::IptcKey ik(iptckey);
283  return QString::fromLocal8Bit( Exiv2::IptcDataSets::dataSetDesc(ik.tag(), ik.record()) );
284  }
285  catch (Exiv2::Error& e)
286  {
287  d->printExiv2ExceptionError("Cannot get metadata tag description using Exiv2 ", e);
288  }
289  catch(...)
290  {
291  kError() << "Default exception from Exiv2";
292  }
293 
294  return QString();
295 }
296 
297 bool KExiv2::removeIptcTag(const char* iptcTagName, bool setProgramName) const
298 {
299  if (!setProgramId(setProgramName))
300  return false;
301 
302  try
303  {
304  Exiv2::IptcData::iterator it = d->iptcMetadata().begin();
305  int i = 0;
306 
307  while(it != d->iptcMetadata().end())
308  {
309  QString key = QString::fromLocal8Bit(it->key().c_str());
310 
311  if (key == QString(iptcTagName))
312  {
313  it = d->iptcMetadata().erase(it);
314  ++i;
315  }
316  else
317  {
318  ++it;
319  }
320  };
321 
322  if (i > 0)
323  return true;
324  }
325  catch(Exiv2::Error& e)
326  {
327  d->printExiv2ExceptionError("Cannot remove Iptc tag using Exiv2 ", e);
328  }
329  catch(...)
330  {
331  kError() << "Default exception from Exiv2";
332  }
333 
334  return false;
335 }
336 
337 bool KExiv2::setIptcTagData(const char* iptcTagName, const QByteArray& data, bool setProgramName) const
338 {
339  if (data.isEmpty())
340  return false;
341 
342  if (!setProgramId(setProgramName))
343  return false;
344 
345  try
346  {
347  Exiv2::DataValue val((Exiv2::byte *)data.data(), data.size());
348  d->iptcMetadata()[iptcTagName] = val;
349  return true;
350  }
351  catch(Exiv2::Error& e)
352  {
353  d->printExiv2ExceptionError("Cannot set Iptc tag data into image using Exiv2 ", e);
354  }
355  catch(...)
356  {
357  kError() << "Default exception from Exiv2";
358  }
359 
360  return false;
361 }
362 
363 QByteArray KExiv2::getIptcTagData(const char* iptcTagName) const
364 {
365  try
366  {
367  Exiv2::IptcKey iptcKey(iptcTagName);
368  Exiv2::IptcData iptcData(d->iptcMetadata());
369  Exiv2::IptcData::iterator it = iptcData.findKey(iptcKey);
370 
371  if (it != iptcData.end())
372  {
373  char* const s = new char[(*it).size()];
374  (*it).copy((Exiv2::byte*)s, Exiv2::bigEndian);
375  QByteArray data(s, (*it).size());
376  delete [] s;
377  return data;
378  }
379  }
380  catch(Exiv2::Error& e)
381  {
382  d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
383  .arg(iptcTagName), e);
384  }
385  catch(...)
386  {
387  kError() << "Default exception from Exiv2";
388  }
389 
390  return QByteArray();
391 }
392 
393 QString KExiv2::getIptcTagString(const char* iptcTagName, bool escapeCR) const
394 {
395  try
396  {
397  Exiv2::IptcKey iptcKey(iptcTagName);
398  Exiv2::IptcData iptcData(d->iptcMetadata());
399  Exiv2::IptcData::iterator it = iptcData.findKey(iptcKey);
400 
401  if (it != iptcData.end())
402  {
403  std::ostringstream os;
404  os << *it;
405  QString tagValue(os.str().c_str());
406 
407  if (escapeCR)
408  tagValue.replace('\n', ' ');
409 
410  return tagValue;
411  }
412  }
413  catch(Exiv2::Error& e)
414  {
415  d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
416  .arg(iptcTagName), e);
417  }
418  catch(...)
419  {
420  kError() << "Default exception from Exiv2";
421  }
422 
423  return QString();
424 }
425 
426 bool KExiv2::setIptcTagString(const char* iptcTagName, const QString& value, bool setProgramName) const
427 {
428  if (!setProgramId(setProgramName))
429  return false;
430 
431  try
432  {
433  d->iptcMetadata()[iptcTagName] = std::string(value.toUtf8().constData());
434 
435  // Make sure we have set the charset to UTF-8
436  d->iptcMetadata()["Iptc.Envelope.CharacterSet"] = "\33%G";
437  return true;
438  }
439  catch(Exiv2::Error& e)
440  {
441  d->printExiv2ExceptionError("Cannot set Iptc tag string into image using Exiv2 ", e);
442  }
443  catch(...)
444  {
445  kError() << "Default exception from Exiv2";
446  }
447 
448  return false;
449 }
450 
451 QStringList KExiv2::getIptcTagsStringList(const char* iptcTagName, bool escapeCR) const
452 {
453  try
454  {
455  if (!d->iptcMetadata().empty())
456  {
457  QStringList values;
458  Exiv2::IptcData iptcData(d->iptcMetadata());
459 
460  for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
461  {
462  QString key = QString::fromLocal8Bit(it->key().c_str());
463 
464  if (key == QString(iptcTagName))
465  {
466  QString tagValue = QString::fromUtf8(it->toString().c_str());
467 
468  if (escapeCR)
469  tagValue.replace('\n', ' ');
470 
471  values.append(tagValue);
472  }
473  }
474 
475  return values;
476  }
477  }
478  catch(Exiv2::Error& e)
479  {
480  d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
481  .arg(iptcTagName), e);
482  }
483  catch(...)
484  {
485  kError() << "Default exception from Exiv2";
486  }
487 
488  return QStringList();
489 }
490 
491 bool KExiv2::setIptcTagsStringList(const char* iptcTagName, int maxSize,
492  const QStringList& oldValues, const QStringList& newValues,
493  bool setProgramName) const
494 {
495  if (!setProgramId(setProgramName))
496  return false;
497 
498  try
499  {
500  QStringList oldvals = oldValues;
501  QStringList newvals = newValues;
502 
503  kDebug() << d->filePath.toAscii().constData() << " : " << iptcTagName
504  << " => " << newvals.join(",").toAscii().constData();
505 
506  // Remove all old values.
507  Exiv2::IptcData iptcData(d->iptcMetadata());
508  Exiv2::IptcData::iterator it = iptcData.begin();
509 
510  while(it != iptcData.end())
511  {
512  QString key = QString::fromLocal8Bit(it->key().c_str());
513  QString val = QString::fromUtf8(it->toString().c_str());
514 
515  // Also remove new values to avoid duplicates. They will be added again below.
516  if ( key == QString(iptcTagName) &&
517  (oldvals.contains(val) || newvals.contains(val))
518  )
519  it = iptcData.erase(it);
520  else
521  ++it;
522  };
523 
524  // Add new values.
525 
526  Exiv2::IptcKey iptcTag(iptcTagName);
527 
528  for (QStringList::iterator it = newvals.begin(); it != newvals.end(); ++it)
529  {
530  QString key = *it;
531  key.truncate(maxSize);
532 
533  Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
534  val->read(key.toUtf8().constData());
535  iptcData.add(iptcTag, val.get());
536  }
537 
538  d->iptcMetadata() = iptcData;
539 
540  // Make sure character set is UTF-8
541  setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
542 
543  return true;
544  }
545  catch(Exiv2::Error& e)
546  {
547  d->printExiv2ExceptionError(QString("Cannot set Iptc key '%1' into image using Exiv2 ")
548  .arg(iptcTagName), e);
549  }
550  catch(...)
551  {
552  kError() << "Default exception from Exiv2";
553  }
554 
555  return false;
556 }
557 
558 QStringList KExiv2::getIptcKeywords() const
559 {
560  try
561  {
562  if (!d->iptcMetadata().empty())
563  {
564  QStringList keywords;
565  Exiv2::IptcData iptcData(d->iptcMetadata());
566 
567  for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
568  {
569  QString key = QString::fromLocal8Bit(it->key().c_str());
570 
571  if (key == QString("Iptc.Application2.Keywords"))
572  {
573  QString val = QString::fromUtf8(it->toString().c_str());
574  keywords.append(val);
575  }
576  }
577 
578  kDebug() << d->filePath << " ==> Read Iptc Keywords: " << keywords;
579 
580  return keywords;
581  }
582  }
583  catch(Exiv2::Error& e)
584  {
585  d->printExiv2ExceptionError("Cannot get Iptc Keywords from image using Exiv2 ", e);
586  }
587  catch(...)
588  {
589  kError() << "Default exception from Exiv2";
590  }
591 
592  return QStringList();
593 }
594 
595 bool KExiv2::setIptcKeywords(const QStringList& oldKeywords, const QStringList& newKeywords,
596  bool setProgramName) const
597 {
598  if (!setProgramId(setProgramName))
599  return false;
600 
601  try
602  {
603  QStringList oldkeys = oldKeywords;
604  QStringList newkeys = newKeywords;
605 
606  kDebug() << d->filePath << " ==> New Iptc Keywords: " << newkeys;
607 
608  // Remove all old keywords.
609  Exiv2::IptcData iptcData(d->iptcMetadata());
610  Exiv2::IptcData::iterator it = iptcData.begin();
611 
612  while(it != iptcData.end())
613  {
614  QString key = QString::fromLocal8Bit(it->key().c_str());
615  QString val = QString::fromUtf8(it->toString().c_str());
616 
617  // Also remove new keywords to avoid duplicates. They will be added again below.
618  if ( key == QString("Iptc.Application2.Keywords") &&
619  (oldKeywords.contains(val) || newKeywords.contains(val))
620  )
621  it = iptcData.erase(it);
622  else
623  ++it;
624  };
625 
626  // Add new keywords. Note that Keywords Iptc tag is limited to 64 char but can be redondant.
627 
628  Exiv2::IptcKey iptcTag("Iptc.Application2.Keywords");
629 
630  for (QStringList::iterator it = newkeys.begin(); it != newkeys.end(); ++it)
631  {
632  QString key = *it;
633  key.truncate(64);
634 
635  Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
636  val->read(key.toUtf8().constData());
637  iptcData.add(iptcTag, val.get());
638  }
639 
640  d->iptcMetadata() = iptcData;
641 
642  // Make sure character set is UTF-8
643  setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
644 
645  return true;
646  }
647  catch(Exiv2::Error& e)
648  {
649  d->printExiv2ExceptionError("Cannot set Iptc Keywords into image using Exiv2 ", e);
650  }
651  catch(...)
652  {
653  kError() << "Default exception from Exiv2";
654  }
655 
656  return false;
657 }
658 
659 QStringList KExiv2::getIptcSubjects() const
660 {
661  try
662  {
663  if (!d->iptcMetadata().empty())
664  {
665  QStringList subjects;
666  Exiv2::IptcData iptcData(d->iptcMetadata());
667 
668  for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
669  {
670  QString key = QString::fromLocal8Bit(it->key().c_str());
671 
672  if (key == QString("Iptc.Application2.Subject"))
673  {
674  QString val(it->toString().c_str());
675  subjects.append(val);
676  }
677  }
678 
679  return subjects;
680  }
681  }
682  catch(Exiv2::Error& e)
683  {
684  d->printExiv2ExceptionError("Cannot get Iptc Subjects from image using Exiv2 ", e);
685  }
686  catch(...)
687  {
688  kError() << "Default exception from Exiv2";
689  }
690 
691  return QStringList();
692 }
693 
694 bool KExiv2::setIptcSubjects(const QStringList& oldSubjects, const QStringList& newSubjects,
695  bool setProgramName) const
696 {
697  if (!setProgramId(setProgramName))
698  return false;
699 
700  try
701  {
702  QStringList oldDef = oldSubjects;
703  QStringList newDef = newSubjects;
704 
705  // Remove all old subjects.
706  Exiv2::IptcData iptcData(d->iptcMetadata());
707  Exiv2::IptcData::iterator it = iptcData.begin();
708 
709  while(it != iptcData.end())
710  {
711  QString key = QString::fromLocal8Bit(it->key().c_str());
712  QString val = QString::fromUtf8(it->toString().c_str());
713 
714  if (key == QString("Iptc.Application2.Subject") && oldDef.contains(val))
715  it = iptcData.erase(it);
716  else
717  ++it;
718  };
719 
720  // Add new subjects. Note that Keywords Iptc tag is limited to 236 char but can be redondant.
721 
722  Exiv2::IptcKey iptcTag("Iptc.Application2.Subject");
723 
724  for (QStringList::iterator it = newDef.begin(); it != newDef.end(); ++it)
725  {
726  QString key = *it;
727  key.truncate(236);
728 
729  Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
730  val->read(key.toUtf8().constData());
731  iptcData.add(iptcTag, val.get());
732  }
733 
734  d->iptcMetadata() = iptcData;
735 
736  // Make sure character set is UTF-8
737  setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
738 
739  return true;
740  }
741  catch(Exiv2::Error& e)
742  {
743  d->printExiv2ExceptionError("Cannot set Iptc Subjects into image using Exiv2 ", e);
744  }
745  catch(...)
746  {
747  kError() << "Default exception from Exiv2";
748  }
749 
750  return false;
751 }
752 
753 QStringList KExiv2::getIptcSubCategories() const
754 {
755  try
756  {
757  if (!d->iptcMetadata().empty())
758  {
759  QStringList subCategories;
760  Exiv2::IptcData iptcData(d->iptcMetadata());
761 
762  for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
763  {
764  QString key = QString::fromLocal8Bit(it->key().c_str());
765 
766  if (key == QString("Iptc.Application2.SuppCategory"))
767  {
768  QString val(it->toString().c_str());
769  subCategories.append(val);
770  }
771  }
772 
773  return subCategories;
774  }
775  }
776  catch(Exiv2::Error& e)
777  {
778  d->printExiv2ExceptionError("Cannot get Iptc Sub Categories from image using Exiv2 ", e);
779  }
780  catch(...)
781  {
782  kError() << "Default exception from Exiv2";
783  }
784 
785  return QStringList();
786 }
787 
788 bool KExiv2::setIptcSubCategories(const QStringList& oldSubCategories, const QStringList& newSubCategories,
789  bool setProgramName) const
790 {
791  if (!setProgramId(setProgramName))
792  return false;
793 
794  try
795  {
796  QStringList oldkeys = oldSubCategories;
797  QStringList newkeys = newSubCategories;
798 
799  // Remove all old Sub Categories.
800  Exiv2::IptcData iptcData(d->iptcMetadata());
801  Exiv2::IptcData::iterator it = iptcData.begin();
802 
803  while(it != iptcData.end())
804  {
805  QString key = QString::fromLocal8Bit(it->key().c_str());
806  QString val = QString::fromUtf8(it->toString().c_str());
807 
808  if (key == QString("Iptc.Application2.SuppCategory") && oldSubCategories.contains(val))
809  it = iptcData.erase(it);
810  else
811  ++it;
812  };
813 
814  // Add new Sub Categories. Note that SubCategories Iptc tag is limited to 32
815  // characters but can be redondant.
816 
817  Exiv2::IptcKey iptcTag("Iptc.Application2.SuppCategory");
818 
819  for (QStringList::iterator it = newkeys.begin(); it != newkeys.end(); ++it)
820  {
821  QString key = *it;
822  key.truncate(32);
823 
824  Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
825  val->read(key.toUtf8().constData());
826  iptcData.add(iptcTag, val.get());
827  }
828 
829  d->iptcMetadata() = iptcData;
830 
831  // Make sure character set is UTF-8
832  setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
833 
834  return true;
835  }
836  catch(Exiv2::Error& e)
837  {
838  d->printExiv2ExceptionError("Cannot set Iptc Sub Categories into image using Exiv2 ", e);
839  }
840  catch(...)
841  {
842  kError() << "Default exception from Exiv2";
843  }
844 
845  return false;
846 }
847 
848 KExiv2::TagsMap KExiv2::getIptcTagsList() const
849 {
850  try
851  {
852  QList<const Exiv2::DataSet*> tags;
853  tags << Exiv2::IptcDataSets::envelopeRecordList()
854  << Exiv2::IptcDataSets::application2RecordList();
855 
856  TagsMap tagsMap;
857  for (QList<const Exiv2::DataSet*>::iterator it = tags.begin(); it != tags.end(); ++it)
858  {
859  do
860  {
861  QString key = QLatin1String( Exiv2::IptcKey( (*it)->number_, (*it)->recordId_ ).key().c_str() );
862  QStringList values;
863  values << (*it)->name_ << (*it)->title_ << (*it)->desc_;
864  tagsMap.insert(key, values);
865  ++(*it);
866  }
867  while((*it)->number_ != 0xffff);
868  }
869  return tagsMap;
870  }
871  catch(Exiv2::Error& e)
872  {
873  d->printExiv2ExceptionError("Cannot get Iptc Tags list using Exiv2 ", e);
874  }
875  catch(...)
876  {
877  kError() << "Default exception from Exiv2";
878  }
879 
880  return TagsMap();
881 }
882 
883 } // NameSpace KExiv2Iface
KExiv2Iface::KExiv2::getIptcTagsDataList
KExiv2::MetaDataMap getIptcTagsDataList(const QStringList &iptcKeysFilter=QStringList(), bool invertSelection=false) const
Return a map of Iptc tags name/value found in metadata sorted by Iptc keys given by 'iptcKeysFilter'...
Definition: kexiv2iptc.cpp:149
KExiv2Iface::KExiv2::getIptcTagString
QString getIptcTagString(const char *iptcTagName, bool escapeCR=true) const
Get an Iptc tag content like a string.
Definition: kexiv2iptc.cpp:393
QString::append
QString & append(QChar ch)
KExiv2Iface::KExiv2::getIptcKeywords
QStringList getIptcKeywords() const
Return a strings list of Iptc keywords from image.
Definition: kexiv2iptc.cpp:558
QString::truncate
void truncate(int position)
KExiv2Iface::KExiv2::getIptcTagsList
KExiv2::TagsMap getIptcTagsList() const
Return a map of all standard Iptc tags supported by Exiv2.
Definition: kexiv2iptc.cpp:848
KExiv2Iface::KExiv2::Private::iptcMetadata
const Exiv2::IptcData & iptcMetadata() const
Definition: kexiv2_p.h:164
QByteArray
KExiv2Iface::KExiv2::setIptcTagData
bool setIptcTagData(const char *iptcTagName, const QByteArray &data, bool setProgramName=true) const
Set an Iptc tag content using a bytes array.
Definition: kexiv2iptc.cpp:337
QMap
KExiv2Iface::KExiv2::getIptcSubCategories
QStringList getIptcSubCategories() const
Return a strings list of Iptc sub-categories from image.
Definition: kexiv2iptc.cpp:753
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QByteArray::isEmpty
bool isEmpty() const
KExiv2Iface::KExiv2::Private::filePath
QString filePath
Definition: kexiv2_p.h:206
QStringList::join
QString join(const QString &separator) const
KExiv2Iface::KExiv2::hasIptc
bool hasIptc() const
Return 'true' if metadata container in memory as Iptc.
Definition: kexiv2iptc.cpp:58
KExiv2Iface::KExiv2::setIptc
bool setIptc(const QByteArray &data) const
Set the Iptc data using a Qt byte array.
Definition: kexiv2iptc.cpp:122
KExiv2Iface::KExiv2::getIptcTagsStringList
QStringList getIptcTagsStringList(const char *iptcTagName, bool escapeCR=true) const
Returns a strings list with of multiple Iptc tags from the image.
Definition: kexiv2iptc.cpp:451
KExiv2Iface::KExiv2::getIptcTagData
QByteArray getIptcTagData(const char *iptcTagName) const
Get an Iptc tag content as a bytes array.
Definition: kexiv2iptc.cpp:363
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
QList::append
void append(const T &value)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
KExiv2Iface::KExiv2::setIptcSubCategories
bool setIptcSubCategories(const QStringList &oldSubCategories, const QStringList &newSubCategories, bool setProgramName=true) const
Set Iptc sub-categories using a list of strings defined by 'newSubCategories' parameter.
Definition: kexiv2iptc.cpp:788
KExiv2Iface::KExiv2::setIptcTagsStringList
bool setIptcTagsStringList(const char *iptcTagName, int maxSize, const QStringList &oldValues, const QStringList &newValues, bool setProgramName=true) const
Set multiple Iptc tags contents using a strings list.
Definition: kexiv2iptc.cpp:491
QList::isEmpty
bool isEmpty() const
KExiv2Iface::KExiv2::getIptcTagDescription
QString getIptcTagDescription(const char *iptcTagName)
Return the Iptc Tag description or a null string.
Definition: kexiv2iptc.cpp:277
QString::isEmpty
bool isEmpty() const
KExiv2Iface::KExiv2::MetaDataMap
QMap< QString, QString > MetaDataMap
A map used to store Tags Key and Tags Value.
Definition: kexiv2.h:123
QByteArray::constData
const char * constData() const
QString
QList
QMap::end
iterator end()
QList::iterator
QStringList
QList::end
iterator end()
KExiv2Iface::KExiv2::removeIptcTag
bool removeIptcTag(const char *iptcTagName, bool setProgramName=true) const
Remove the all instance of Iptc tags 'iptcTagName' from Iptc metadata.
Definition: kexiv2iptc.cpp:297
KExiv2Iface::KExiv2::setIptcTagString
bool setIptcTagString(const char *iptcTagName, const QString &value, bool setProgramName=true) const
Set an Iptc tag content using a string.
Definition: kexiv2iptc.cpp:426
KExiv2Iface::KExiv2::setProgramId
virtual bool setProgramId(bool on=true) const
Re-implement this method to set automatically the Program Name and Program Version information in Exi...
Definition: kexiv2.cpp:541
KExiv2Iface::KExiv2::canWriteIptc
static bool canWriteIptc(const QString &filePath)
Return 'true' if Iptc can be written in file.
Definition: kexiv2iptc.cpp:34
QString::replace
QString & replace(int position, int n, QChar after)
KExiv2Iface::KExiv2::TagsMap
QMap< QString, QStringList > TagsMap
A map used to store Tags Key and a list of Tags properties :
Definition: kexiv2.h:136
KExiv2Iface::KExiv2::Private::printExiv2ExceptionError
static void printExiv2ExceptionError(const QString &msg, Exiv2::Error &e)
Generic method to print the Exiv2 C++ Exception error message from 'e'.
QLatin1String
KExiv2Iface::KExiv2::setIptcKeywords
bool setIptcKeywords(const QStringList &oldKeywords, const QStringList &newKeywords, bool setProgramName=true) const
Set Iptc keywords using a list of strings defined by 'newKeywords' parameter.
Definition: kexiv2iptc.cpp:595
kexiv2_p.h
===========================================================This file is a part of digiKam project htt...
QByteArray::data
char * data()
QString::section
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
KExiv2Iface::KExiv2::getIptcTagTitle
QString getIptcTagTitle(const char *iptcTagName)
Return the Iptc Tag title or a null string.
Definition: kexiv2iptc.cpp:257
KExiv2Iface::KExiv2::setIptcSubjects
bool setIptcSubjects(const QStringList &oldSubjects, const QStringList &newSubjects, bool setProgramName=true) const
Set Iptc subjects using a list of strings defined by 'newSubjects' parameter.
Definition: kexiv2iptc.cpp:694
QMap::insert
iterator insert(const Key &key, const T &value)
KExiv2Iface::KExiv2::getIptcSubjects
QStringList getIptcSubjects() const
Return a strings list of Iptc subjects from image.
Definition: kexiv2iptc.cpp:659
QByteArray::size
int size() const
KExiv2Iface::KExiv2::data
KExiv2Data data() const
Definition: kexiv2.cpp:218
QMap::find
iterator find(const Key &key)
QList::begin
iterator begin()
KExiv2Iface::KExiv2::getIptc
QByteArray getIptc(bool addIrbHeader=false) const
Return a Qt byte array copy of Iptc container get from current image.
Definition: kexiv2iptc.cpp:82
QMap::iterator
kexiv2.h
===========================================================This file is a part of digiKam project htt...
QFile::encodeName
QByteArray encodeName(const QString &fileName)
QString::toAscii
QByteArray toAscii() const
KExiv2Iface::KExiv2::clearIptc
bool clearIptc() const
Clear the Iptc metadata container in memory.
Definition: kexiv2iptc.cpp:63
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libkexiv2/libkexiv2

Skip menu "libs/libkexiv2/libkexiv2"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal