Here, after @TarasBanakh, there is another example of a quotient map $\ q: X\rightarrow X/\~ $ such that $X$ is compact but there is no compact subset $Y\subseteq X$ such that $f(Y)=f(X)$. Let $Q\subset\mathbb R$ be the set of all rational numbers. Let $\ J:=[0;1]:=\{x\in\mathbb R: 0\le x\le 1\},\ $ Define $$ X\ :=\ \{(x\ y)\in J^2\,:\, |\{x\ y\}\cap Q| = 1\} $$ And let $\ p:X\rightarrow J\ $ be the projection $\ p(x\ y)\ := x.\ $ Then $p$ is onto, and for every $A\subseteq J$ we have: 1. $p^{-1}(A)$ is open in $X$ when $A$ is open in $J$ because $p$ is induced by the Cartesian projection; 2. $p^{-1}(A)$ is not open in $X$ when $A$ is not open in $J$ because $p^{-1}(x)$ is dense in $\ \{x\}\times J\ $ for every $\ x\in J.\ $ Thus, $\ p\ $ is topologically equivalent to the respective quotient map. > More than this, $p$ is an open map. Indeed, sets > $$ B_{abcd}\ :=\ ((a;b)\times(c;d))\,\cap\, X$$ > form a topological base of $X$, and $\ p(B_{abcd}) = (a;b)\cap J.\ $ Thus $p$ is an open map. Finally, let $\ Y\subseteq X\ $ be compact (a proof by contradiction). Then $Y$ is a countable union of finite sets: $$ Y\,\ =\,\ \bigcup_{a\in Q}\ (\{a\}\times\mathbb R)\cap J\,\ \cup \,\ \bigcup_{b\in Q}\ (\mathbb R\times\{b\})\cap J $$ Thus $Y$ would be countable while $J$ is not, a contradiction.