public function setImage($key, $value, $page = null, $width = null, $height = null, $offsetX = null, $offsetY = null)
    {
        $filename = strtok(strrchr($value, '/'), '/.');
        $file = substr(strrchr($value, '/'), 1);
        $size = @getimagesize($value);
        if ($size === false) {
            throw new OdfException("Invalid image");
        }
        if (!$width && !$height) {
            list ($width, $height) = $size;
            $width *= Odf::PIXEL_TO_CM;
            $height *= Odf::PIXEL_TO_CM;
        }
        $anchor = $page == -1 ? 'text:anchor-type="aschar"' : "text:anchor-type=\"page\" text:anchor-page-number=\"{$page}\" svg:x=\"{$offsetX}cm\" svg:y=\"{$offsetY}cm\"";
        $xml = <<<IMG
<draw:frame draw:style-name="fr1" draw:name="$filename" {$anchor} svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
IMG;
        $this->images[$value] = $file;
        $this->manif_vars[] = $file;    //save image name as array element
        $this->setVars($key, $xml, false);
        return $this;
    }
public function setImage($key, $value, $page = null, $width = null, $height = null, $offsetX = null, $offsetY = null)
    {
        $filename = strtok(strrchr($value, '/'), '/.');
        $file = substr(strrchr($value, '/'), 1);
        $size = @getimagesize($value);
        if ($size === false) {
            throw new OdfException("Invalid image");
        }
        if (!$width && !$height) {
            list ($width, $height) = $size;
            $width *= Odf::PIXEL_TO_CM;
            $height *= Odf::PIXEL_TO_CM;
        }
        $anchor = $page == -1 ? 'text:anchor-type="aschar"' : "text:anchor-type=\"page\" text:anchor-page-number=\"{$page}\" svg:x=\"{$offsetX}cm\" svg:y=\"{$offsetY}cm\"";
        $xml = <<<IMG
<draw:frame draw:style-name="fr1" draw:name="$filename" {$anchor} svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
IMG;
        $this->images[$value] = $file;
        $this->manif_vars[] = $file;    //save image name as array element
        $this->setVars($key, $xml, false);
        return $this;
    }
public function setImage ( $ key , $ value , $ page = null , $ width = null , $ height = null , $ offsetX = null , $ offsetY = null ) { $ filename = strtok ( strrchr ( $ value , '/' ) , '/.' ) ; $ file = substr ( strrchr ( $ value , '/' ) , 1 ) ; $ size = @ getimagesize ( $ value ) ; if ( $ size === false ) { throw new OdfException ( "Invalid image" ) ; } if ( ! $ width && ! $ height ) { list ( $ width , $ height ) = $ size ; $ width *= Odf :: PIXEL_TO_CM ; $ height *= Odf :: PIXEL_TO_CM ; } $ anchor = $ page == - 1 ? 'text:anchor-type="aschar"' : "text:anchor-type=\"page\" text:anchor-page-number=\"{$page}\" svg:x=\"{$offsetX}cm\" svg:y=\"{$offsetY}cm\"" ; $ xml =  <<<IMG
<draw:frame draw:style-name="fr1" draw:name="$filename" {$anchor} svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
IMG ; $ this -> images [ $ value ] = $ file ; $ this -> manif_vars [ ] = $ file ; //save image name as array element $ this -> setVars ( $ key , $ xml , false ) ; return $ this ; }
Assign a template variable as a picture

@param string $key name of the variable within the template
@param string $value path to the picture
@param string $page anchor to page number (or -1 if anchor-type is aschar)
@param string $width width of picture (keep original if null)
@param string $height height of picture (keep original if null)
@param string $offsetX offset by horizontal (not used if $page = -1)
@param string $offsetY offset by vertical (not used if $page = -1)
@throws OdfException
@return Segment
Assign a template variable as a picture