RE: store tag-icon also in some other image format



Hi List,

Actually I would appreciate this too, since I'm trying to load the stored tag icons from the f-spot with in python.
Till now, I could not desirialize the pixbuf objects from the db. Can anybody explain which steps are necessary to deseriliaze the
pixbuf from the db?

I tried to:
1. load the icon into a stringimport gtk
2. Decode with a B64 decoder
3. Load into pixbuf

(look my python code)
### snip ###
from ctypes.util import find_library                                                                                                                 
from ctypes import *
from base64 import *

class GdkPixdata(Structure):
    _fields_ = [
        ("magic",c_uint32),
        ("length",c_int32),
        ("pixdata_type",c_uint32),
        ("rowstride", c_uint32),
        ("width", c_uint32),
        ("height", c_uint32),
        ("pixel_data", c_char_p),
    ]  

class GError(Structure):
    _fields_ = [
        ("domain", c_uint32),
        ("code", c_int),
        ("message", c_char_p),
    ]  

pixlib = CDLL(find_library('gdk_pixbuf-2.0'))pixbuf = None
pixlib.gdk_pixdata_deserialize.argtypes = [POINTER(GdkPixdata), c_uint, POINTER(c_char), POINTER(GError)]

### snip ###
        sql = 'SELECT id, name, icon, category_id FROM tags where category_id = %d' % int(category)
        res = self.__execute_sql(sql)
       
        for row in res:
            try:
                pixdata = GdkPixdata()
                length = c_uint(len(tag.icon))
               
                #2. Decode with a B64 decoder
                pixlib.gdk_pixdata_deserialize(byref(pixdata), length,  b64decode(row[2]), None)
               
                data = "">                w = pixdata.width
                h = pixdata.height
                rs = pixdata.rowstride
               
                #3. Load into pixbuf
                pixbuf = gtk.gdk.pixbuf_new_from_data(data, gtk.gdk.COLORSPACE_RGB, False, 8, w, h, rs)
           
            except Exception, e:
                pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 48, 48) #create empty pixbuf

### snip ###



I see another problem with storing the data in gtk pixbuf format. You guys store gtk related data into a database. If another application (which is not
developed in gtk) wants to access those data, it has to use gtk even if it does not use gtk as the application development kit.

BTW, why the tag icons have different sizes? This looks sometimes really strange...

Regards

Babis



----- Ursprüngliche Mail ----
Von: Andreas Unterkircher <unki netshadow at>
An: f-spot-list gnome org
Gesendet: Sonntag, den 8. Juni 2008, 10:57:13 Uhr
Betreff: store tag-icon also in some other image format

Hello Guys,

In reference to my former post [1] about the tag-icon format used in
F-Spot, I want to ask if it would be possible that F-Spot stores the
tag-icon in the database in some other format too - PNG for example.

Some users asked me, why phpfspot can not show the same icons for tags
like they have selected in F-Spot. There the icon is stored as
Gdk.Pixbuf in the sqlite3 database, but there is no direct way for PHP
(gd, imagemagick, imlib, ...) to handle that thing and convert it to
some browser-compatible formats (png, gif, jpeg,...).

For now phpfspot randomly choose one of the photos and displays it next
to the tag but as I want to phpfspot act like a online version of F-Spot
(at least for the viewing parts), it would be create if it can display
the same icon as the user has chosen in F-Spot.

What do you think? I knew, that this would blew up the database a bit -
but on the other hand - compared to a uncompressed pixbuf a PNG could be
quiet small :-)

Cheers,
Andreas

[1] http://mail.gnome.org/archives/f-spot-list/2008-January/msg00049.html
_______________________________________________
F-spot-list mailing list
F-spot-list gnome org
http://mail.gnome.org/mailman/listinfo/f-spot-list


Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]