I have a h:graphicImage in a composite component like this:
You can conditionally add attributes via <c:if><f:attribute>
.
<h:graphicImage ...>
<c:if test="#{not empty cc.attrs.height}"><f:attribute name="height" value="#{cc.attrs.height}" /></c:if>
<c:if test="#{not empty cc.attrs.width}"><f:attribute name="width" value="#{cc.attrs.width}" /></c:if>
</h:graphicImage>