        (if (= resp :error)
          (log lb-log (str "failed to retrieve avatar image for '" username "'\n"))
          (let [image (<! (av/read-image (first resp) c))
-               ext (second resp)
-               stamped-image (av/stamped image (:stamp-type @state) ext)]
+               ext (second resp)]
            (log lb-log (str "successfully read image, detected extension is '" ext "'\n"))
-           (log lb-log (str "type is '" (.getType stamped-image) "'\n"))
            (config! (select form [:#orig-ava]) :icon image)
-           (config! (select form [:#stamped-ava]) :icon stamped-image)
+           (update-state :image-orig image :image-ext ext)
+           (update-stamped-image form)
            ))
        ))))
+
+(defn update-stamped-image [form]
+  "Gets an image from state, [re]stamps it according to state config,
+saves newly stamped to state updates widgets"
+  (when-let [image-orig (:image-orig @state)]
+    (update-state :image-stamped
+                  (av/stamped image-orig (:stamp-type @state) (:image-ext @state)))
+    (config! (select form [:#stamped-ava]) :icon (:image-stamped @state))))
 
 (defn build-avatars-tab []
   (let [bg-stamp-pos (button-group)

                                               :columns 80
                                               ))
                       "span,growx"]]
              :constraints ["fill", "[][grow][]", ""])]

    ;; set up username edit to wait for user input become idle
    (let [te-name (select form [:#username])
          lb-log (select form [:#log])
          active-chan (chan 1)
          keys-chan (chan 1)
          stop-listening (fn []
                           ;; (log lb-log "Stopping listening\n")
                           (go
                            (if (<! active-chan)
                              (do
                                ;; important to put it back to channel immediately so others could read
                                (>! active-chan false)
                                (prepare-avatars (text te-name) lb-log form)
                              ))))

          start-listening (fn []
                            ;;(log lb-log "Starting listening\n")
                            (go
                             (>! active-chan true)
                             (loop []
                               (let [[v ch] (alts! [keys-chan (timeout 800)])]
                                 (if (not (blank? v))
                                   (recur)
                                   (do
                              ;;       (log lb-log "timeout reached\n")
                                     (stop-listening))
                                   ))
                               )))]
      ;; It is important in this scheme to return value to the channel as soon as it had been read:
      ;; so that others interested can read back
      (listen te-name
              :focus-gained (fn [e]
                              (put! active-chan false))

              :document (fn [e]
                          (go
                           (if (<! active-chan)
                             (do
                               ;; important to put it back to channel immediately so others could read
                               (>! active-chan true)
                               (>! keys-chan "1")
                               )
                             (do
                               ;(log lb-log "in not-active mode, initiating listening\n")
                               (start-listening))
                             ))
                          )
              :focus-lost (fn [e]
                            ;(log lb-log "focus lost, stopping\n")
                            (stop-listening)
                            )
              )
      form)))

(defn build-posts-tab []
  (label "Posts"))

                              :halign :center)
                       "span 1 3,w 105px::, h 105px::,wrap,top"]
                      [(label "Положение штампа:")]
                      [(flow-panel :items [(radio :id :top
                                                  :text "Сверху"
                                                  :group bg-stamp-pos
                                                  :selected? (not= :bottom (:stamp-type @state)))
                                           (radio :id :bottom
                                                  :text "Снизу"
                                                  :group bg-stamp-pos
                                                  :selected? (= :bottom (:stamp-type @state))
                                                  )]) "wrap"]
                      [(button :text "Проштамповать") "wrap,skip 1"]
                      [(label "") "grow,push,span 2"] ;; empty filler
                      [(label :id :stamped-ava
