Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. include 'imageEdit.php';
  2. function roundImage($image, $size, $text){
  3.     $corner = $size.'Corner';
  4.     switch($size){
  5.         case 'xSmall':
  6.             $bgPos = '3px';
  7.             $pad = '1px';
  8.             $fontStyle = 'normal';
  9.             $fontSize = '7px;';
  10.             $imageSize = 25;
  11.         case 'small':
  12.             $bgPos = '5px';
  13.             $pad = '1px';
  14.             $fontStyle = 'normal';
  15.             $fontSize = '8px;';
  16.             $imageSize = 50;
  17.             break;
  18.         case 'medium':
  19.             $bgPos = '10px';
  20.             $pad = '2px';
  21.             $fontStyle = 'normal';
  22.             $fontSize = '9px;';
  23.             $imageSize = 85;
  24.             break;
  25.         case 'big';
  26.             $bgPos = '15px';
  27.             $pad = '5px';
  28.             $fontStyle = 'italic';
  29.             $fontSize = '11px;';
  30.             $imageSize = 225;
  31.             break;
  32.     }
  33.     $thisImage = new createImage();
  34.     $thisImage -> load(substr($image,1));
  35.     $w = $thisImage -> getWidth();
  36.     $h = $thisImage -> getHeight();
  37.     if($w > $h){
  38.         $thisImage -> resizeToHeight($imageSize);
  39.     }else{
  40.         $thisImage -> resizeToWidth($imageSize);
  41.     }
  42.     $h = $thisImage -> getHeight();
  43.     $w = $thisImage -> getWidth();
  44.     $thisImage = '';
  45.     if($text != false){
  46.         $imageText = '<div class="hoverText"><p style="padding:'.$pad.'; font-style:'.$fontStyle.'; font-size:'.$fontSize.';">'.$text.'</p></div>';
  47.     }
  48.     return '<div class="'.$size.'Image">'.imageElement($image, $w, $h, $imageSize).$imageText.'</div><div class="topLeftCorner '.$corner.'"></div><div class="topRightCorner '.$corner.'"></div><div class="bottomLeftCorner '.$corner.'"></div><div class="bottomRightCorner '.$corner.'"></div>';
  49. }
  50. function imageElement($imagePath, $width, $height, $maxSize){
  51.     $style = '';
  52.     if($width < $height){
  53.         $style .= 'width:'.$maxSize.'px;';
  54.         $style .= 'bottom: -'.ceil(($height - $maxSize) / 2).'px;';
  55.         $style .= 'left: 0px;';
  56.     }else{
  57.         $style .= 'height:'.$maxSize.'px;';
  58.         $style .= 'left: -'.ceil(($width - $maxSize) / 2).'px;';
  59.         $style .= 'bottom:0px;';
  60.     }  
  61.     return '<img src="'.$imagePath.'" style="position:absolute;'.$style.'" />';
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement