This note is under construction. @Victor has pointed out to my error in the pre-edited version--thank you, Victor. I feel that I Have a chance to prove that the space $X$ below is correct. If I can't achieve it within a couple days then I will remove this my "answer"
Here, after @TarasBanakh, there is another example of a quotient map $\ q: X\rightarrow X/{\sim} $ 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:
- $p^{-1}(A)$ is open in $X$ when $A$ is open in $J$ because $p$ is induced by the Cartesian projection;
- $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.
Well, about this whole "answer", we will see.