As long as you set the width of the image manually (or know it), you can use this:
Edit: added a command to set up caption so it ocupies the rest of the line.
Edit 2: added onside
to \captionsetup
in \captionimagewidth
;
added a new command \capimagewidth
, which corrects width and indent, so for wide images the label ("Figure 1.1") doesn't move into the left margin.
\documentclass{book}
\usepackage[showframe]{geometry} % just for checking centering
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{%
singlelinecheck=false,
}
\DeclareCaptionLabelFormat{myfigure}{\llap{#1 #2:\ }}
\captionsetup{labelformat=myfigure}
% Edit
\newlength{\capindent}
\newlength{\capwidth}
\newcommand{\captionimagewidth}[1]{%
\capindent\dimexpr0.5\textwidth-#1/2\relax
\capwidth\dimexpr\textwidth-\capindent
\captionsetup{width=\capwidth,margin={\capindent,0pt},oneside}%
}
% Edit 2: added `oneside` to \captionsetup
% correction for wide images
\newcommand{\capimagewidth}[1]{%
\capindent\dimexpr0.5\textwidth-#1/2\relax
% from your answer
\addtocounter{figure}{1}%
\settowidth{\capwidth}{%
\figurename~\thefigure:\space%
}%
\addtocounter{figure}{-1}%
%
\ifdim\capindent<\capwidth
\capindent\capwidth
\fi
\capwidth\dimexpr\textwidth-\capindent
\captionsetup{width=\capwidth,margin={\capindent,0pt},oneside}%
}
\begin{document}
\chapter{test}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.3\textwidth]{example-image}
\captionsetup{width=0.3\textwidth}
\caption{Text}
\end{figure}
\setcounter{figure}{1000}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{example-image}
% old
%\captionsetup{width=0.5\textwidth}
% Edit
\captionimagewidth{0.5\textwidth}
\caption{A very long caption text, which needs more than one line. Just some more text to fill it.}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.9\textwidth]{example-image}
\capimagewidth{0.9\textwidth}
\caption{A very long caption text, which needs more than one line. Just some more text to fill it. Amd make it even longer.}
\end{figure}
\end{document}
Result after edit:
But for wide images, the label moves into the margin:
With new command from second edit:
Old result: