本文整理汇总了PHP中sfImage::setMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP sfImage::setMimeType方法的具体用法?PHP sfImage::setMimeType怎么用?PHP sfImage::setMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfImage
的用法示例。
在下文中一共展示了sfImage::setMimeType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: opp_sync_politician_image
/**
* fetch today's news regarding objects monitored by the user
*
* @param string $user - OppUser object
* @return void
* @author Guglielmo Celata
*/
function opp_sync_politician_image($pol)
{
$start_time = microtime(true);
$success = true;
echo pakeColor::colorize(sprintf('Processing politician %s...', $pol), array('fg' => 'red', 'bold' => true));
// invoke the remote getPolImage function to grab the images from op_openpolis
$remote_img_url = sfConfig::get('app_remote_politicians_images_service_url') . '/' . sfConfig::get('app_remote_openpolis_api_key') . '/' . $pol->getId();
/* debug
echo pakeColor::colorize(sprintf('Url: %s...', $remote_img_url),
array('fg' => 'red', 'bold' => true));
*/
$file = fopen($remote_img_url, "r");
if (!$file) {
$err = "unable to open remote file.";
$success = false;
}
$remote_img_str = '';
while (!feof($file)) {
$remote_img_str .= fgets($file, 1024);
}
fclose($file);
$images_root = SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'parlamentari' . DIRECTORY_SEPARATOR;
// resizes images and stores them in the FS
$picture = new sfImage();
$picture->setMimeType('image/jpeg');
$picture->loadString($remote_img_str);
$picture->resize(91, null);
$picture->saveAs($images_root . 'picture/' . $pol->getId() . '.jpeg', 'image/jpeg');
$thumb = new sfImage();
$thumb->setMimeType('image/jpeg');
$thumb->loadString($remote_img_str);
$thumb->resize(40, null);
$thumb->saveAs($images_root . 'thumb/' . $pol->getId() . '.jpeg', 'image/jpeg');
$execution_time = microtime(true) - $start_time;
if ($success) {
echo " ok (";
} else {
echo " {$err} (";
}
echo pakeColor::colorize(sprintf("%f", $execution_time), array('fg' => 'cyan'));
echo ")\n";
}