def browse_chooser_cb(self, filename, ctx): #self.dialog.show() if filename == None: return # checking if we have to scale the picture down # also checking if it even is a picture try: pixbuf = gtk.gdk.pixbuf_new_from_file(filename) except gobject.GError: self.notify("Error: Invalid image file", True) return larger_dimension = max((pixbuf.get_width(), pixbuf.get_height())) if os.path.getsize(filename) <= TP_FACE_SIZE and \ larger_dimension <= MAX_FACE_DIMENSION: # use the picture directly without recompression self.remove_temp() self.set_picture(filename) else: # need to recompress the picture pixbuf = scale_image(pixbuf, MAX_FACE_DIMENSION) if not self.compress_jpeg(pixbuf): self.notify("Error: Unable to compress JPEG picture", True)
def scale_user_face(self, user, factor): # returns saved face picture if user is in dictionary, # else creates a new picture, and saves and returns it return scale_image(get_user_profile_picture( user, status_icons=False, center=False), MAX_FACE_DIMENSION / factor)
def got_photo(self, pixbuf): if pixbuf: pixbuf = scale_image(pixbuf, MAX_FACE_DIMENSION) if not self.compress_jpeg(pixbuf): self.notify("Error: Unable to compress JPEG picture", True) self.camera_dialog = None