Possible characterization of compact metric spaces via real-valued uniformly continuous functions? 1) If $X$ is a metric space such that the image of every uniformly continuous function $f: X \to \mathbb R$ is bounded, then is it necessarily true that $X$ is compact ? 
2) If $X$ is a metric space such that the image of every uniformly continuous function $f: X \to \mathbb R$ is compact, then is it necessarily true that $X$ is compact ? 
If either of (1) or (2) is not true, what happens if we also assume $X$ is complete ?
(Note that (1), hence (2), is true if we require all real valued "continuous" image to be bounded ...  )
 A: I'm not sure if you're familiar with this, but for (1) you can take $X$ to be the closed unit ball of any Banach space. Because $X$ is bounded, any uniformly continuous $f:X\to\mathbb{R}$ is bounded. However, $X$ is not compact. Note that $X$ is complete.
Proof that any uniformly continuous function $f$ from a bounded convex linear set $V$ to a metric space $W$ must be bounded: Since $V$ is bounded, there exists $v\in V$ and $r>0$ such that $V=B_r^V(v)$. Since $f$ is uniformly continuous, for $\varepsilon=1$ we find $\delta>0$ such that $d(x,y)\leq\delta\implies d(f(x),f(y))\leq\varepsilon=1$. Then for any $x\in V$ we can move from $v$ to $x$ in steps of size $\leq\delta$. This can be done in $\lceil d(v,x)/\delta\rceil\leq r/\delta+1$ steps. By the triangle inequality, we get $d(f(v),f(x))\leq r/\delta+1$.
Statement (2) is true, actually. Let $X$ be a metric space such that the image of every uniformly continuous function $f:X\to\mathbb{R}$ is compact. In particular, the image of every uniformly continuous function $f:X\to\mathbb{R}$ is closed, which is all we really need. The goal is to show that $X$ is compact, which means that every sequence has a convergent subsequence. So let $\{x_n\}$ be a sequence in $X$.
Consider the function $$f(x):=\sup\left\{1-\frac1n-d(x,x_n):n\in\mathbb{N}\right\}.$$ We want to show $f$ is uniformly continuous. Let $\varepsilon>0$ and choose $\delta=\varepsilon>0$. Let $x,y\in X$ with $d(x,y)<\delta$. Assume without loss of generality that $f(y)\geq f(x)$, so $d(f(x),f(y))=f(y)-f(x)$. Then $f(x)\geq1-\frac1n-d(x,x_n)$ for all $n\in\mathbb{N}$. We get $$1-\frac1n-d(y,x_n)\leq1-\frac1n-d(x,x_n)+d(x,y)\leq f(x)+\delta$$ for all $n\in\mathbb{N}$, so $f(y)\leq f(x)+\delta$, so $d(f(x),f(y))\leq\delta=\varepsilon$.
By hypothesis, because $f$ is uniformly continuous, the image $f(X)$ is closed. Since $f(x_n)=1-\frac1n\to1$ as $n\to\infty$ we find $1\in\overline{f(X)}$. Because $f(X)$ is closed, there exists $x\in X$ such that $f(x)=1$. We can use this to find a subsequence of $\{x_n\}$ converging to $x$ as follows.
Take $x_{n_1}=x_1$. Then if $x_{n_k}$ is defined, by definition of the supremum there exists $n\in\mathbb{N}$ such that $1-\frac1n-d(x,x_n)>1-\frac1{n_k}$. We define $x_{n_{k+1}}=x_n$. This way, $\{n_k\}$ is increasing, and $1-\frac1{n_k}-d(x,x_{n_k})\to1$, so $d(x,x_{n_k})\to0$, so $x_{n_k}\to x$. Therefore, $X$ is compact.
