The picture stuff uses the size settings contained in the XML, it just replaces the image, but read on...
In bind.xslt we have:
Using xml Syntax Highlighting
<!-- docx4j 3.0.1. Handle a rich text control which contains an image.
Since this doesn't have a w:databinding, we can't just use mode="picture3"
If the w:sdtContent contains an existing w:drawing/wp:inline/a:graphic ..
reuse it, so any formatting thus configured is used.
We'll just replace the rId.. -->
<xsl:template match=" @*|node()" mode="picture3richtext">
<xsl:param name="tag" select="/.."/>
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="picture3richtext">
<xsl:with-param name="tag" select="$tag"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="a:blip" mode="picture3richtext" priority="1">
<xsl:param name="tag" select="/.."/>
<a:blip r:embed="{java:org.docx4j.model.datastorage.BindingTraverserXSLT.xpathInjectImageRelId(
$wmlPackage,
$sourcePart,
$customXmlDataStorageParts,
$xPathsMap,
$tag )}" />
<!-- if it was @r:link, it is now embedded -->
</xsl:template>
Parsed in 0.002 seconds, using
GeSHi 1.0.8.4
and
Using xml Syntax Highlighting
<xsl:when test="w:sdtPr/w:dataBinding and w:sdtPr/w:picture">
<!-- honour w:dataBinding -->
<xsl:choose>
<xsl:when test="w:sdtContent//a:blip"><!-- docx4j 3.0 -->
<xsl:copy>
<xsl:copy-of select="w:sdtPr"/>
<xsl:if test="w:stdEndPr">
<xsl:copy-of select="w:sdtEndPr"/>
</xsl:if>
<xsl:apply-templates select="w:sdtContent" mode="picture3">
<xsl:with-param name="sdtPr" select="w:sdtPr"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<!-- fallback to pre v3 approach -->
<xsl:copy>
<xsl:copy-of select="w:sdtPr"/>
<xsl:if test="w:stdEndPr">
<xsl:copy-of select="w:sdtEndPr"/>
</xsl:if>
<w:sdtContent>
<xsl:copy-of
select="java:org.docx4j.model.datastorage.BindingTraverserXSLT.xpathInjectImage(
$wmlPackage,
$sourcePart,
$customXmlDataStorageParts,
string(w:sdtPr/w:dataBinding/@w:storeItemID),
string(w:sdtPr/w:dataBinding/@w:xpath),
string(w:sdtPr/w:dataBinding/@w:prefixMappings),
$parent,
$child,
string(w:sdtContent//wp:extent[1]/@cx),
string(w:sdtContent//wp:extent[1]/@cy))" />
</w:sdtContent>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
Parsed in 0.002 seconds, using
GeSHi 1.0.8.4
For the picture content control case, BindingTraverserXSLT's xpathInjectImage will use the cx, cy values found in the pre-existing image xml, unless they are 0. If 0, docx4j will work out the native image size. So you ought to be able to get this to happen, by editing those values to be 0.
For the rich text case, the image is replaced and that's all. No sizing magic.
As mentioned in my earlier reply, consider instead binding escaped XHTML containing a image. That uses
https://github.com/plutext/docx4j-Impor ... fault.java which gets the image size this way:
https://github.com/plutext/docx4j-Impor ... java#L1601