1. shuerhaaken
  2. libtaginfo

Commits

shuerhaaken  committed 137deec

image extraction works

  • Participants
  • Parent commits 0d3ddfb
  • Branches master

Comments (0)

Files changed (12)

File ChangeLog

View file
+commit 0d3ddfbe259f9c28cb0dfe379e19555958d84368
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Tue Oct 29 16:14:26 2013 +0100
+
+    fixes
+
 commit 32865e540a7ea6300f8ec3c5dbfe3815346dfd7a
 Author: Jörn Magens <shuerhaaken@googlemail.com>
 Date:   Tue Oct 29 15:45:17 2013 +0100

File libtaginfo/apetaginfo.cc

View file
 
 
 #include <apefile.h>
+#include <apetag.h>
 
 
 #define APE_TAG_DISK                "DISC"
 #define APE_TAG_COMPOSER            "COMPOSER" 
 #define APE_TAG_COMMENT             "COMMENT" 
 #define APE_TAG_YEAR                "YEAR" 
-#define APE_TAG_COVER_ART_FRONT     "COVER ART (FRONT)" 
-#define APE_TAG_COVER_ART_OTHER     "COVER ART (OTHER)" 
 #define APE_TAG_LYRICS              "LYRICS" 
 #define APE_TAG_LYRICS_UNSYNCED     "UNSYNCED LYRICS"
 #define APE_TAG_RATING              "RATING"
 #define APE_TAG_ENCODER             "ENCODED BY"
 #define APE_TAG_HOMEPAGE            "RELATED"
 
+#define TRACK_LABELS                "TRACK_LABELS"
+#define ALBUM_LABELS                "ALBUM_LABELS"
+#define ARTIST_LABELS               "ARTIST_LABELS"
+
+#define APE_TAG_COVER_ART_OTHER             "COVER ART (OTHER)"
+#define APE_TAG_COVER_ART_ICON	            "COVER ART (ICON)"
+#define APE_TAG_COVER_ART_OTHER_ICON        "COVER ART (OTHER ICON)"
+#define APE_TAG_COVER_ART_FRONT             "COVER ART (FRONT)"
+#define APE_TAG_COVER_ART_BACK              "COVER ART (BACK)"
+#define APE_TAG_COVER_ART_LEAFLET           "COVER ART (LEAFLET)"
+#define APE_TAG_COVER_ART_MEDIA             "COVER ART (MEDIA)"
+#define APE_TAG_COVER_ART_LEAD              "COVER ART (LEAD)"
+#define APE_TAG_COVER_ART_ARTIST            "COVER ART (ARTIST)"
+#define APE_TAG_COVER_ART_CONDUCTOR         "COVER ART (CONDUCTOR)"
+#define APE_TAG_COVER_ART_BAND              "COVER ART (BAND)"
+#define APE_TAG_COVER_ART_COMPOSER          "COVER ART (COMPOSER)"
+#define APE_TAG_COVER_ART_LYRICIST          "COVER ART (LYRICIST)"
+#define APE_TAG_COVER_ART_STUDIO            "COVER ART (STUDIO)"
+#define APE_TAG_COVER_ART_RECORDING         "COVER ART (RECORDING)"
+#define APE_TAG_COVER_ART_PERFORMANCE       "COVER ART (PERFORMANCE)"
+#define APE_TAG_COVER_ART_MOVIE_SCENE       "COVER ART (MOVIE SCENE)"
+#define APE_TAG_COVER_ART_COLORED_FISH      "COVER ART (COLORED FISH)"
+#define APE_TAG_COVER_ART_ILLUSTRATION      "COVER ART (ILLUSTRATION)"
+#define APE_TAG_COVER_ART_BAND_LOGO         "COVER ART (BAND LOGO)"
+#define APE_TAG_COVER_ART_PUBLISHER_LOGO    "COVER ART (PUBLISHER LOGO)"
+
+
 using namespace TagInfo;
 using namespace TagLib;
 
     image->data_length = 0;
 }
 
+String image_type_to_ape_image_name(const ImageType& image_type) {
+    String itp;
+    switch(image_type) {
+        case IMAGE_TYPE_COVER_FRONT :
+            itp = APE_TAG_COVER_ART_FRONT;
+            break;
+        case IMAGE_TYPE_COVER_BACK :
+            itp = APE_TAG_COVER_ART_BACK;
+            break;
+        case IMAGE_TYPE_OTHER :
+            itp = APE_TAG_COVER_ART_OTHER;
+            break;
+        case IMAGE_TYPE_FILE_ICON :
+            itp = APE_TAG_COVER_ART_ICON;
+            break;
+        case IMAGE_TYPE_OTHER_FILE_ICON :
+            itp = APE_TAG_COVER_ART_OTHER_ICON;
+            break;
+        case IMAGE_TYPE_LEAFLET_PAGE :
+            itp = APE_TAG_COVER_ART_LEAFLET;
+            break;
+        case IMAGE_TYPE_MEDIA  :
+            itp = APE_TAG_COVER_ART_MEDIA;
+            break;
+        case IMAGE_TYPE_LEAD_ARTIST :
+            itp = APE_TAG_COVER_ART_LEAD;
+            break;
+        case IMAGE_TYPE_ARTIST :
+            itp = APE_TAG_COVER_ART_ARTIST;
+            break;
+        case IMAGE_TYPE_CONDUCTOR :
+            itp = APE_TAG_COVER_ART_CONDUCTOR;
+            break;
+        case IMAGE_TYPE_BAND :
+            itp = APE_TAG_COVER_ART_BAND;
+            break;
+        case IMAGE_TYPE_COMPOSER :
+            itp = APE_TAG_COVER_ART_COMPOSER;
+            break;
+        case IMAGE_TYPE_LYRICIST :
+            itp = APE_TAG_COVER_ART_LYRICIST;
+            break;
+        case IMAGE_TYPE_RECORDING_LOCATION :
+            itp = APE_TAG_COVER_ART_STUDIO;
+            break;
+        case IMAGE_TYPE_DURING_RECORDING :
+            itp = APE_TAG_COVER_ART_RECORDING;
+            break;
+        case IMAGE_TYPE_DURING_PERFORMANCE :
+            itp = APE_TAG_COVER_ART_PERFORMANCE;;
+            break;
+        case IMAGE_TYPE_MOVIESCREENCAPTURE :
+            itp = APE_TAG_COVER_ART_MOVIE_SCENE;;
+            break;
+        case IMAGE_TYPE_COLOURED_FISH :
+            itp = APE_TAG_COVER_ART_COLORED_FISH;
+            break;
+        case IMAGE_TYPE_ILLUSTRATION :
+            itp = APE_TAG_COVER_ART_ILLUSTRATION;
+            break;
+        case IMAGE_TYPE_ARTIST_LOGO :
+            itp = APE_TAG_COVER_ART_BAND_LOGO;
+            break;
+        case IMAGE_TYPE_PUBLISHER_LOGO :
+            itp = APE_TAG_COVER_ART_PUBLISHER_LOGO;
+            break;
+        default:
+            itp = APE_TAG_COVER_ART_OTHER;
+            break;
+    }
+    return itp;
+}
+
+ImageType ape_image_type_to_image_type(const String &nme) {
+
+    ImageType itp;
+    if(nme == APE_TAG_COVER_ART_OTHER)
+        itp = IMAGE_TYPE_OTHER;
+    else if(nme == APE_TAG_COVER_ART_ICON)
+        itp = IMAGE_TYPE_FILE_ICON;
+    else if(nme == APE_TAG_COVER_ART_OTHER_ICON)
+        itp = IMAGE_TYPE_OTHER_FILE_ICON;
+    else if(nme == APE_TAG_COVER_ART_FRONT)
+        itp = IMAGE_TYPE_COVER_FRONT;
+    else if(nme == APE_TAG_COVER_ART_BACK)
+        itp = IMAGE_TYPE_COVER_BACK;
+    else if(nme == APE_TAG_COVER_ART_LEAFLET)
+        itp = IMAGE_TYPE_LEAFLET_PAGE;
+    else if(nme == APE_TAG_COVER_ART_MEDIA)
+        itp = IMAGE_TYPE_MEDIA;
+    else if(nme == APE_TAG_COVER_ART_LEAD)
+        itp = IMAGE_TYPE_LEAD_ARTIST;
+    else if(nme == APE_TAG_COVER_ART_ARTIST)
+        itp = IMAGE_TYPE_ARTIST;
+    else if(nme == APE_TAG_COVER_ART_CONDUCTOR)
+        itp = IMAGE_TYPE_CONDUCTOR;
+    else if(nme == APE_TAG_COVER_ART_BAND)
+        itp = IMAGE_TYPE_BAND;
+    else if(nme == APE_TAG_COVER_ART_COMPOSER)
+        itp = IMAGE_TYPE_COMPOSER;
+    else if(nme == APE_TAG_COVER_ART_LYRICIST)
+        itp = IMAGE_TYPE_LYRICIST;
+    else if(nme == APE_TAG_COVER_ART_STUDIO)
+        itp = IMAGE_TYPE_RECORDING_LOCATION;
+    else if(nme == APE_TAG_COVER_ART_RECORDING)
+        itp = IMAGE_TYPE_DURING_RECORDING;
+    else if(nme == APE_TAG_COVER_ART_PERFORMANCE)
+        itp = IMAGE_TYPE_DURING_PERFORMANCE;
+    else if(nme == APE_TAG_COVER_ART_MOVIE_SCENE)
+        itp = IMAGE_TYPE_MOVIESCREENCAPTURE;
+    else if(nme == APE_TAG_COVER_ART_COLORED_FISH)
+        itp = IMAGE_TYPE_COLOURED_FISH;
+    else if(nme == APE_TAG_COVER_ART_ILLUSTRATION)
+        itp = IMAGE_TYPE_ILLUSTRATION;
+    else if(nme == APE_TAG_COVER_ART_BAND_LOGO)
+        itp = IMAGE_TYPE_ARTIST_LOGO;
+    else if(nme == APE_TAG_COVER_ART_PUBLISHER_LOGO)
+        itp = IMAGE_TYPE_PUBLISHER_LOGO;
+    else
+        itp = IMAGE_TYPE_OTHER;
+
+    return itp;
+}
+
 
 ApeTagInfo::ApeTagInfo(const String &filename) : Info(filename) {
     taglib_apetag = NULL;
                 album_artist = taglib_apetag->itemListMap()["ALBUMARTIST"].toStringList().front();
             }
             
-            // Rating
+            // Rating 
             if(taglib_apetag->itemListMap().contains(APE_TAG_RATING)) {
                 long rat = 0;
                 rat = atol(taglib_apetag->itemListMap()[APE_TAG_RATING].toStringList().front().toCString(true));
             }
             // Labels
             if(track_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("TRACK_LABELS")) {
-                    track_labels_string = taglib_apetag->itemListMap()["TRACK_LABELS"].toStringList().front();
+                if(taglib_apetag->itemListMap().contains(TRACK_LABELS)) {
+                    track_labels_string = taglib_apetag->itemListMap()[TRACK_LABELS].toStringList().front();
                     track_labels = split(track_labels_string, "|");
                 }
             }
             if(artist_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("ARTIST_LABELS")) {
-                    artist_labels_string = taglib_apetag->itemListMap()["ARTIST_LABELS"].toStringList().front();
+                if(taglib_apetag->itemListMap().contains(ARTIST_LABELS)) {
+                    artist_labels_string = taglib_apetag->itemListMap()[ARTIST_LABELS].toStringList().front();
                     artist_labels = split(artist_labels_string, "|");
                 }
             }
             if(album_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("ALBUM_LABELS")) {
-                    album_labels_string = taglib_apetag->itemListMap()["ALBUM_LABELS"].toStringList().front();
+                if(taglib_apetag->itemListMap().contains(ALBUM_LABELS)) {
+                    album_labels_string = taglib_apetag->itemListMap()[ALBUM_LABELS].toStringList().front();
                     album_labels = split(album_labels_string, "|");
                 }
             }
