def tagimage(self, imageurl, pageid, latcoord, longcoord, hood, username): imageurl = util.convertimageurl(imageurl) query = db.GqlQuery("SELECT * FROM ImageModel where imageurl = :1", imageurl) image = query.get() if image is None: image = ImageModel(usernameupdated=username, imageurl=imageurl, pageid=int(pageid), latcoord=latcoord, longcoord=longcoord, neighborhood=hood) else: image.usernameupdated = username image.imageurl = imageurl image.pageid = int(pageid) image.latcoord = latcoord image.longcoord = longcoord image.neighborhood = hood try: image.put() user = util.getuser(username) if (user is not None): user.count = user.count + 1 else: user = UserModel(username=username, count=1) user.put() return True except Exception, err: logging.error(str(err)) return False
def get(self): # TODO uncomment to reimport return dir_in = 'img_in/' listing = os.listdir(dir_in) for infile in listing: img = ImageModel() img.data = db.Blob(open(dir_in + "/" + infile).read()) img.put() self.response.out.write("Opened: " + dir_in + "/" + infile + "\n<p>")
def start_app(self): labels = [LabelModel() for _ in range(100)] self.image = Factory.MainImage(ImageModel()) self.root.ids.image_box.add_widget(self.image) self.exif = Factory.GetExifData(ButtonModel(image=self.image, labels=labels)) self.root.ids.button_box.add_widget(self.exif) right = Factory.RotateRight(self.exif.model) self.root.ids.button_box.add_widget(right) left = Factory.RotateLeft(self.exif.model) self.root.ids.button_box.add_widget(left) loc = Factory.GetLocation(self.exif.model) self.root.ids.button_box.add_widget(loc) next = Factory.NextImage(self.exif.model) self.root.ids.cycle_box.add_widget(next) prev = Factory.PreviousImage(self.exif.model) self.root.ids.cycle_box.add_widget(prev) get = Factory.OpenImage(self.exif.model) self.root.ids.button_box.add_widget(get) lab = Factory.ExifLabel(LabelModel()) self.root.ids.exif_container.add_widget(lab) list_adapter = SimpleListAdapter( data=labels, args_converter=lambda row, model: {'model': model, 'size_hint_y': None, 'height':100}, cls=Factory.ExifTags) self.root.ids.exif_container.add_widget(ListView(adapter=list_adapter))
def post(self): """ Handles a request to create a new image object Gets the image data from img in the HTTP header/context """ #Create a new object #Fill it with data form the img data from the context #store the object site_image = ImageModel() image_data = self.request.get("img") if (image_data.__len__() > 0): site_image.data = image_data site_image.put() #Re-direct to the page form which the page was created self.redirect('/')
def saveimagedictionary(self): logging.info("Starting saving") newimagecount = updatedimagecount = 0 imagestosave = [] for imagename in self.imagedictionary.keys(): dbimage = util.getimage(imagename) wikiimage = self.imagedictionary[imagename] if (dbimage is not None): dbimage.pageid = int(wikiimage[0]) dbimage.neighborhood = wikiimage[1] imagetosave = dbimage updatedimagecount = updatedimagecount + 1 else: imagetosave = ImageModel(pageid=int(wikiimage[0]), imageurl=imagename, neighborhood=wikiimage[1], usernameupdated='WikiUser') savedimagecount = savedimagecount + 1 imagestosave.append(imagetosave) try: db.put(imagestosave) except Exception, err: logging.error(str(err))
def get(self): #master_image = db.get(self.request.get("img_id")) master_image = open("img.jpg").read() # Create block for all items in DB blocks = [ ImageBlock(img.data) for img in ImageModel.all() ] mosaic = Mosaic(master_image, blocks) image_out = mosaic.get_image() self.response.headers['Content-Type'] = "image/png" self.response.out.write(image_out)
def dialog_edit_image_property(self): propwin = ImagePropWin.get_instance() if not self.model: self.model = ImageModel() propwin.set_model(self.model) if not propwin.is_visible(): propwin.show() # Move window near the main window app parent = self.get_parent_window().get_effective_parent() _dont_care_, parent_x, parent_y = parent.get_origin() parent_w = parent.get_width() parent_h = parent.get_height() propwin.move(parent_x + parent_w, parent_y)
def get(self): """ Called for HTTP get on /(when ever page / is requested). Presents a list of subscriptions for this week. The data presented is essentially read only of not logged in or read/write if logged in. All HTML rendering is handled by the viernes_util module. Two strings are formatted: the body and the title, these are passed to viernes_util.page which produced the complete page html. """ #create a new page and set the title html_page = util.html_page() html_page.set_title("Photo montage") form_inputs = list() form_inputs.append(html_page.form_input('img',"file",'Add Image')) html_page.append_top( html_page.form("Add Image",'/image/add',form_inputs)) html_page.append_top( html_page.form_get("Create Mosaic",'/mosaic/create')) html_page.append_content(html_page.img('/images/selected_img', 'main image', 'selected image')) html_page.append_content(html_page.img('/images/mosaic_img', 'mosaic image', 'mosaic image')) siteimgs_query = ImageModel.all() imgs_html_string = "" for siteimg in siteimgs_query : imgs_html_string += siteimg.to_html(html_page, "image/set_as_default") html_page.append_footer(html_page.div(imgs_html_string, 'site_images')) #Render it html_page.page(self)
def _block_new(self, block_type=PARAGRAPH): #print("_block_new:") if block_type == SubdocView.PARAGRAPH: buf = EditorTextBuffer() widget = EditorTextView(self.elements_toolbar, self.notebook_app) widget.set_buffer(buf) self.add(widget) elif block_type == SubdocView.IMAGE: #print("Image insertion asked") widget = ImageView() self.add(widget) model = ImageModel() widget.set_model(model) else: raise NotImplementedError widget.connect("focus-in-event", self.on_child_focus_in) widget.connect("cursor-move", self.on_child_cursor_move) #self.add(widget) return widget
def getimage(imagename): # get image from datastore here return ImageModel.gql("WHERE imageurl=:1",imagename).get()
def getimage(imagename): # get image from datastore here return ImageModel.gql("WHERE imageurl=:1", imagename).get()