Quote from: zaigham at Apr 27, 2012, 09:15 AM
Would you like to share your snippet with us? 
Thanks.
Sure

Here's the snippet
<?php
// --------------------
// Parameters
// --------------------
// $src
// $width
// $height
// $zc
if (empty($modx)) return;
if (!$modx->loadClass('modPhpThumb', $modx->getOption('core_path') . 'model/phpthumb/', true, true))
{
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not load modPhpThumb class.');
return;
}
$thumb_path = sprintf('assets/thumbs/%sx%s-%s', $width, $height, basename($src));
if (!file_exists($thumb_path))
{
$thumb = new modPhpThumb($modx);
$thumb->initialize();
$thumb->set($src);
if (isset($width)) $thumb->setParameter('w', $width);
if (isset($height)) $thumb->setParameter('h', $height);
if (isset($zc)) $thumb->setParameter('zc', $zc);
$thumb->GenerateThumbnail();
$thumb->RenderToFile(MODX_BASE_PATH . $thumb_path);
}
return $thumb_path;
If you were to name the snippet 'create_thumb' you would call it using:
[[!create_thumb? &src=`path/to/your/image` &width=`300` &height=`150` &zc=`1`]]
and it will output the path to the generated thumbnail.
Note: The generated thumbnail names aren't very good if you miss out either the width or the height parameters but that won't stop it working.