def ico_pos_new(id, pos=None): if pos == ico_pos.get(id): return f = ico.get(id) if not f: return pic = picopen(fs_get_jpg(PIC_FULL_SIZE, f)) if not pic: return pic_id = pic_new(CID_ICO96, id) if pos: pos_tuple = pos.split("_") if len(pos_tuple) == 3: x, y, size = map(int, pos_tuple) if size: pic = pic_square(pic, size, top_left=(x, y), size=size) pic = pic_square(pic, 96, size=96) fs_set_jpg("96", pic_id, pic) ico_pos.set(id, pos or "") ico96.set(id, pic_id) from model.feed_po import mc_feed_user_dict mc_feed_user_dict.delete(id)
def ico_pos_new(id, pos=None): if pos == ico_pos.get(id): return f = ico.get(id) if not f: return pic = picopen(fs_get_jpg(PIC_FULL_SIZE, f)) if not pic: return pic_id = pic_new(CID_ICO96, id) if pos: pos_tuple = pos.split('_') if len(pos_tuple) == 3: x, y, size = map(int, pos_tuple) if size: pic = pic_square(pic, size, top_left=(x, y), size=size) pic = pic_square(pic, 96, size=96) fs_set_jpg('96', pic_id, pic) ico_pos.set(id, pos or '') ico96.set(id, pic_id) from model.feed_po import mc_feed_user_dict mc_feed_user_dict.delete(id)
def product_pic_new(com_id, product_id, pic): pic_id = pic_new(CID_PRODUCT_PIC, com_id) pic_save(pic_id, pic) p1 = pic_fit_width_cut_height_if_large(pic, 548) fs_set_jpg('548', pic_id, p1) p2 = pic_fit_width_cut_height_if_large(pic, 215) fs_set_jpg('215', pic_id, p2) return pic_id
def po_pic_new(user_id, po_id, pic, seq=None): pic_id = pic_new(CID_PO_PIC, user_id) pic_save(pic_id, pic) try: po_pic_save(pic_id, pic) except: traceback.print_exc() return if seq is None: seq = seq_gen(user_id, po_id) pp = PoPic(id=pic_id, user_id=user_id, po_id=po_id, seq=seq) pp.save() mc_flush(user_id, po_id) return pp
def photo_new(user_id, photo): photo_id = pic_new(CID_PHOTO, user_id) pic_save(photo_id, photo) po_photo_save(photo_id, photo) return photo_id
def com_pic_new(com_id, pic): pic_id = pic_new(CID_COM_PIC, com_id) pic_save(pic_id, pic) p1 = pic_fit_width_cut_height_if_large(pic, 357) fs_set_jpg('357', pic_id, p1) return pic_id