I need to know how much I need to zoom (in percent) the inner box to rotate the outer rectangle 12 degrees and he touched the inner rectangle with four sides on the perimeter.
For example, I have image 400x300px.
In this image in photoshop, I rotated inner rectangle 12 degrees and zoom width on 113%, and height on 126% (how see my eye).

Let the inner rectangle be $W$ wide and $H$ high. If you rotate by $\theta$ the leftmost triangle is $W \cos \theta, W\sin \theta, W$ and the bottom triangle is $H\cos \theta, H\sin \theta, H$ The outer rectangle is then $(W \cos \theta + H \sin \theta) \times (H \cos \theta + W \sin \theta)$, which in your case is $300 \cos 12 + 400 \sin 12 \times 400 \cos 12 + 300 \sin 12 \approx 376.6 \times 453.6$ Your eye gave $378 \times 452$, mighty close.