-            if(taglib_apetag->itemListMap().contains(APE_TAG_COVER_ART_FRONT)) {
-                has_image = true;
-            }
-            else if(taglib_apetag->itemListMap().contains(APE_TAG_COVER_ART_OTHER)) {
-                has_image = true;
+            APE::ItemListMap map = taglib_apetag->itemListMap();
+            for(APE::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
+                if(true ||
+                   it->first == APE_TAG_COVER_ART_OTHER          ||
+                   it->first == APE_TAG_COVER_ART_ICON	         ||
+                   it->first == APE_TAG_COVER_ART_OTHER_ICON     ||
+                   it->first == APE_TAG_COVER_ART_FRONT          ||
+                   it->first == APE_TAG_COVER_ART_BACK           ||
+                   it->first == APE_TAG_COVER_ART_LEAFLET        ||
+                   it->first == APE_TAG_COVER_ART_MEDIA          ||
+                   it->first == APE_TAG_COVER_ART_LEAD           ||
+                   it->first == APE_TAG_COVER_ART_ARTIST         ||
+                   it->first == APE_TAG_COVER_ART_CONDUCTOR      ||
+                   it->first == APE_TAG_COVER_ART_BAND           ||
+                   it->first == APE_TAG_COVER_ART_COMPOSER       ||
+                   it->first == APE_TAG_COVER_ART_LYRICIST       ||
+                   it->first == APE_TAG_COVER_ART_STUDIO         ||
+                   it->first == APE_TAG_COVER_ART_RECORDING      ||
+                   it->first == APE_TAG_COVER_ART_PERFORMANCE    ||
+                   it->first == APE_TAG_COVER_ART_MOVIE_SCENE    ||
+                   it->first == APE_TAG_COVER_ART_COLORED_FISH   ||
+                   it->first == APE_TAG_COVER_ART_ILLUSTRATION   ||
+                   it->first == APE_TAG_COVER_ART_BAND_LOGO      ||
+                   it->first == APE_TAG_COVER_ART_PUBLISHER_LOGO ||
+                   true) {
+                    has_image = true;
+                }
             }
             return true;
         }
                 }
             }
             if(changedflag & CHANGED_DATA_ALBUMARTIST)
-                taglib_apetag->addValue(APE_TAG_ALBUMARTIST, album_artist, true);
+                    taglib_apetag->addValue(APE_TAG_ALBUMARTIST, album_artist, true);
             
             if(changedflag & CHANGED_DATA_RATING) {
                 taglib_apetag->addValue(APE_TAG_RATING, format("%u", rating_to_popularity(rating)), true);
             }
             if(changedflag & CHANGED_DATA_PLAYCOUNT) {
-                taglib_apetag->addValue("PLAY_COUNTER", format("%u", playcount), true);
+                taglib_apetag->addValue(APE_TAG_PLAYCNT, format("%u", playcount), true);
             }
             if(changedflag & CHANGED_TRACK_LABELS)
-                check_ape_label_frame(taglib_apetag, "TRACK_LABELS",  track_labels_string);
+                check_ape_label_frame(taglib_apetag, TRACK_LABELS,  track_labels_string);
             if(changedflag & CHANGED_ARTIST_LABELS)
-                check_ape_label_frame(taglib_apetag, "ARTIST_LABELS", artist_labels_string);
+                check_ape_label_frame(taglib_apetag, ARTIST_LABELS, artist_labels_string);
             if(changedflag & CHANGED_ALBUM_LABELS)
-                check_ape_label_frame(taglib_apetag, "ALBUM_LABELS",  album_labels_string);
+                check_ape_label_frame(taglib_apetag, ALBUM_LABELS,  album_labels_string);
             save_base_tags((TagLib::Tag *)taglib_apetag);
         }
     }
     return Info::save();
 }
 
-
 Image ** ApeTagInfo::get_images(int &image_count) const {
     if(taglib_apetag && !taglib_apetag->isEmpty()) {
         image_count = 0;
         Image** images;
+        List<Image*> imageList;
         if(taglib_apetag) {
-            images = new Image*[2];
             Image * image = NULL;
             int i = 0;
-            if(taglib_apetag->itemListMap().contains(APE_TAG_COVER_ART_FRONT)) {
-                image = new Image();
-                get_ape_item_image(taglib_apetag->itemListMap()[APE_TAG_COVER_ART_FRONT], image);
-                if(image->data && image->data_length > 0) {
-                    image->image_type = IMAGE_TYPE_COVER_FRONT;
-                    images[i] = image;
-                    i++;
-                }
+            APE::ItemListMap map = taglib_apetag->itemListMap();
+            for(APE::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
+                if(true ||
+                   it->first == APE_TAG_COVER_ART_OTHER          ||
+                   it->first == APE_TAG_COVER_ART_ICON	         ||
+                   it->first == APE_TAG_COVER_ART_OTHER_ICON     ||
+                   it->first == APE_TAG_COVER_ART_FRONT          ||
+                   it->first == APE_TAG_COVER_ART_BACK           ||
+                   it->first == APE_TAG_COVER_ART_LEAFLET        ||
+                   it->first == APE_TAG_COVER_ART_MEDIA          ||
+                   it->first == APE_TAG_COVER_ART_LEAD           ||
+                   it->first == APE_TAG_COVER_ART_ARTIST         ||
+                   it->first == APE_TAG_COVER_ART_CONDUCTOR      ||
+                   it->first == APE_TAG_COVER_ART_BAND           ||
+                   it->first == APE_TAG_COVER_ART_COMPOSER       ||
+                   it->first == APE_TAG_COVER_ART_LYRICIST       ||
+                   it->first == APE_TAG_COVER_ART_STUDIO         ||
+                   it->first == APE_TAG_COVER_ART_RECORDING      ||
+                   it->first == APE_TAG_COVER_ART_PERFORMANCE    ||
+                   it->first == APE_TAG_COVER_ART_MOVIE_SCENE    ||
+                   it->first == APE_TAG_COVER_ART_COLORED_FISH   ||
+                   it->first == APE_TAG_COVER_ART_ILLUSTRATION   ||
+                   it->first == APE_TAG_COVER_ART_BAND_LOGO      ||
+                   it->first == APE_TAG_COVER_ART_PUBLISHER_LOGO ||
+                   true) {
+                    image = new Image();
+                    get_ape_item_image(it->second, image);
+                    if(image->data && image->data_length > 0) {
+                        image->image_type = ape_image_type_to_image_type(it->first);
+                        imageList.prepend(image);
+                        i++;
+                    }
+                    else {
+                        delete image;
+                    }
+               }
             }
-            else if(taglib_apetag->itemListMap().contains(APE_TAG_COVER_ART_OTHER)) {
-                image = new Image();
-                get_ape_item_image(taglib_apetag->itemListMap()[APE_TAG_COVER_ART_OTHER], image);
-                if(image->data && image->data_length > 0) {
-                    image->image_type = IMAGE_TYPE_OTHER;
-                    images[i] = image;
-                    i++;
+            if(0 < i) {
+                images = new Image*[i];
+                for(List<Image *>::Iterator it = imageList.begin(); it != imageList.end(); ++it) {
+                    images[image_count] = (*it);
                 }
+                image_count = i;
+                return images;
             }
-            image_count = i;
         }
-        return images;
+        
     }
     return NULL;
 }
 void ApeTagInfo::set_images(const Image ** images, const int image_count) {
     if(taglib_apetag) {
         APE::ItemListMap listmap = taglib_apetag->itemListMap();
-        if(listmap.contains(APE_TAG_COVER_ART_FRONT))
-            taglib_apetag->removeItem(APE_TAG_COVER_ART_FRONT);
-        if(listmap.contains(APE_TAG_COVER_ART_OTHER))
-            taglib_apetag->removeItem(APE_TAG_COVER_ART_OTHER);
         
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_OTHER);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_ICON);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_OTHER_ICON);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_FRONT);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_BACK);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_LEAFLET);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_MEDIA);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_LEAD);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_ARTIST);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_CONDUCTOR);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_BAND);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_COMPOSER);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_LYRICIST);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_STUDIO);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_RECORDING);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_PERFORMANCE);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_MOVIE_SCENE);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_COLORED_FISH);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_ILLUSTRATION);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_BAND_LOGO);
+        taglib_apetag->removeItem(APE_TAG_COVER_ART_PUBLISHER_LOGO);
+                
         for(int p = 0; p < image_count; p++) {
             if(!images[p]->data || images[p]->data_length == 0)
                 continue;
             
             APE::Item imageItem = APE::Item();
             imageItem.setType(TagLib::APE::Item::Binary);
-            if(images[p]->image_type == IMAGE_TYPE_COVER_FRONT)
-                imageItem.setKey(APE_TAG_COVER_ART_FRONT);
-            else
-                imageItem.setKey(APE_TAG_COVER_ART_OTHER);
+            String key = image_type_to_ape_image_name(images[p]->image_type);
+            imageItem.setKey(key);
             imageItem.setBinaryData(ImgData);
-            if(images[p]->image_type == IMAGE_TYPE_COVER_FRONT)
-                taglib_apetag->setItem(APE_TAG_COVER_ART_FRONT, imageItem);
-            else
-                taglib_apetag->setItem(APE_TAG_COVER_ART_OTHER, imageItem);
+            taglib_apetag->setItem(key, imageItem);
         }
     }
 }

File libtaginfo/asfinfo.cc

View file
 
 
 #include <asffile.h>
+#include <asftag.h>
+#include <asfpicture.h>
 
 
 #define COMPILATION_FLAG         "WM/PartOfACompilation"
 #define PICTURE_FLAG             "WM/Picture"
-#define TOTAL_TRACKS             "TrackTotal" // seems not to be official, but it is like in taglib sharp
+#define TOTAL_TRACKS             "TrackTotal"
+#define ALBUM_ARTIST             "WM/AlbumArtist"
+#define VOLUME_NUMBER            "WM/PartOfSet"
+#define COMPOSER                 "WM/Composer"
+#define ORIGINAL_ARTIST          "WM/OriginalArtist"
+#define COPYRIGHT                "Copyright"
+#define ENCODER                  "WM/EncodedBy"
+#define HOMEPAGE                 "URL"
+#define SHARED_RATING            "WM/SharedUserRating"
+#define TRACK_LABELS             "TRACK_LABELS"
+#define ALBUM_LABELS             "ALBUM_LABELS"
+#define ARTIST_LABELS            "ARTIST_LABELS"
+#define LYRICS                   "WM/Lyrics"
+
 
 using namespace TagInfo;
 
     return 5;
 }
 
