Bug 112723 - jpeg meta info comment lost on editing in krita
Summary: jpeg meta info comment lost on editing in krita
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Bart Coppens
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-16 14:10 UTC by Thomas Zander
Modified: 2005-09-16 15:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Zander 2005-09-16 14:10:29 UTC
Version:           1.4.88 (using KDE 3.4.91 (beta1, >= 20050910), compiled sources)
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-13)
OS:                Linux (i686) release 2.6.11.1

I opened a jpeg image that has a comment field (as editable in konqueror) and after rotating and saving the image the comment field was empty.
All other fields (stuff my camera put in there) were still present.
Comment 1 Halla Rempt 2005-09-16 14:17:42 UTC
Okay... I'm not even sure that ImageMagick loads those fields, but if it does, it should be doable to keep that. I'll assign this bug to Bart because he did such a sterling job with the other annotations.
Comment 2 Bart Coppens 2005-09-16 15:42:10 UTC
SVN commit 461107 by coppens:

Also import and export imagemagick's so-called "attributes". This includes saving of user comments to file. Should work on all imagemagick versions, but it wouldn't surprise me if there were some weird version that depends on those ImageAttributeIterator calls that are in the online docs but not in my install. If you find such a version, file a bug report for it.

BUG: 112723

 M  +35 -4     kis_image_magick_converter.cc  


--- trunk/koffice/filters/krita/magick/kis_image_magick_converter.cc #461106:461107
@@ -161,6 +161,7 @@
         const StringInfo *profile;
         KisAnnotation* annotation = 0;
 
+        // Profiles and so
         ResetImageProfileIterator(src);
         while((name = GetNextImageProfile(src))) {
             profile = GetImageProfile(src, name);
@@ -180,6 +181,26 @@
 
             image -> addAnnotation(annotation);
         }
+        
+        // Attributes, since we have no hint on if this is an attribute or a profile
+        // annotation, we prefix it with 'krita_attribute:'. XXX This needs to be rethought!
+        // And there are apparantly attribute iterator functions like above, but not
+        // in my magick version *sigh*
+        ImageAttribute * attr = src -> attributes;
+        while (attr) {
+            QByteArray rawdata;
+            int len = strlen(attr -> value) + 1;
+            rawdata.resize(len);
+            memcpy(rawdata.data(), attr -> value, len);
+
+            annotation = new KisAnnotation(
+                    QString("krita_attribute:%1").arg(QString(attr -> key)), "", rawdata);
+            Q_CHECK_PTR(annotation);
+
+            image -> addAnnotation(annotation);
+            attr = attr -> next;
+        }
+
 #endif
     }
 
@@ -194,11 +215,21 @@
                 ++it;
                 continue;
             }
+
             kdDebug() << "Trying to store annotation of type " << (*it) -> type() << " of size " << (*it) -> annotation() . size() << endl;
-            if (!ProfileImage(dst, (*it) -> type().ascii(),
-                (unsigned char*)(*it) -> annotation() . data(),
-                (*it) -> annotation() . size(), MagickFalse)) {
-                    kdDebug() << "Storing failed!" << endl;
+
+            if ((*it) -> type().startsWith("krita_attribute:")) { // Attribute
+                if (!SetImageAttribute(dst,
+                    (*it) -> type().mid(strlen("krita_attribute:")).ascii(),
+                    (*it) -> annotation() . data()) ) {
+                        kdDebug() << "Storing of attribute " << (*it) -> type() << "failed!\n";
+                }
+            } else { // Profile
+                if (!ProfileImage(dst, (*it) -> type().ascii(),
+                    (unsigned char*)(*it) -> annotation() . data(),
+                    (*it) -> annotation() . size(), MagickFalse)) {
+                        kdDebug() << "Storing failed!" << endl;
+                }
             }
             ++it;
         }