diff options
author | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-11-06 19:32:49 (GMT) |
---|---|---|
committer | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-11-06 19:32:49 (GMT) |
commit | d1bee2c30e32b7d05beb709dbd0fbf7383cd7cd7 (patch) | |
tree | 1fb2e88c3efdc7e1dba8ac4091b3ce6d75070de9 /serialize.py | |
parent | 75606c87e12d7830fcf2e1b4d67459a239f7a446 (diff) |
thumbnails from xml, not from datastore
git-svn-id: http://mediamods.com/public-svn/camera-activity/Record.activity@887 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
Diffstat (limited to 'serialize.py')
-rw-r--r-- | serialize.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/serialize.py b/serialize.py index 78c767b..2df2d3e 100644 --- a/serialize.py +++ b/serialize.py @@ -147,7 +147,7 @@ def fillRecdFromNode( recd, el ): if (el.getAttributeNode(Constants.recdThumbBytes) != None): recd.thumbBytes = el.getAttribute(Constants.recdThumbBytes) - bt = el.getAttributeNode(Constants.recdBuddyThumb) + bt = el.getAttributeNode(Constants.recdBase64Thumb) if (bt != None): try: thumbPath = os.path.join(Instance.tmpPath, "datastoreThumb.jpg") @@ -157,7 +157,7 @@ def fillRecdFromNode( recd, el ): recd.thumbFilename = os.path.basename(thumbPath) record.Record.log.debug("saved thumbFilename") except: - record.Record.log.error("unable to getRecdBuddyThumb") + record.Record.log.error("unable to getRecdBase64Thumb") ai = el.getAttributeNode(Constants.recdAudioImage) if (not ai == None): @@ -184,10 +184,6 @@ def getRecdXmlMeshString( recd ): root = recdXml.documentElement _addRecdXmlAttrs( root, recd, True ) - pixbuf = recd.getThumbPixbuf( ) - thumb = str( utils.getStringFromPixbuf(pixbuf) ) - root.setAttribute(Constants.recdBuddyThumb, thumb ) - writer = cStringIO.StringIO() recdXml.writexml(writer) return writer.getvalue() @@ -217,6 +213,10 @@ def _addRecdXmlAttrs( el, recd, forMeshTransmit ): el.setAttribute(Constants.recdThumbBytes, str(recd.thumbBytes)) el.setAttribute(Constants.recdRecordVersion, str(Constants.VERSION)) + pixbuf = recd.getThumbPixbuf( ) + thumb64 = str( utils.getStringFromPixbuf(pixbuf) ) + el.setAttribute(Constants.recdBase64Thumb, thumb64) + def saveMediaHash( mediaHashs ): impl = getDOMImplementation() @@ -251,9 +251,6 @@ def saveMediaHash( mediaHashs ): def _saveMedia( el, recd ): if ( (recd.buddy == True) and (recd.datastoreId == None) and (not recd.downloadedFromBuddy) ): - pixbuf = recd.getThumbPixbuf( ) - buddyThumb = str( utils.getStringFromPixbuf(pixbuf) ) - el.setAttribute(Constants.recdBuddyThumb, buddyThumb ) recd.savedMedia = True _saveXml( el, recd ) else: @@ -294,10 +291,20 @@ def _saveMediaToDatastore( el, recd ): mediaObject = datastore.create() mediaObject.metadata['title'] = recd.title - pixbuf = recd.getThumbPixbuf() - record.Record.log.debug("serialize: pixbuf->" + str(pixbuf)) - thumbData = utils.getStringFromPixbuf(pixbuf) - mediaObject.metadata['preview'] = thumbData + datastorePreviewPixbuf = recd.getThumbPixbuf() + if (recd.type == Constants.TYPE_AUDIO): + datastorePreviewPixbuf = recd.getAudioImagePixbuf() + elif (recd.type == Constant.TYPE_PHOTO): + datastorePreviewFilepath = recd.getMediaFilepath() + datastorePreviewPixbuf = gtk.gdk.pixbuf_new_from_file(datastorePreviewFilepath) + + datastorePreviewWidth = 300 + datastorePreviewHeight = 225 + if (datastorePreviewPixbuf.get_width() != datastorePreviewWidth): + datastorePreviewPixbuf = datastorePreviewPixbuf.scale_simple(datastorePreviewWidth, datastorePreviewHeight, gtk.gdk.INTERP_NEAREST) + + datastorePreviewBase64 = utils.getStringFromPixbuf(datastorePreviewPixbuf) + mediaObject.metadata['preview'] = datastorePreviewBase64 colors = str(recd.colorStroke.hex) + "," + str(recd.colorFill.hex) mediaObject.metadata['icon-color'] = colors |