Method: getResizedImage($imagefilename , $width , $height , [$cropmode] , [$fill] , [$top] , [$right] , [$bottom] , [$left])

Creates a resized image based upon the inputs sent and returns the URL of created image (eg: '/myimage.100_100_crop_FFFFFF.jpg').

Detailed examples of usage can be found here.

Arguments:

$imagefilename (STRING)
Path to image on server. Eg: '/media/myimage.jpg'

$width (INT or 'auto')
Width in pixels of image to output.
If 'auto' the image will be resized maintaining its current aspect ratio to match the $height specified.

$height (INT or 'auto')
Height in pixels of image to output.
If 'auto' the image will be resized maintaining its current aspect ratio to match the $width specified.

$cropmode (ENUM) optional - default: crop
- crop: crop image to fit aspect ratio of result
- whitespace: add whitespace to image to fit aspect ratio of result

$fill (STRING) optional - default: 'FFFFFF'
Fill color to use in whitespace added to the image output. (Hex value)

$top, $right , $bottom , $left (INT or 'auto') - default: 'auto'
Positioning of resized source image within the the new output image. Eg $top = 10, would result in the resized image being aligned 10px from the top of the new image.
If 'auto', the image is centre aligned in the output

Returns:

STRING

Example:

$this->getResizedImage('/media/myimage.jpg' , 200 , 200 , 'crop');
$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 200 , 200 , 'whitespace' , 'ef6633' , 0 , 'auto' , 'auto' , 0);

Example 2:

<div>
	<h3>Crop to 300x300px</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'crop'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_crop__autoautoautoauto.png" />
	</div>
</div>
<div>
	<h3>Crop to 300x300px left aligned</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'crop' , 'FFFFFF' , 'auto' , 'auto' , 'auto' , 0));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_crop_FFFFFF_autoautoauto0.png" />
	</div>
</div>
<div>
	<h3>Crop to 300x50px top aligned</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 50 , 'crop' , 'FFFFFF' , 0 , 'auto' , 'auto' , 0));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x50_crop_FFFFFF_0autoauto0.png" />
	</div>
</div>
<div>
	<h3>Crop to 150x300px bottom right aligned</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 100 , 300 , 'crop' , 'FFFFFF' , 'auto' , 0 , 0 , 'auto'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.150x300_crop_FFFFFF_auto00auto.png" />
	</div>
</div>
<div>
	<h3>Add whitespace to 300x300px</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'whitespace'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_whitespace__autoautoautoauto.png" />
	</div>
</div>
<div>
	<h3>Add whitespace to 500x100px left aligned</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 500 , 100 , 'whitespace' , 'FFFFFF' , 'auto' , 'auto' , 'auto' , 0));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.500x100_whitespace_FFFFFF_autoautoauto0.png" />
	</div>
</div>
<div>
	<h3>Add whitespace to 500x100px right aligned</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 500 , 100 , 'whitespace' , 'FFFFFF' , 'auto' , 0 , 'auto' , 'auto'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.500x100_whitespace_FFFFFF_auto0autoauto.png" />
	</div>
</div>
<div>
	<h3>Add color fill to 300x300px</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'whitespace' , 'FF0000'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_whitespace_556270_autoautoautoauto.png" />
	</div>
</div>
<div>
	<h3>Add color fill to 300x300px align top</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'whitespace' , 'FF0000' , 0 , 'auto' , 'auto' , 'auto'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_whitespace_556270_0autoautoauto.png" />
	</div>
</div>
<div>
	<h3>Add color fill to 300x300px align bottom</h3>
	<p>$this->getResizedImage($this->document->getValue('document_thumbnailimage') , 300 , 300 , 'whitespace' , 'FF0000' , 'auto' , 'auto' , 0 , 'auto'));</p>
	<div>
		<img style="border: 1px solid #DDD"  src="/media/logo_bw.300x300_whitespace_556270_autoauto0auto.png" />
	</div>
</div>

Contact Us

Address: 22a Fishergate York, YO10 4AB · Tel: 01904 636677 · Email: info@dotadmin.com