Continuing my previous question: Is there a way to use \scalebox in a way that the logo scales to a specific height?
I want to put a logo I created in Tikz into a rectangle that I also created in Tikz. Both should be used as a chapter header. I used the \savebox command to save the logo beforehand. But now I want the logo to have the same height as the rectangle and both should have the same origin. Is it possible to use an expression like height of the rectangle / \ht\logo as the scaling factor somehow? This would be helpful should the logo ever change.
Here is the code; the line that I think needs to be changed is marked.
\documentclass[a4paper,11pt,fleqn]{book}
\usepackage{xcolor}
\usepackage{color}
\definecolor{mydarkgray}{RGB}{0,100,100}
\newcommand{\mytemplatecolor}{mydarkgray}
\usepackage{tikz}
\newsavebox{\logo}
\savebox{\logo}{%
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\path[draw=black,fill=black,line join=miter,line cap=round,miter
limit=4.00,nonzero rule,dash phase=3.000pt,line width=0.000pt]
(178.4915,651.0411) .. controls (178.0358,651.0411) and (177.5801,651.0411)..
(177.1244,651.0411) .. controls (177.1244,652.6787) and (177.1244,654.3163) ..
(177.1244,655.9539) .. controls (177.5801,655.9539) and (178.0358,655.9539) ..
(178.4915,655.9539) .. controls (178.4915,654.3163) and (178.4915,652.6787) ..
(178.4915,651.0411) -- cycle;
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-182.0794,658.5070) rectangle
(-177.1244,660.6401);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-280.8165,679.2454) rectangle (-193.6939,684.6964);
\path[xscale=-1.000,yscale=1.000,fill=black,nonzero rule,rounded
corners=0.0000cm] (-280.8165,694.2955) rectangle (-177.1245,696.3244);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-280.8165,716.4833) rectangle
(-177.1245,721.9073);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-185.6345,669.1724) rectangle (-177.1244,673.9126);
\end{tikzpicture}}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}[display]
{\Huge\bfseries\sffamily\color{\mytemplatecolor}}
{\gdef\chapterlabel{\thechapter\ }}
{0pt} % separation between label and chapter-title
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-8cm,xshift=0cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[name path=mainbox,fill=\mytemplatecolor,\mytemplatecolor] (0,0) rectangle(35.5mm,15mm);% mainbox
\path (0,0) ++(0.379\wd\logo,+0.3755\ht\logo) node {\scalebox{0.76} {\usebox{\logo}}};% this works if i would finetune the settings. But i want the Logo to always appear with the exakt height of the mainbox and flush with the page boarder. No tiny overlap anywere as this looks bad when zooming inside the PDF
\node[anchor=north east,yshift=-7.2cm,xshift=34mm,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{15mm}{\raggedleft $\phantom{\textrm{l}}$\color{white}\chapterlabel}};
\node[anchor=north west,yshift=-7.2cm,xshift=37mm,text width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{\textwidth}{\color{\mytemplatecolor}#1}};
\end{tikzpicture}
};
\gdef\chapterlabel{} % code before the title body
\end{tikzpicture}
}
\titlespacing*{\chapter}{-98pt}{38pt}{30pt} % [A]
\begin{document}
\chapter{A Chapter}
\end{document}
If not can I somehow output the size of the logo to calculate manually the exact ratio? Can I specify a specific height in mm with \scalebox?

.
\resizebox, rather than\scalebox. – egreg Jan 31 '17 at 11:28\resizebox{0.379\width}{0.3755\height}{\usebox{logo}}is what you're looking for. – egreg Jan 31 '17 at 12:15\path (1.15,0.75) node {\resizebox{23mm}{15.15mm}{\usebox{\logo}}};so the logo is 15 mm in height... the extra 0.15 mm are likely due to the fact that the visible part of the logo is not 15 mm. I am still stuck to position the logo anchored at the lower left corner of the outer Box. If i change the width of the logo i have to manually reposition it...this is a it annoying – NorrinRadd Jan 31 '17 at 13:03\path (1.15,0.75) node {\resizebox{23mm}{15.15mm}{\usebox{\logo}}};use\node[above right=0mm, inner sep=0pt] at (0,0) {\resizebox{!}{15.15mm}{usebox{\logo}}};. The!in the resizebox means you only want to scale the height and Keep the aspect Ratio of the Image (assuming that's what you want). – Guilherme Zanotelli Jan 31 '17 at 13:07