+ImageType get_image_type_from_pic_type(const ASF::Picture::Type& tpe) {
+    ImageType itp = IMAGE_TYPE_OTHER;
+    switch(tpe) {
+        case ASF::Picture::FrontCover :
+            itp = IMAGE_TYPE_COVER_FRONT;
+            break;
+        case ASF::Picture::BackCover :
+            itp = IMAGE_TYPE_COVER_BACK;
+            break;
+        case ASF::Picture::Other :
+            itp = IMAGE_TYPE_OTHER;
+            break;
+        case ASF::Picture::FileIcon :
+            itp = IMAGE_TYPE_FILE_ICON;
+            break;
+        case ASF::Picture::OtherFileIcon :
+            itp = IMAGE_TYPE_OTHER_FILE_ICON;
+            break;
+        case ASF::Picture::LeafletPage :
+            itp = IMAGE_TYPE_LEAFLET_PAGE;
+            break;
+        case ASF::Picture::Media :
+            itp = IMAGE_TYPE_MEDIA;
+            break;
+        case ASF::Picture::LeadArtist :
+            itp = IMAGE_TYPE_LEAD_ARTIST;
+            break;
+        case ASF::Picture::Artist :
+            itp = IMAGE_TYPE_ARTIST;
+            break;
+        case ASF::Picture::Conductor :
+            itp = IMAGE_TYPE_CONDUCTOR;
+            break;
+        case ASF::Picture::Band :
+            itp = IMAGE_TYPE_BAND;
+            break;
+        case ASF::Picture::Composer :
+            itp = IMAGE_TYPE_COMPOSER;
+            break;
+        case ASF::Picture::Lyricist :
+            itp = IMAGE_TYPE_LYRICIST;
+            break;
+        case ASF::Picture::RecordingLocation :
+            itp = IMAGE_TYPE_RECORDING_LOCATION;
+            break;
+        case ASF::Picture::DuringRecording :
+            itp = IMAGE_TYPE_DURING_RECORDING;
+            break;
+        case ASF::Picture::DuringPerformance :
+            itp = IMAGE_TYPE_DURING_PERFORMANCE;
+            break;
+        case ASF::Picture::MovieScreenCapture :
+            itp = IMAGE_TYPE_MOVIESCREENCAPTURE;
+            break;
+        case ASF::Picture::ColouredFish :
+            itp = IMAGE_TYPE_COLOURED_FISH;
+            break;
+        case ASF::Picture::Illustration :
+            itp = IMAGE_TYPE_ILLUSTRATION;
+            break;
+        case ASF::Picture::BandLogo :
+            itp = IMAGE_TYPE_ARTIST_LOGO;
+            break;
+        case ASF::Picture::PublisherLogo :
+            itp = IMAGE_TYPE_PUBLISHER_LOGO;
+            break;
+        default:
+            itp = IMAGE_TYPE_OTHER;
+            break;
+    }
+    return itp;
+}
+
+ASF::Picture::Type image_type_to_picture_type(const ImageType& image_type) {
+    ASF::Picture::Type itp;
+    switch(image_type) {
+        case IMAGE_TYPE_COVER_FRONT :
+            itp = ASF::Picture::FrontCover;
+            break;
+        case IMAGE_TYPE_COVER_BACK :
+            itp = ASF::Picture::BackCover;
+            break;
+        case IMAGE_TYPE_OTHER :
+            itp = ASF::Picture::Other;
+            break;
+        case IMAGE_TYPE_FILE_ICON :
+            itp = ASF::Picture::FileIcon;
+            break;
+        case IMAGE_TYPE_OTHER_FILE_ICON :
+            itp = ASF::Picture::OtherFileIcon;
+            break;
+        case IMAGE_TYPE_LEAFLET_PAGE :
+            itp = ASF::Picture::LeafletPage;
+            break;
+        case IMAGE_TYPE_MEDIA  :
+            itp = ASF::Picture::Media;
+            break;
+        case IMAGE_TYPE_LEAD_ARTIST :
+            itp = ASF::Picture::LeadArtist;
+            break;
+        case IMAGE_TYPE_ARTIST :
+            itp = ASF::Picture::Artist;
+            break;
+        case IMAGE_TYPE_CONDUCTOR :
+            itp = ASF::Picture::Conductor;
+            break;
+        case IMAGE_TYPE_BAND :
+            itp = ASF::Picture::Band;
+            break;
+        case IMAGE_TYPE_COMPOSER :
+            itp = ASF::Picture::Composer;
+            break;
+        case IMAGE_TYPE_LYRICIST :
+            itp = ASF::Picture::Lyricist;
+            break;
+        case IMAGE_TYPE_RECORDING_LOCATION :
+            itp = ASF::Picture::RecordingLocation;
+            break;
+        case IMAGE_TYPE_DURING_RECORDING :
+            itp = ASF::Picture::DuringRecording;
+            break;
+        case IMAGE_TYPE_DURING_PERFORMANCE :
+            itp = ASF::Picture::DuringPerformance;
+            break;
+        case IMAGE_TYPE_MOVIESCREENCAPTURE :
+            itp = ASF::Picture::MovieScreenCapture;
+            break;
+        case IMAGE_TYPE_COLOURED_FISH :
+            itp = ASF::Picture::ColouredFish;
+            break;
+        case IMAGE_TYPE_ILLUSTRATION :
+            itp = ASF::Picture::Illustration;
+            break;
+        case IMAGE_TYPE_ARTIST_LOGO :
+            itp = ASF::Picture::BandLogo;
+            break;
+        case IMAGE_TYPE_PUBLISHER_LOGO :
+            itp = ASF::Picture::PublisherLogo;
+            break;
+        default:
+            itp = ASF::Picture::Other;
+            break;
+    }
+}
 
 AsfInfo::AsfInfo(const String &filename) : Info(filename) {
     if(file_name.isEmpty()) {
         if(asf_tag) {
             load_base_tags((TagLib::Tag *)asf_tag);
             
-            if(asf_tag->attributeListMap().contains("WM/PartOfSet") && !asf_tag->attributeListMap()[ "WM/PartOfSet" ].isEmpty()) {
-                StringList list = asf_tag->attributeListMap()[ "WM/PartOfSet" ].front().toString().split("/");
+            if(asf_tag->attributeListMap().contains(VOLUME_NUMBER) && !asf_tag->attributeListMap()[ VOLUME_NUMBER ].isEmpty()) {
+                StringList list = asf_tag->attributeListMap()[ VOLUME_NUMBER ].front().toString().split("/");
                 if(list.size() == 2) {
                     volume_number = atol(list.front().toCString(false));
                     volume_count  = atol(list.back().toCString(false));
                     volume_number = atol(list.front().toCString(false));
                 }
             }
-            if(asf_tag->attributeListMap().contains("WM/Composer")) {
-                composer = asf_tag->attributeListMap()[ "WM/Composer" ].front().toString();
+            if(asf_tag->attributeListMap().contains(COMPOSER)) {
+                composer = asf_tag->attributeListMap()[ COMPOSER ].front().toString();
             }
-            if(asf_tag->attributeListMap().contains("WM/OriginalArtist")) {
-                original_artist = asf_tag->attributeListMap()[ "WM/OriginalArtist" ].front().toString();
+            if(asf_tag->attributeListMap().contains(ORIGINAL_ARTIST)) {
+                original_artist = asf_tag->attributeListMap()[ ORIGINAL_ARTIST ].front().toString();
             }
             if(asf_tag->attributeListMap().contains(TOTAL_TRACKS)) {// seems not to be official
                 track_count = 
                     atol(asf_tag->attributeListMap()[ TOTAL_TRACKS ].front().toString().toCString(false));
             }
-            if(asf_tag->attributeListMap().contains("Copyright")) {
-                copyright = asf_tag->attributeListMap()[ "Copyright" ].front().toString();
+            if(asf_tag->attributeListMap().contains(COPYRIGHT)) {
+                copyright = asf_tag->attributeListMap()[ COPYRIGHT ].front().toString();
             }
-            if(asf_tag->attributeListMap().contains("WM/EncodedBy")) {
-                encoder = asf_tag->attributeListMap()[ "WM/EncodedBy" ].front().toString();
+            if(asf_tag->attributeListMap().contains(ENCODER)) {
+                encoder = asf_tag->attributeListMap()[ ENCODER ].front().toString();
             }
-            if(asf_tag->attributeListMap().contains("URL")) {
-                homepage = asf_tag->attributeListMap()[ "URL" ].front().toString();
+            if(asf_tag->attributeListMap().contains(HOMEPAGE)) {
+                homepage = asf_tag->attributeListMap()[ HOMEPAGE ].front().toString();
             }
             if(asf_tag->attributeListMap().contains(COMPILATION_FLAG)) {
                 is_compilation =
                     asf_tag->attributeListMap()[COMPILATION_FLAG].front().toString() == String("1");
             }
-            if(asf_tag->attributeListMap().contains("WM/AlbumArtist")) {
-                album_artist = asf_tag->attributeListMap()[ "WM/AlbumArtist" ].front().toString();
+            if(asf_tag->attributeListMap().contains(ALBUM_ARTIST)) {
+                album_artist = asf_tag->attributeListMap()[ ALBUM_ARTIST ].front().toString();
             }
             long rat = 0;
-            if(asf_tag->attributeListMap().contains("WM/SharedUserRating")) {
-                rat = atol(asf_tag->attributeListMap()[ "WM/SharedUserRating" ].front().toString().toCString(false));
+            if(asf_tag->attributeListMap().contains(SHARED_RATING)) {
+                rat = atol(asf_tag->attributeListMap()[ SHARED_RATING ].front().toString().toCString(false));
             }
             if(!rat && asf_tag->attributeListMap().contains("Rating")) {
                 rat = atol(asf_tag->attributeListMap()[ "Rating" ].front().toString().toCString(false));
             }
             if(rat) {
-                if(rat > 5) {
+                if(rat > 5)
                     rating = wm_rating_to_rating(rat);
-                }
                 else
-                {
                     rating = rat;
-                }
             }
             if(track_labels.size() == 0) {
-                if(asf_tag->attributeListMap().contains("TRACK_LABELS")) {
-                    track_labels_string = asf_tag->attributeListMap()[ "TRACK_LABELS" ].front().toString();
+                if(asf_tag->attributeListMap().contains(TRACK_LABELS)) {
+                    track_labels_string = asf_tag->attributeListMap()[ TRACK_LABELS ].front().toString();
                     track_labels = split(track_labels_string, "|");
                 }
             }
             if(artist_labels.size() == 0) {
-                if(asf_tag->attributeListMap().contains("ARTIST_LABELS")) {
-                    artist_labels_string = asf_tag->attributeListMap()[ "ARTIST_LABELS" ].front().toString();
+                if(asf_tag->attributeListMap().contains(ARTIST_LABELS)) {
+                    artist_labels_string = asf_tag->attributeListMap()[ ARTIST_LABELS ].front().toString();
                     artist_labels = split(artist_labels_string, "|");
                 }
             }
             if(album_labels.size() == 0) {
-                if(asf_tag->attributeListMap().contains("ALBUM_LABELS")) {
-                    album_labels_string = asf_tag->attributeListMap()[ "ALBUM_LABELS" ].front().toString();
+                if(asf_tag->attributeListMap().contains(ALBUM_LABELS)) {
+                    album_labels_string = asf_tag->attributeListMap()[ ALBUM_LABELS ].front().toString();
                     album_labels = split(album_labels_string, "|");
                 }
             }
     if(asf_tag) {
         if(changedflag) {
             if(changedflag & CHANGED_DATA_VOL_NUM || changedflag & CHANGED_DATA_VOL_CNT) {
-                asf_tag->removeItem("WM/PartOfSet");
+                asf_tag->removeItem(VOLUME_NUMBER);
                 if(volume_count != 0) {
                     if(volume_number != 0)
-                        asf_tag->setAttribute("WM/PartOfSet", format("%u/%u", volume_number, volume_count));
+                        asf_tag->setAttribute(VOLUME_NUMBER, format("%u/%u", volume_number, volume_count));
                     else
-                        asf_tag->setAttribute("WM/PartOfSet", format("%u", volume_number));
+                        asf_tag->setAttribute(VOLUME_NUMBER, format("%u", volume_number));
                 }
             }
-//            if(changedflag & CHANGED_DATA_VOL_NUM) {
-//                asf_tag->removeItem("WM/PartOfSet");
-//                asf_tag->setAttribute("WM/PartOfSet", format("%u", volume_number));
-//            }
-            if(changedflag & CHANGED_TRACK_COUNT) { // seems not officially supported
+            if(changedflag & CHANGED_TRACK_COUNT) {
                 asf_tag->removeItem(TOTAL_TRACKS);
                 asf_tag->setAttribute(TOTAL_TRACKS, format("%d", track_count));
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {
-                asf_tag->removeItem("WM/Composer");
-                asf_tag->setAttribute("WM/Composer", composer);
+                asf_tag->removeItem(COMPOSER);
+                asf_tag->setAttribute(COMPOSER, composer);
             }
             if(changedflag & CHANGED_ORIGINALARTIST_TAG) {
-                asf_tag->removeItem("WM/OriginalArtist");
-                asf_tag->setAttribute("WM/OriginalArtist", original_artist);
+                asf_tag->removeItem(ORIGINAL_ARTIST);
+                asf_tag->setAttribute(ORIGINAL_ARTIST, original_artist);
             }
             if(changedflag & CHANGED_COPYRIGHT_TAG) {
-                asf_tag->removeItem("Copyright");
-                asf_tag->setAttribute("Copyright", copyright);
+                asf_tag->removeItem(COPYRIGHT);
+                asf_tag->setAttribute(COPYRIGHT, copyright);
             }
             if(changedflag & CHANGED_ENCODER_TAG) {
-                asf_tag->removeItem("WM/EncodedBy");
-                asf_tag->setAttribute("WM/EncodedBy", encoder);
+                asf_tag->removeItem(ENCODER);
+                asf_tag->setAttribute(ENCODER, encoder);
             }
             if(changedflag & CHANGED_HOMEPAGE_TAG) {
-                asf_tag->removeItem("URL");
-                asf_tag->setAttribute("URL", homepage);
+                asf_tag->removeItem(HOMEPAGE);
+                asf_tag->setAttribute(HOMEPAGE, homepage);
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
                 asf_tag->removeItem(COMPILATION_FLAG);
                     asf_tag->setAttribute(COMPILATION_FLAG, String("0"));
             }
             if(changedflag & CHANGED_DATA_ALBUMARTIST) {
-                asf_tag->removeItem("WM/AlbumArtist");
-                asf_tag->setAttribute("WM/AlbumArtist", album_artist);
+                asf_tag->removeItem(ALBUM_ARTIST);
+                asf_tag->setAttribute(ALBUM_ARTIST, album_artist);
             }
             if(changedflag & CHANGED_DATA_RATING) {
-                asf_tag->removeItem("WM/SharedUserRating");
+                asf_tag->removeItem(SHARED_RATING);
                 int WMRatings[] = { 0, 0, 1, 25, 50, 75, 99 };
-                asf_tag->setAttribute("WM/SharedUserRating", format("%i", WMRatings[ rating + 1 ]));
+                asf_tag->setAttribute(SHARED_RATING, format("%i", WMRatings[ rating + 1 ]));
             }
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)
-                check_asf_label_frame(asf_tag, "TRACK_LABELS", track_labels_string);
+                check_asf_label_frame(asf_tag, TRACK_LABELS, track_labels_string);
             if(changedflag & CHANGED_ARTIST_LABELS)
-                check_asf_label_frame(asf_tag, "ARTIST_LABELS", artist_labels_string);
+                check_asf_label_frame(asf_tag, ARTIST_LABELS, artist_labels_string);
             if(changedflag & CHANGED_ALBUM_LABELS)
-                check_asf_label_frame(asf_tag, "ALBUM_LABELS", album_labels_string);
+                check_asf_label_frame(asf_tag, ALBUM_LABELS, album_labels_string);
             save_base_tags((TagLib::Tag *)asf_tag);
         }
     }
     if(asf_tag) {
         Image** images;
         if(asf_tag->attributeListMap().contains(PICTURE_FLAG)) {
-            ASF::Attribute attr = asf_tag->attributeListMap()[PICTURE_FLAG].front(); 
-            // TODO more pictures
-            ASF::Picture pict = attr.toPicture();
-            if(!pict.isValid())
+            ASF::AttributeList list = asf_tag->attributeListMap()[ PICTURE_FLAG ];
+            if(0 >= list.size())
                 return NULL;
-            images = new Image*[1];
-            ByteVector pict_data = pict.picture();
-            Image * image = new Image();
-            if(pict_data.size() > 0) {
-                image->data_length = pict_data.size();
-                image->data = new char[image->data_length];
-                memcpy(image->data, pict_data.data(), pict_data.size());
-                
-                String mimetype = pict.mimeType();
-                if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_JPEG;
-                else if(mimetype.find("/png") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_PNG;
-                else if(mimetype.find("/bmp") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_BMP;
-                else if(mimetype.find("/gif") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_GIF;
-                
-                image->image_type = IMAGE_TYPE_COVER_FRONT;
-                
-                if(image->data && image->data_length > 0) {
-                    image_count = 0;
-                    images[0] = image;
+            int i = 0;
+            images = new Image*[list.size()];
+            for(ASF::AttributeList::ConstIterator it = list.begin(); it != list.end(); it++) {
+                //ASF::Attribute attr = (*it);
+                ASF::Picture pict = (*it).toPicture();
+                if(!pict.isValid())
+                    continue;
+                ByteVector pict_data = pict.picture();
+                Image * image = new Image();
+                if(pict_data.size() > 0) {
+                    image->data_length = pict_data.size();
+                    image->data = new char[image->data_length];
+                    memcpy(image->data, pict_data.data(), pict_data.size());
+                    
+                    String mimetype = pict.mimeType();
+                    if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_JPEG;
+                    else if(mimetype.find("/png") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                    else if(mimetype.find("/bmp") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_BMP;
+                    else if(mimetype.find("/gif") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                    
+                    image->image_type = get_image_type_from_pic_type(pict.type()); 
+                                        
+                    if(image->data && image->data_length > 0) {
+                        images[i] = image;
+                        image_count++;
+                        i++;
+                    }
+                    else {
+                        delete image;
+                    }
                 }
             }
+            return images;
         }
-        return images;
     }
     return NULL;
 }
             if(image->image_file_type == IMAGE_FILE_TYPE_JPEG || 
                image->image_file_type == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
                 picture.setMimeType("image/jpeg");
-            if(image->image_file_type == IMAGE_FILE_TYPE_PNG)
+            else if(image->image_file_type == IMAGE_FILE_TYPE_PNG)
                 picture.setMimeType("image/png");
+            else if(image->image_file_type == IMAGE_FILE_TYPE_GIF)
+                picture.setMimeType("image/gif");
+            else if(image->image_file_type == IMAGE_FILE_TYPE_BMP)
+                picture.setMimeType("image/bmp");
             
             ByteVector ImgData = ByteVector((TagLib::uint) image->data_length);
             memcpy(ImgData.data(), image->data, image->data_length);
             
             picture.setPicture(ImgData);
+            picture.setType(image_type_to_picture_type(image->image_type));
             ASF::Attribute attr = ASF::Attribute(picture);
-            asf_tag->setAttribute(PICTURE_FLAG, attr);
+            asf_tag->addAttribute(PICTURE_FLAG, attr);
         }
     }
 }
 
 String AsfInfo::get_lyrics(void) const {
     if(asf_tag) {
-            if(asf_tag->attributeListMap().contains("WM/Lyrics")) {
-            return asf_tag->attributeListMap()[ "WM/Lyrics" ].front().toString();
+            if(asf_tag->attributeListMap().contains(LYRICS)) {
+            return asf_tag->attributeListMap()[ LYRICS ].front().toString();
         }
     }
     return String();
 
 bool AsfInfo::set_lyrics(const String &lyrics) {
     if(asf_tag) {
-        asf_tag->removeItem("WM/Lyrics");
-        asf_tag->setAttribute("WM/Lyrics", lyrics);
+        asf_tag->removeItem(LYRICS);
+        asf_tag->setAttribute(LYRICS, lyrics);
         return true;
     }
     return false;

File libtaginfo/flacinfo.cc

View file
 using namespace TagInfo;
 
 
+
 FlacInfo::FlacInfo(const String &filename) : XiphInfo(filename) {
     if(file_name.isEmpty()) {
         valid = false;
     return false;
 }
 
+ImageType flac_image_type_to_image_type(const FLAC::Picture::Type &tpe) {
+    ImageType itp;
+    switch(tpe) {
+        case FLAC::Picture::FrontCover:
+            itp = IMAGE_TYPE_COVER_FRONT;
+            break;
+        case FLAC::Picture::BackCover:
+            itp = IMAGE_TYPE_COVER_BACK;
+            break;
+        case FLAC::Picture::Other:
+            itp = IMAGE_TYPE_OTHER;
+            break;
+        case FLAC::Picture::FileIcon:
+            itp = IMAGE_TYPE_FILE_ICON;
+            break;
+        case FLAC::Picture::OtherFileIcon:
+            itp = IMAGE_TYPE_OTHER_FILE_ICON;
+            break;
+        case FLAC::Picture::LeafletPage:
+            itp = IMAGE_TYPE_LEAFLET_PAGE;
+            break;
+        case FLAC::Picture::Media:
+            itp = IMAGE_TYPE_MEDIA;
+            break;
+        case FLAC::Picture::LeadArtist:
+            itp = IMAGE_TYPE_LEAD_ARTIST;
+            break;
+        case FLAC::Picture::Artist:
+            itp = IMAGE_TYPE_ARTIST;
+            break;
+        case FLAC::Picture::Conductor:
+            itp = IMAGE_TYPE_CONDUCTOR;
+            break;
+        case FLAC::Picture::Band:
+            itp = IMAGE_TYPE_BAND;
+            break;
+        case FLAC::Picture::Composer:
+            itp = IMAGE_TYPE_COMPOSER;
+            break;
+        case FLAC::Picture::Lyricist:
+            itp = IMAGE_TYPE_LYRICIST;
+            break;
+        case FLAC::Picture::RecordingLocation:
+            itp = IMAGE_TYPE_RECORDING_LOCATION;
+            break;
+        case FLAC::Picture::DuringRecording:
+            itp = IMAGE_TYPE_DURING_RECORDING;
+            break;
+        case FLAC::Picture::DuringPerformance:
+            itp = IMAGE_TYPE_DURING_PERFORMANCE;
+            break;
+        case FLAC::Picture::MovieScreenCapture:
+            itp = IMAGE_TYPE_MOVIESCREENCAPTURE;
+            break;
+        case FLAC::Picture::ColouredFish:
+            itp = IMAGE_TYPE_COLOURED_FISH;
+            break;
+        case FLAC::Picture::Illustration:
+            itp = IMAGE_TYPE_ILLUSTRATION;
+            break;
+        case FLAC::Picture::BandLogo:
+            itp = IMAGE_TYPE_ARTIST_LOGO;
+            break;
+        case FLAC::Picture::PublisherLogo:
+            itp = IMAGE_TYPE_PUBLISHER_LOGO;
+            break;
+        default:
+            itp = IMAGE_TYPE_OTHER;
+            break;
+    }
+    return itp;    
+}
 
 Image ** FlacInfo::get_images(int &image_count) const {
     if(flac_file) {
             Image** images = new Image*[plist.size()];
             for(List<FLAC::Picture *>::Iterator it = plist.begin(); it != plist.end(); ++it) {
                 Image * image = new Image();
-                image->image_type = IMAGE_TYPE_COVER_FRONT;
                 FLAC::Picture * p = (*it);
+                image->image_type = flac_image_type_to_image_type(p->type());
                 image->data_length = p->data().size();
                 image->data = new char[image->data_length];
                 memcpy(image->data, p->data().data(), image->data_length);

File libtaginfo/id3info.cc

View file
 #include <urllinkframe.h>
 
 
+#define LYRICS              "USLT"
+#define IMAGES              "APIC"
+#define VOLUME              "TPOS"
+#define TRACKNUMBER         "TRCK"
+#define COMPOSER            "TCOM"
+#define ORIGINAL_ARTIST     "TOPE"
+#define ALBUM_ARTIST        "TPE2"
+#define COMPILATION         "TCMP"
+#define COPYRIGHT           "TCOP"
+#define ENCODER             "TENC"
+#define HOMEPAGE            "WXXX"
+#define TRACK_LABELS        "TRACK_LABELS"
+#define ALBUM_LABELS        "ALBUM_LABELS"
+#define ARTIST_LABELS       "ARTIST_LABELS"
+
+
+
 using namespace TagInfo;
 
 
 
 
 
-TagLib::ID3v2::AttachedPictureFrame::Type image_type_to_picframetype(ImageType image_type) {
+TagLib::ID3v2::AttachedPictureFrame::Type image_type_to_picframetype(const ImageType& image_type) {
+    TagLib::ID3v2::AttachedPictureFrame::Type itp;
     switch(image_type) {
-        case IMAGE_TYPE_COVER_FRONT:
-            return TagLib::ID3v2::AttachedPictureFrame::FrontCover;
-        case IMAGE_TYPE_COVER_BACK:
-            return TagLib::ID3v2::AttachedPictureFrame::BackCover;
+        case IMAGE_TYPE_COVER_FRONT :
+            return ID3v2::AttachedPictureFrame::FrontCover;
+        case IMAGE_TYPE_COVER_BACK :
+            return ID3v2::AttachedPictureFrame::BackCover;
+        case IMAGE_TYPE_OTHER :
+            return ID3v2::AttachedPictureFrame::Other;
+        case IMAGE_TYPE_FILE_ICON :
+            return ID3v2::AttachedPictureFrame::FileIcon;
+//            
+        case IMAGE_TYPE_OTHER_FILE_ICON :
+            return ID3v2::AttachedPictureFrame::OtherFileIcon;
+//            
+        case IMAGE_TYPE_LEAFLET_PAGE :
+            return ID3v2::AttachedPictureFrame::LeafletPage;
+//            break;
+        case IMAGE_TYPE_MEDIA  :
+            return ID3v2::AttachedPictureFrame::Media;
+//            break;
+        case IMAGE_TYPE_LEAD_ARTIST :
+            return ID3v2::AttachedPictureFrame::LeadArtist;
+//            break;
+        case IMAGE_TYPE_ARTIST :
+            return ID3v2::AttachedPictureFrame::Artist;
+//            break;
+        case IMAGE_TYPE_CONDUCTOR :
+            return ID3v2::AttachedPictureFrame::Conductor;
+//            break;
+        case IMAGE_TYPE_BAND :
+            return ID3v2::AttachedPictureFrame::Band;
+//            break;
+        case IMAGE_TYPE_COMPOSER :
+            return ID3v2::AttachedPictureFrame::Composer;
+//            break;
+        case IMAGE_TYPE_LYRICIST :
+            return ID3v2::AttachedPictureFrame::Lyricist;
+//            break;
+        case IMAGE_TYPE_RECORDING_LOCATION :
+            return ID3v2::AttachedPictureFrame::RecordingLocation;
+//            break;
+        case IMAGE_TYPE_DURING_RECORDING :
+            return ID3v2::AttachedPictureFrame::DuringRecording;
+//            break;
+        case IMAGE_TYPE_DURING_PERFORMANCE :
+            return ID3v2::AttachedPictureFrame::DuringPerformance;
+//            break;
+        case IMAGE_TYPE_MOVIESCREENCAPTURE :
+            return ID3v2::AttachedPictureFrame::MovieScreenCapture;
+//            break;
+        case IMAGE_TYPE_COLOURED_FISH :
+            return ID3v2::AttachedPictureFrame::ColouredFish;
+//            break;
+        case IMAGE_TYPE_ILLUSTRATION :
+            return ID3v2::AttachedPictureFrame::Illustration;
+//            break;
+        case IMAGE_TYPE_ARTIST_LOGO :
+            return ID3v2::AttachedPictureFrame::BandLogo;
+//            break;
+        case IMAGE_TYPE_PUBLISHER_LOGO :
+            return ID3v2::AttachedPictureFrame::PublisherLogo;
+//            break;
         default:
-            return TagLib::ID3v2::AttachedPictureFrame::Other;
-    }
-}
-
-void set_id3v2_image(ID3v2::Tag * tagv2, const char* pdata, int pdata_length, ImageFileType image_file_type) {
-    TagLib::ID3v2::AttachedPictureFrame * PicFrame = NULL;
-    TagLib::ID3v2::FrameList frameList = tagv2->frameListMap()["APIC"];
-    for(list<TagLib::ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
-        PicFrame = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(*iter);
-        if((PicFrame->type() == TagLib::ID3v2::AttachedPictureFrame::FrontCover) ||
-           (PicFrame->type() == TagLib::ID3v2::AttachedPictureFrame::Other))
-            tagv2->removeFrame(PicFrame, true);
-    }
-    
-    if(!pdata || pdata_length == 0)
-        return;
-    
-    PicFrame = new TagLib::ID3v2::AttachedPictureFrame;
-    if(image_file_type == IMAGE_FILE_TYPE_JPEG || image_file_type == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
-        PicFrame->setMimeType("image/jpeg");
-    if(image_file_type == IMAGE_FILE_TYPE_PNG)
-        PicFrame->setMimeType("image/png");
-    PicFrame->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
-    ByteVector ImgData((TagLib::uint) pdata_length);
-    memcpy(ImgData.data(), pdata, pdata_length);
-    PicFrame->setPicture(ImgData);
-    tagv2->addFrame(PicFrame);
-}
-
-
-void set_id3v2_lyrics(ID3v2::Tag * tagv2, const String &lyrics) {
-    TagLib::ID3v2::UnsynchronizedLyricsFrame * LyricsFrame;
-    
-    TagLib::ID3v2::FrameList frameList = tagv2->frameListMap()["USLT"];
-    for(list<TagLib::ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
-            LyricsFrame = static_cast<TagLib::ID3v2::UnsynchronizedLyricsFrame*>(*iter);
-        tagv2->removeFrame(LyricsFrame, true);
-    }
-    if(!lyrics.isEmpty()) {
-        LyricsFrame = new TagLib::ID3v2::UnsynchronizedLyricsFrame(TagLib::String::UTF8);
-        LyricsFrame->setText(lyrics);
-        tagv2->addFrame(LyricsFrame);
+            return ID3v2::AttachedPictureFrame::Other;
+//            break;
+        return itp;
     }
 }
 
 
-
 // ID3
 
 
         if(taglib_tagId3v2 && !taglib_tagId3v2->isEmpty()) {
             if(!taglib_tag)
                 load_base_tags((TagLib::Tag *)taglib_tagId3v2);
-            if(taglib_tagId3v2->frameListMap().contains("TPOS") && !taglib_tagId3v2->frameListMap()["TPOS"].isEmpty()) {
-                StringList list = taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString().split("/");
+            if(taglib_tagId3v2->frameListMap().contains(VOLUME) && !taglib_tagId3v2->frameListMap()[VOLUME].isEmpty()) {
+                StringList list = taglib_tagId3v2->frameListMap()[ VOLUME ].front()->toString().split("/");
                 if(list.size() == 2) {
                     volume_number = atol(list.front().toCString(false));
                     volume_count  = atol(list.back().toCString(false));
                     volume_number = atol(list.front().toCString(false));
                 }
             }
-            if(taglib_tagId3v2->frameListMap().contains("TRCK") && !taglib_tagId3v2->frameListMap()["TRCK"].isEmpty()) {
-                StringList list = taglib_tagId3v2->frameListMap()[ "TRCK" ].front()->toString().split("/");
+            if(taglib_tagId3v2->frameListMap().contains(TRACKNUMBER) && !taglib_tagId3v2->frameListMap()[TRACKNUMBER].isEmpty()) {
+                StringList list = taglib_tagId3v2->frameListMap()[ TRACKNUMBER ].front()->toString().split("/");
                 if(list.size() == 2)
                     track_count = atol(list.back().toCString(false));
             }
-            if(taglib_tagId3v2->frameListMap().contains("TCOM")) {
-                composer = taglib_tagId3v2->frameListMap()[ "TCOM" ].front()->toString();
+            if(taglib_tagId3v2->frameListMap().contains(COMPOSER)) {
+                composer = taglib_tagId3v2->frameListMap()[ COMPOSER ].front()->toString();
             }
-            if(taglib_tagId3v2->frameListMap().contains("TOPE")) {
-                original_artist = taglib_tagId3v2->frameListMap()[ "TOPE" ].front()->toString();
+            if(taglib_tagId3v2->frameListMap().contains(ORIGINAL_ARTIST)) {
+                original_artist = taglib_tagId3v2->frameListMap()[ ORIGINAL_ARTIST ].front()->toString();
             }
-            if(taglib_tagId3v2->frameListMap().contains("TPE2")) {
-                album_artist = taglib_tagId3v2->frameListMap()[ "TPE2" ].front()->toString();
+            if(taglib_tagId3v2->frameListMap().contains(ALBUM_ARTIST)) {
+                album_artist = taglib_tagId3v2->frameListMap()[ ALBUM_ARTIST ].front()->toString();
             }
-            if(taglib_tagId3v2->frameListMap().contains("TCMP")) {
-                is_compilation =(taglib_tagId3v2->frameListMap()["TCMP"].front()->toString()) == String("1");
+            if(taglib_tagId3v2->frameListMap().contains(COMPILATION)) {
+                is_compilation =(taglib_tagId3v2->frameListMap()[COMPILATION].front()->toString()) == String("1");
             }
-            if(taglib_tagId3v2->frameListMap().contains("TCOP")) {
-                copyright = taglib_tagId3v2->frameListMap()[ "TCOP" ].front()->toString();
+            if(taglib_tagId3v2->frameListMap().contains(COPYRIGHT)) {
+                copyright = taglib_tagId3v2->frameListMap()[ COPYRIGHT ].front()->toString();
             }
-            if(taglib_tagId3v2->frameListMap().contains("TENC")) {
-                encoder = taglib_tagId3v2->frameListMap()[ "TENC" ].front()->toString();
+            if(taglib_tagId3v2->frameListMap().contains(ENCODER)) {
+                encoder = taglib_tagId3v2->frameListMap()[ ENCODER ].front()->toString();
             }
-            if(taglib_tagId3v2->frameListMap().contains("WXXX")) {
-                ID3v2::FrameList l = taglib_tagId3v2->frameList("WXXX");
+            if(taglib_tagId3v2->frameListMap().contains(HOMEPAGE)) {
+                ID3v2::FrameList l = taglib_tagId3v2->frameList(HOMEPAGE);
                 TagLib::ID3v2::UserUrlLinkFrame *f = 
                     dynamic_cast<TagLib::ID3v2::UserUrlLinkFrame *>(l.front());
                 homepage = f->url();
                 playcount = popularity_frame->counter();
             }
             if(track_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, TRACK_LABELS);
                 if(!frame)
                     frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACKLABELS");
                 if(frame) {
                 }
             }
             if(artist_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, ARTIST_LABELS);
                 if(!frame)
                     frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTISTLABELS");
                 if(frame) {
                     StringList artist_labels_list = frame->fieldList();
                     if(artist_labels_list.size()) {
                         artist_labels_string = artist_labels_list[1];//.toCString(true);
-std::cout << "artist_labels_string: " << artist_labels_string << std::endl;
+//std::cout << "artist_labels_string: " << artist_labels_string << std::endl;
                         artist_labels = split(artist_labels_string, "|");
                     }
                 }
-                else {
+/*                else {
 std::cout << "NO artit label frame " << std::endl;
                 }
+*/            
             }
             if(album_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, ALBUM_LABELS);
                 if(!frame)
                     frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUMLABELS");
                 if(frame) {
                 }
             }
             // Image availability
-            TagLib::ID3v2::FrameList frame_list = taglib_tagId3v2->frameListMap()["APIC"];
+            TagLib::ID3v2::FrameList frame_list = taglib_tagId3v2->frameListMap()[IMAGES];
             has_image =(frame_list.size() > 0); //something is there
         }
     }
         if(changedflag) {
             TagLib::ID3v2::TextIdentificationFrame * frame;
             if(changedflag & CHANGED_DATA_VOL_NUM || changedflag & CHANGED_DATA_VOL_CNT) {
-                taglib_tagId3v2->removeFrames("TPOS");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
+                taglib_tagId3v2->removeFrames(VOLUME);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(VOLUME);
                 frame->setText(format("%u/%u", volume_number, volume_count));
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {
-                taglib_tagId3v2->removeFrames("TCOM");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TCOM");
+                taglib_tagId3v2->removeFrames(COMPOSER);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(COMPOSER);
                 frame->setText(composer);
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_TRACK_NUMBER) {
-                taglib_tagId3v2->removeFrames("TRCK");
+                taglib_tagId3v2->removeFrames(TRACKNUMBER);
                 if(!(changedflag & CHANGED_TRACK_COUNT)) {
                     // prevent overwrite in save_base_tags()
                     changedflag &= ~(CHANGED_TRACK_NUMBER);
                     // prevent overwrite in save_base_tags()
                     changedflag &= ~(CHANGED_TRACK_NUMBER);
                     changedflag &= ~(CHANGED_TRACK_COUNT);
-                    frame = new TagLib::ID3v2::TextIdentificationFrame("TRCK");
+                    frame = new TagLib::ID3v2::TextIdentificationFrame(TRACKNUMBER);
                     frame->setText(format("%d/%d", track_number, track_count));
                     taglib_tagId3v2->addFrame(frame);
                 }
                 // prevent overwrite in save_base_tags()
                 changedflag &= ~(CHANGED_TRACK_NUMBER);
                 changedflag &= ~(CHANGED_TRACK_COUNT);
-                taglib_tagId3v2->removeFrames("TRCK");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TRCK");
+                taglib_tagId3v2->removeFrames(TRACKNUMBER);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(TRACKNUMBER);
                 frame->setText(format("%d/%d", track_number, track_count));
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_ORIGINALARTIST_TAG) {
-                taglib_tagId3v2->removeFrames("TOPE");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TOPE");
+                taglib_tagId3v2->removeFrames(ORIGINAL_ARTIST);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(ORIGINAL_ARTIST);
                 frame->setText(original_artist);
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_DATA_ALBUMARTIST) {
-                taglib_tagId3v2->removeFrames("TPE2");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TPE2");
+                taglib_tagId3v2->removeFrames(ALBUM_ARTIST);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(ALBUM_ARTIST);
                 frame->setText(album_artist);
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
-                taglib_tagId3v2->removeFrames("TCMP");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TCMP");
+                taglib_tagId3v2->removeFrames(COMPILATION);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(COMPILATION);
                 if(is_compilation)
                     frame->setText("1");
                 else
             }
             
             if(changedflag & CHANGED_COPYRIGHT_TAG) {
-                taglib_tagId3v2->removeFrames("TCOP");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TCOP");
+                taglib_tagId3v2->removeFrames(COPYRIGHT);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(COPYRIGHT);
                 frame->setText(copyright);
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_ENCODER_TAG) {
-                taglib_tagId3v2->removeFrames("TENC");
-                frame = new TagLib::ID3v2::TextIdentificationFrame("TENC");
+                taglib_tagId3v2->removeFrames(ENCODER);
+                frame = new TagLib::ID3v2::TextIdentificationFrame(ENCODER);
                 frame->setText(encoder);
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_HOMEPAGE_TAG) {
-                taglib_tagId3v2->removeFrames("WXXX");
+                taglib_tagId3v2->removeFrames(HOMEPAGE);
                 ID3v2::UserUrlLinkFrame *f = new ID3v2::UserUrlLinkFrame();
                 f->setUrl(homepage);
                 taglib_tagId3v2->addFrame(f);
             
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)
-                id3v2_check_label_frame(taglib_tagId3v2, "TRACK_LABELS", track_labels_string);
+                id3v2_check_label_frame(taglib_tagId3v2, TRACK_LABELS, track_labels_string);
             if(changedflag & CHANGED_ARTIST_LABELS)
-                id3v2_check_label_frame(taglib_tagId3v2, "ARTIST_LABELS", artist_labels_string);
+                id3v2_check_label_frame(taglib_tagId3v2, ARTIST_LABELS, artist_labels_string);
             if(changedflag & CHANGED_ALBUM_LABELS)
-                id3v2_check_label_frame(taglib_tagId3v2, "ALBUM_LABELS", album_labels_string);
+                id3v2_check_label_frame(taglib_tagId3v2, ALBUM_LABELS, album_labels_string);
             
             save_base_tags((TagLib::Tag *)taglib_tagId3v2);
         }
     return Info::save();
 }
 
-ImageType get_image_type_from_pic_frame_type(ID3v2::AttachedPictureFrame::Type tpe) {
+ImageType get_image_type_from_pic_frame_type(const ID3v2::AttachedPictureFrame::Type &tpe) {
     ImageType itp;
     switch(tpe) {
         case TagLib::ID3v2::AttachedPictureFrame::FrontCover:
-            itp = IMAGE_TYPE_COVER_FRONT;
-            break;
+            return IMAGE_TYPE_COVER_FRONT;
+            
         case TagLib::ID3v2::AttachedPictureFrame::BackCover:
-            itp = IMAGE_TYPE_COVER_BACK;
-            break;
+            return IMAGE_TYPE_COVER_BACK;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Other:
-            itp = IMAGE_TYPE_OTHER;
-            break;
+            return IMAGE_TYPE_OTHER;
+            
         case TagLib::ID3v2::AttachedPictureFrame::FileIcon:
-            itp = IMAGE_TYPE_FILE_ICON;
-            break;
+            return IMAGE_TYPE_FILE_ICON;
+            
         case TagLib::ID3v2::AttachedPictureFrame::OtherFileIcon:
-            itp = IMAGE_TYPE_OTHER_FILE_ICON;
-            break;
+            return IMAGE_TYPE_OTHER_FILE_ICON;
+            
         case TagLib::ID3v2::AttachedPictureFrame::LeafletPage:
-            itp = IMAGE_TYPE_LEAFLET_PAGE;
-            break;
+            return IMAGE_TYPE_LEAFLET_PAGE;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Media:
-            itp = IMAGE_TYPE_MEDIA;
-            break;
+            return IMAGE_TYPE_MEDIA;
+            
         case TagLib::ID3v2::AttachedPictureFrame::LeadArtist:
-            itp = IMAGE_TYPE_LEAD_ARTIST;
-            break;
+            return IMAGE_TYPE_LEAD_ARTIST;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Artist:
-            itp = IMAGE_TYPE_ARTIST;
-            break;
+            return IMAGE_TYPE_ARTIST;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Conductor:
-            itp = IMAGE_TYPE_CONDUCTOR;
-            break;
+            return IMAGE_TYPE_CONDUCTOR;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Band:
-            itp = IMAGE_TYPE_BAND;
-            break;
+            return IMAGE_TYPE_BAND;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Composer:
-            itp = IMAGE_TYPE_COMPOSER;
-            break;
+            return IMAGE_TYPE_COMPOSER;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Lyricist:
-            itp = IMAGE_TYPE_LYRICIST;
-            break;
+            return IMAGE_TYPE_LYRICIST;
+            
         case TagLib::ID3v2::AttachedPictureFrame::RecordingLocation:
-            itp = IMAGE_TYPE_RECORDING_LOCATION;
-            break;
+            return IMAGE_TYPE_RECORDING_LOCATION;
+            
         case TagLib::ID3v2::AttachedPictureFrame::DuringRecording:
-            itp = IMAGE_TYPE_DURING_RECORDING;
-            break;
+            return IMAGE_TYPE_DURING_RECORDING;
+            
         case TagLib::ID3v2::AttachedPictureFrame::DuringPerformance:
-            itp = IMAGE_TYPE_DURING_PERFORMANCE;
-            break;
+            return IMAGE_TYPE_DURING_PERFORMANCE;
+            
         case TagLib::ID3v2::AttachedPictureFrame::MovieScreenCapture:
-            itp = IMAGE_TYPE_MOVIESCREENCAPTURE;
-            break;
+            return IMAGE_TYPE_MOVIESCREENCAPTURE;
+            
         case TagLib::ID3v2::AttachedPictureFrame::ColouredFish:
-            itp = IMAGE_TYPE_COLOURED_FISH;
-            break;
+            return IMAGE_TYPE_COLOURED_FISH;
+            
         case TagLib::ID3v2::AttachedPictureFrame::Illustration:
-            itp = IMAGE_TYPE_ILLUSTRATION;
-            break;
+            return IMAGE_TYPE_ILLUSTRATION;
+            
         case TagLib::ID3v2::AttachedPictureFrame::BandLogo:
-            itp = IMAGE_TYPE_ARTIST_LOGO;
-            break;
+            return IMAGE_TYPE_ARTIST_LOGO;
+            
         case TagLib::ID3v2::AttachedPictureFrame::PublisherLogo:
-            itp = IMAGE_TYPE_PUBLISHER_LOGO;
-            break;
+            return IMAGE_TYPE_PUBLISHER_LOGO;
+            
         default:
-            itp = IMAGE_TYPE_OTHER;
-            break;
+            return IMAGE_TYPE_OTHER;
+            
     }
     return itp;
 }
 Image ** Id3Info::get_images(int &image_count) const {
     if(taglib_tagId3v2) {
         Image** images;
-        TagLib::ID3v2::FrameList framelist = taglib_tagId3v2->frameListMap()["APIC"];
+        TagLib::ID3v2::FrameList framelist = taglib_tagId3v2->frameListMap()[IMAGES];
         TagLib::ID3v2::AttachedPictureFrame * pic_frame = NULL;
         int cnt = framelist.size();
         images = new Image*[cnt];
         for(list<TagLib::ID3v2::Frame*>::iterator iter = framelist.begin(); iter != framelist.end(); iter++) {
             pic_frame = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(*iter);
             Image * image = new Image();
+//            cout << "image_type_to_picframetype(get_image_type_from_pic_frame_type(pic_frame->type()))" << image_type_to_picframetype(get_image_type_from_pic_frame_type(pic_frame->type())) << endl;
             image->image_type = get_image_type_from_pic_frame_type(pic_frame->type());
             if(image) {
                 if(pic_frame->picture().size() > 0) {
                         image->image_file_type = IMAGE_FILE_TYPE_JPEG;
                     else if(mimetype.find("/png") != -1)
                         image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                    else if(mimetype.find("/gif") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                    else if(mimetype.find("/bmp") != -1)
+                        image->image_file_type = IMAGE_FILE_TYPE_BMP;
                     image->description = ::strdup(pic_frame->description().toCString(true));
                 }
                 if(image->data && image->data_length > 0) {
 void Id3Info::set_images(const Image ** images, const int image_count) {
     if(taglib_tagId3v2) {
         TagLib::ID3v2::AttachedPictureFrame * PicFrame = NULL;
-        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()["APIC"];
+        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()[IMAGES];
         for(int p = 0; p < image_count; p++) {
             if(!images[p] || !images[p]->data || images[p]->data_length == 0)
                 continue;
             if(images[p]->image_file_type == IMAGE_FILE_TYPE_JPEG || 
                images[p]->image_file_type == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
                 PicFrame->setMimeType("image/jpeg");
-            if(images[p]->image_file_type == IMAGE_FILE_TYPE_PNG)
+            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_PNG)
                 PicFrame->setMimeType("image/png");
+            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_GIF)
+                PicFrame->setMimeType("image/gif");
+            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_BMP)
+                PicFrame->setMimeType("image/bmp");
             PicFrame->setType(image_type_to_picframetype(images[p]->image_type));
+            if(images[p]->description) {
+                const char* ds = ::strdup(images[p]->description);
+                String desc = String(ds);
+                PicFrame->setDescription(desc);
+            }
             ByteVector ImgData((TagLib::uint) images[p]->data_length);
             memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
             PicFrame->setPicture(ImgData);
 
 String Id3Info::get_lyrics(void) const {
     if(taglib_tagId3v2) {
-        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameList("USLT");
+        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameList(LYRICS);
         if(!frameList.isEmpty()) {
             TagLib::ID3v2::UnsynchronizedLyricsFrame * lyrics_frame = 
                 static_cast<TagLib::ID3v2::UnsynchronizedLyricsFrame * >(frameList.front());
 bool Id3Info::set_lyrics(const String &lyrics) {
     if(taglib_tagId3v2) {
         TagLib::ID3v2::UnsynchronizedLyricsFrame * lyrics_frame;
-        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()["USLT"];
+        TagLib::ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()[LYRICS];
         for(list<TagLib::ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
             lyrics_frame = static_cast<TagLib::ID3v2::UnsynchronizedLyricsFrame*>(*iter);
             taglib_tagId3v2->removeFrame(lyrics_frame, true);

File libtaginfo/image.cc

View file
 }
 
 Image::~Image() {
-    if(data)
+//    if(data)
         delete [] data;
-    if(description)
+//    if(description)
         delete [] description;
 }
 

File libtaginfo/taginfo_id3tags.h

View file
     */        
     class AiffInfo : public Id3Info {
         public :
-            //! Constructor for AiffInfo
+            //! Constructor for AiffInfo 
             //! \param filename is the path to the media file
             AiffInfo(const String &filename = "");
             virtual ~AiffInfo();

File libtaginfo/taginfo_image.h

View file
     /*!
     * Enumerated classification of image content
     */
-    enum ImageType {
+    enum ImageType { 
         //! An image type not listed here
-        IMAGE_TYPE_OTHER,
+        IMAGE_TYPE_OTHER, 
         //! 32x32 PNG image that should be used as the file icon
         IMAGE_TYPE_FILE_ICON,
         //! File icon of a different size or format

File libtaginfo/xiphinfo.cc

View file
 
 
 
-using namespace TagInfo;
 
+using namespace TagInfo;
 
 
+#define LYRICS                  "LYRICS"
+#define COVERARTMIME            "COVERARTMIME"
+#define COVERART                "COVERART"
+#define COVERARTDESCRIPTION     "COVERARTDESCRIPTION"
+#define COVERARTTYPE            "COVERARTTYPE"
+#define DISCNUMBER              "DISCNUMBER"
+#define DISCTOTAL               "DISCTOTAL"
+#define COMPOSER                "COMPOSER"
+#define PERFORMER               "PERFORMER"
+#define TRACKTOTAL              "TRACKTOTAL"
+#define COMPILATION             "COMPILATION"
+#define ALBUMARTIST             "ALBUMARTIST"
+#define RATING                  "RATING"
+#define PLAY_COUNTER            "PLAY_COUNTER"
+#define TRACK_LABELS            "TRACK_LABELS"
+#define ALBUM_LABELS            "ALBUM_LABELS"
+#define ARTIST_LABELS           "ARTIST_LABELS"
+#define COPYRIGHT               "COPYRIGHT"
+#define ENCODED_BY              "ENCODED-BY"  
+#define LICENSE                 "LICENSE"
 
 
 static const string base64_char_string = 
             if(!taglib_tag)
                 load_base_tags((TagLib::Tag *)xiphcomment);
             
-            if(xiphcomment->fieldListMap().contains("COMPOSER")) {
-                composer = xiphcomment->fieldListMap()["COMPOSER"].front();
+            if(xiphcomment->fieldListMap().contains(COMPOSER)) {
+                composer = xiphcomment->fieldListMap()[COMPOSER].front();
             }
-            if(xiphcomment->fieldListMap().contains("PERFORMER")) {
-                original_artist = xiphcomment->fieldListMap()["PERFORMER"].front();
+            if(xiphcomment->fieldListMap().contains(PERFORMER)) {
+                original_artist = xiphcomment->fieldListMap()[PERFORMER].front();
             }
-            if(xiphcomment->fieldListMap().contains("DISCNUMBER")) {
-                volume_number = atol(xiphcomment->fieldListMap()["DISCNUMBER"].front().toCString(false));
+            if(xiphcomment->fieldListMap().contains(DISCNUMBER)) {
+                volume_number = atol(xiphcomment->fieldListMap()[DISCNUMBER].front().toCString(false));
             }
-            if(xiphcomment->fieldListMap().contains("DISCTOTAL")) {
-                volume_count = atol(xiphcomment->fieldListMap()["DISCTOTAL"].front().toCString(false));
+            if(xiphcomment->fieldListMap().contains(DISCTOTAL)) {
+                volume_count = atol(xiphcomment->fieldListMap()[DISCTOTAL].front().toCString(false));
             }
-            if(xiphcomment->fieldListMap().contains("TRACKTOTAL")) {
-                track_count = atol(xiphcomment->fieldListMap()["TRACKTOTAL"].front().toCString(false));
+            if(xiphcomment->fieldListMap().contains(TRACKTOTAL)) {
+                track_count = atol(xiphcomment->fieldListMap()[TRACKTOTAL].front().toCString(false));
             }
-            if(xiphcomment->fieldListMap().contains("COMPILATION")) {
-                is_compilation = xiphcomment->fieldListMap()["COMPILATION"].front() == String("1");
+            if(xiphcomment->fieldListMap().contains(COMPILATION)) {
+                is_compilation = xiphcomment->fieldListMap()[COMPILATION].front() == String("1");
             }
-            if(xiphcomment->fieldListMap().contains("ALBUMARTIST")) {
-                album_artist = xiphcomment->fieldListMap()["ALBUMARTIST"].front();
+            if(xiphcomment->fieldListMap().contains(ALBUMARTIST)) {
+                album_artist = xiphcomment->fieldListMap()[ALBUMARTIST].front();
             }
             else if(xiphcomment->fieldListMap().contains("ALBUM ARTIST")) {
                 album_artist = xiphcomment->fieldListMap()["ALBUM ARTIST"].front();
             }
-            if(xiphcomment->fieldListMap().contains("COPYRIGHT")) {
-                copyright = xiphcomment->fieldListMap()["COPYRIGHT"].front();
+            if(xiphcomment->fieldListMap().contains(COPYRIGHT)) {
+                copyright = xiphcomment->fieldListMap()[COPYRIGHT].front();
             }
-            if(xiphcomment->fieldListMap().contains("ENCODED-BY")) {
-                encoder = xiphcomment->fieldListMap()["ENCODED-BY"].front();
+            if(xiphcomment->fieldListMap().contains(ENCODED_BY)) {
+                encoder = xiphcomment->fieldListMap()[ENCODED_BY].front();
             }
-            if(xiphcomment->fieldListMap().contains("LICENSE")) {
-                homepage = xiphcomment->fieldListMap()["LICENSE"].front();
+            if(xiphcomment->fieldListMap().contains(LICENSE)) {
+                homepage = xiphcomment->fieldListMap()[LICENSE].front();
             }
             // Rating
-            if(xiphcomment->fieldListMap().contains("RATING")) {
+            if(xiphcomment->fieldListMap().contains(RATING)) {
                 long rat = 0;
-                rat = atol(xiphcomment->fieldListMap()["RATING"].front().toCString(true));
+                rat = atol(xiphcomment->fieldListMap()[RATING].front().toCString(true));
                 if(rat) {
                     if(rat > 5) {
                         rating = popularity_to_rating(rat);
                     }
                 }
             }
-            if(xiphcomment->fieldListMap().contains("PLAY_COUNTER")) {
+            if(xiphcomment->fieldListMap().contains(PLAY_COUNTER)) {
                 long PlayCount = 0;
-                PlayCount = atol(xiphcomment->fieldListMap()["PLAY_COUNTER"].front().toCString(true));
+                PlayCount = atol(xiphcomment->fieldListMap()[PLAY_COUNTER].front().toCString(true));
                 playcount = PlayCount;
             }
             // Labels
             if(track_labels.size() == 0) {
-                if(xiphcomment->fieldListMap().contains("TRACK_LABELS")) {
-                    track_labels_string = xiphcomment->fieldListMap()["TRACK_LABELS"].front();
+                if(xiphcomment->fieldListMap().contains(TRACK_LABELS)) {
+                    track_labels_string = xiphcomment->fieldListMap()[TRACK_LABELS].front();
                     track_labels = split(track_labels_string, "|");
                 }
             }
             if(artist_labels.size() == 0) {
-                if(xiphcomment->fieldListMap().contains("ARTIST_LABELS")) {
-                    artist_labels_string = xiphcomment->fieldListMap()["ARTIST_LABELS"].front();
+                if(xiphcomment->fieldListMap().contains(ARTIST_LABELS)) {
+                    artist_labels_string = xiphcomment->fieldListMap()[ARTIST_LABELS].front();
                     artist_labels = split(artist_labels_string, "|");
                 }
             }
             if(album_labels.size() == 0) {
-                if(xiphcomment->fieldListMap().contains("ALBUM_LABELS")) {
-                    album_labels_string = xiphcomment->fieldListMap()["ALBUM_LABELS"].front();
+                if(xiphcomment->fieldListMap().contains(ALBUM_LABELS)) {
+                    album_labels_string = xiphcomment->fieldListMap()[ALBUM_LABELS].front();
                     album_labels = split(album_labels_string, "|");
                 }
             }
-            if(xiphcomment->contains("COVERART"))
+            if(xiphcomment->contains(COVERART))
                 has_image = true;
             return true;
         }
     if(xiphcomment) {
         if(changedflag) {
             if(changedflag & CHANGED_DATA_VOL_NUM)
-                xiphcomment->addField("DISCNUMBER", format("%u", volume_number), true);
+                xiphcomment->addField(DISCNUMBER, format("%u", volume_number), true);
             if(changedflag & CHANGED_DATA_VOL_CNT)
-                xiphcomment->addField("DISCTOTAL", format("%u", volume_count), true);
+                xiphcomment->addField(DISCTOTAL, format("%u", volume_count), true);
             if(changedflag & CHANGED_COMPOSER_TAG)
-                xiphcomment->addField("COMPOSER", composer, true);
+                xiphcomment->addField(COMPOSER, composer, true);
             if(changedflag & CHANGED_ORIGINALARTIST_TAG)
-                xiphcomment->addField("PERFORMER", original_artist, true);
+                xiphcomment->addField(PERFORMER, original_artist, true);
             if(changedflag & CHANGED_TRACK_COUNT)
-                xiphcomment->addField("TRACKTOTAL", format("%d", track_count), true);
+                xiphcomment->addField(TRACKTOTAL, format("%d", track_count), true);
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
                 if(is_compilation) {
-                    xiphcomment->addField("COMPILATION", "1", true);
+                    xiphcomment->addField(COMPILATION, "1", true);
                 }
                 else {
-                    xiphcomment->addField("COMPILATION", "0", true);
+                    xiphcomment->addField(COMPILATION, "0", true);
                 }
             }
             if(changedflag & CHANGED_DATA_ALBUMARTIST)
-                xiphcomment->addField("ALBUMARTIST", album_artist, true);
+                xiphcomment->addField(ALBUMARTIST, album_artist, true);
             if(changedflag & CHANGED_DATA_RATING)
-                xiphcomment->addField("RATING", format("%u", rating_to_popularity(rating)), true);
+                xiphcomment->addField(RATING, format("%u", rating_to_popularity(rating)), true);
             if(changedflag & CHANGED_DATA_PLAYCOUNT)
-                xiphcomment->addField("PLAY_COUNTER", format("%u", playcount), true);
+                xiphcomment->addField(PLAY_COUNTER, format("%u", playcount), true);
             
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)
-                check_xiph_label_frame(xiphcomment, "TRACK_LABELS", track_labels_string);
+                check_xiph_label_frame(xiphcomment, TRACK_LABELS, track_labels_string);
             if(changedflag & CHANGED_ARTIST_LABELS)
-                check_xiph_label_frame(xiphcomment, "ARTIST_LABELS", artist_labels_string);
+                check_xiph_label_frame(xiphcomment, ARTIST_LABELS, artist_labels_string);
             if(changedflag & CHANGED_ALBUM_LABELS)
-                check_xiph_label_frame(xiphcomment, "ALBUM_LABELS", album_labels_string);
+                check_xiph_label_frame(xiphcomment, ALBUM_LABELS, album_labels_string);
             
             if(changedflag & CHANGED_COPYRIGHT_TAG)
-                xiphcomment->addField("COPYRIGHT", copyright, true);
+                xiphcomment->addField(COPYRIGHT, copyright, true);
             if(changedflag & CHANGED_ENCODER_TAG)
-                xiphcomment->addField("ENCODED-BY", encoder, true);
+                xiphcomment->addField(ENCODED_BY, encoder, true);
             if(changedflag & CHANGED_HOMEPAGE_TAG)
-                xiphcomment->addField("LICENSE", homepage, true);
+                xiphcomment->addField(LICENSE, homepage, true);
             
             save_base_tags((TagLib::Tag *)xiphcomment);
         }
 
 Image ** XiphInfo::get_images(int &image_count) const {
     image_count = 0;
-    if(xiphcomment && xiphcomment->contains("COVERART")) {
-        Image** images = new Image*[1];
-        
-        Image * image = new Image();
-        image->image_type = IMAGE_TYPE_COVER_FRONT;
-        String mimetype = xiphcomment->fieldListMap()[ "COVERARTMIME" ].front().to8Bit(false);
-        if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
-            image->image_file_type = IMAGE_FILE_TYPE_JPEG;
-        else if(mimetype.find("/png") != -1)
-            image->image_file_type = IMAGE_FILE_TYPE_PNG;
-        
-        const char* CoverEncData = xiphcomment->fieldListMap()[ "COVERART" ].front().toCString(true); 
-        
-        string CoverDecData = base64_decode(CoverEncData);
+    if(xiphcomment && xiphcomment->contains(COVERART)) {
         
-        image->data_length = CoverDecData.size();
-        image->data = new char[image->data_length];
-        memcpy(image->data, CoverDecData.data(), CoverDecData.size());
+        StringList pics      = xiphcomment->fieldListMap()[ COVERART ];
+        StringList pic_mimes = xiphcomment->fieldListMap()[ COVERARTMIME ];
+        StringList pic_types = xiphcomment->fieldListMap()[ COVERARTTYPE ];
+        StringList pic_descr = xiphcomment->fieldListMap()[ COVERARTDESCRIPTION ];
         
-        if(image->data && image->data_length > 0) {
-            images[0] = image;
-            image_count = 1;
-            return images;
+        int cnt       = pics.size();
+        int mimes_cnt = pic_mimes.size();
+        int types_cnt = pic_types.size();
+        int descr_cnt = pic_descr.size();
+        Image** images = new Image*[cnt];
+        for(int i = 0; i < cnt; i++) {
+            Image * image = new Image();
+//            image->image_type = IMAGE_TYPE_COVER_FRONT;
+            String mimetype;
+            String description;
+            String itype;
+            if(i < mimes_cnt) {
+                mimetype = pic_mimes[i];//.to8Bit(false); 
+                if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
+                    image->image_file_type = IMAGE_FILE_TYPE_JPEG;
+                else if(mimetype.find("/png") != -1)
+                    image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                else if(mimetype.find("/gif") != -1)
+                    image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                else if(mimetype.find("/bmp") != -1)
+                    image->image_file_type = IMAGE_FILE_TYPE_BMP;
+            }
+            if(i < types_cnt) {
+                itype = pic_types[i];
+                image->image_type = (ImageType) atol(itype.toCString(false));
+            }
+            if(i < descr_cnt) {
+                description = pic_descr[i];
+                image->description = ::strdup(description.toCString(true));
+            }
+
+            const char* CoverEncData = pics[i].toCString(false);
+            
+            string CoverDecData = base64_decode(CoverEncData);
+            
+            image->data_length = CoverDecData.size();
+            image->data = new char[image->data_length];
+            memcpy(image->data, CoverDecData.data(), CoverDecData.size());
+            
+            if(image->data && image->data_length > 0) {
+                images[i] = image;
+                image_count++;
+            }
+            else
+                delete image;
         }
+        return images;
     }
     return NULL;
 }
 
 void XiphInfo::set_images(const Image ** images, const int image_count) {
     if(xiphcomment) {
-        if(xiphcomment->contains("COVERART")) {
-            xiphcomment->removeField("COVERARTMIME");
-            xiphcomment->removeField("COVERART");
-        }
-        for(int p = 0; p < image_count; p++) {
+        xiphcomment->removeField(COVERARTMIME);
+        xiphcomment->removeField(COVERART);
+        xiphcomment->removeField(COVERARTTYPE);
+        xiphcomment->removeField(COVERARTDESCRIPTION);
+         for(int p = 0; p < image_count; p++) {
             const Image * image = images[p];
             if(image && image->data && image->data_length > 0) {
-                if(image->image_file_type == IMAGE_FILE_TYPE_UNKNOWN || image->image_file_type == IMAGE_FILE_TYPE_JPEG)
-                    xiphcomment->addField("COVERARTMIME", "image/jpeg");
+                if(image->image_file_type == IMAGE_FILE_TYPE_UNKNOWN || 
+                   image->image_file_type == IMAGE_FILE_TYPE_JPEG)
+                    xiphcomment->addField(COVERARTMIME, "image/jpeg", false);
                 else if(image->image_file_type == IMAGE_FILE_TYPE_PNG)
-                    xiphcomment->addField("COVERARTMIME", "image/png");
+                    xiphcomment->addField(COVERARTMIME, "image/png", false);
+                else if(image->image_file_type == IMAGE_FILE_TYPE_GIF)
+                    xiphcomment->addField(COVERARTMIME, "image/gif", false);
+                else if(image->image_file_type == IMAGE_FILE_TYPE_BMP)
+                    xiphcomment->addField(COVERARTMIME, "image/bmp", false);
+                
+                xiphcomment->addField(COVERART, 
+                                      base64encode(image->data, image->data_length).toCString(false),
+                                      false);
+                xiphcomment->addField(COVERARTTYPE, format("%d", (int)image->image_type), false);
                 
-                xiphcomment->addField("COVERART", 
-                                      base64encode(image->data, image->data_length).toCString(false));
+                if(image->description) {
+                    const char* ds = ::strdup(image->description);
+                    String desc = String(ds);
+                    xiphcomment->addField(COVERARTDESCRIPTION, desc, false);
+                }
             }
         }
     }
 
 
 String XiphInfo::get_lyrics(void) const {
-    if(xiphcomment && xiphcomment->contains("LYRICS")) {
-        return xiphcomment->fieldListMap()[ "LYRICS" ].front();
+    if(xiphcomment && xiphcomment->contains(LYRICS)) {
+        return xiphcomment->fieldListMap()[ LYRICS ].front();
     }
     return String();
 }
 
 bool XiphInfo::set_lyrics(const String &lyrics) {
     if(xiphcomment) {
-        while(xiphcomment->contains("LYRICS")) {
-            xiphcomment->removeField("LYRICS");
-        }
+        xiphcomment->removeField(LYRICS);
         if(!lyrics.isEmpty()) {
-            xiphcomment->addField("LYRICS", lyrics);
+            xiphcomment->addField(LYRICS, lyrics, true);
         }
         return true;
     }

File tests/write_image_mp3/main.cc

View file
     
     Image * img = new Image();
     img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_OTHER;
+    img->image_type      = IMAGE_TYPE_COVER_FRONT;
+    img->description     = ::strdup(String("Bescräibunk", String::UTF8).toCString(false));
     
+    Image * img2 = new Image();
+    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
+    img2->image_type      = IMAGE_TYPE_COVER_BACK;
+    img2->description     = ::strdup(String("Beßcräibunk", String::UTF8).toCString(false));
+
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
     img->data_length = filestatus.st_size;
+    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         EXIT_FAILURE;
     }
     
-    img->data = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED) {
+    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
         close(fd);
         perror("Error mmapping the file");
         EXIT_FAILURE;
     
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[1];
+        Image ** imgs = new Image*[2];
         imgs[0] = img;
-        info->set_images((const Image **)imgs, 1);
+        imgs[1] = img2;
+        info->set_images((const Image **)imgs, 2);
         if(imgs)
             delete [] imgs;
         info->save();
     
     info = Info::create(target);
     Image * read_image;
+    Image * read_image2;
     if(info) {
         if(info->load()) {
             int len = 0;
                 }
                 return EXIT_FAILURE;
             }
-            read_image = images[0];
-            if(!images[0] || !read_image) {
+            read_image  = images[0];
+            read_image2 = images[1];
+            if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     if(images)
                     return EXIT_FAILURE;
                 }
             }
+            if(img->image_type != read_image->image_type) {
+                if(images)
+                    delete [] images;
+                if(read_image)
+                    delete read_image;
+                return EXIT_FAILURE;
+            }
+            String st = String(read_image->description, String::UTF8);
+            if(strcmp(img->description, st.toCString(false)) != 0) {
+                if(images)
+                    delete [] images;
+                if(read_image)
+                    delete read_image;
+                return EXIT_FAILURE;
+            }
+            st = String(read_image2->description, String::UTF8);
+            if(strcmp(img2->description, st.toCString(false)) != 0) {
+                if(images)
+                    delete [] images;
+                if(read_image)
+                    delete read_image;
+                return EXIT_FAILURE;
+            }
+            if(img2->image_type != read_image2->image_type) {
+                if(images)
+                    delete [] images;
+                if(read_image)
+                    delete read_image;
+                return EXIT_FAILURE;
+            }