当前位置: 首页>>代码示例>>PHP>>正文


PHP imageCreateFromWBMP函数代码示例

本文整理汇总了PHP中imageCreateFromWBMP函数的典型用法代码示例。如果您正苦于以下问题:PHP imageCreateFromWBMP函数的具体用法?PHP imageCreateFromWBMP怎么用?PHP imageCreateFromWBMP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imageCreateFromWBMP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gerar_tumbs_real

function gerar_tumbs_real($t_x, $t_y, $qualidade, $c_original, $c_final)
{
    $thumbnail = imagecreatetruecolor($t_x, $t_y);
    $original = $c_original;
    $igInfo = getImageSize($c_original);
    switch ($igInfo['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                $originalimage = imageCreateFromGIF($original);
            } else {
                $ermsg = MSG_GIF_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $originalimage = imageCreateFromJPEG($original);
            } else {
                $ermsg = MSG_JPG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $originalimage = imageCreateFromPNG($original);
            } else {
                $ermsg = MSG_PNG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $originalimage = imageCreateFromWBMP($original);
            } else {
                $ermsg = MSG_WBMP_NOT_COMPATIBLE . '<br />';
            }
            break;
        default:
            $ermsg = $igInfo['mime'] . MSG_FORMAT_NOT_COMPATIBLE . '<br />';
            break;
    }
    $nLargura = $igInfo[0];
    $nAltura = $igInfo[1];
    if ($nLargura > $t_x and $nAltura > $t_y) {
        if ($t_x <= $t_y) {
            $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
            $nAltura = $t_y;
        } else {
            $nLargura = $t_x;
            $nAltura = (int) ($igInfo[1] * $t_x / $igInfo[0]);
            if ($nAltura < $t_y) {
                $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
                $nAltura = $t_y;
            }
        }
    }
    $x_pos = $t_x / 2 - $nLargura / 2;
    $y_pos = $t_y / 2 - $nAltura / 2;
    imagecopyresampled($thumbnail, $originalimage, $x_pos, $y_pos, 0, 0, $nLargura, $nAltura, $igInfo[0], $igInfo[1]);
    imagejpeg($thumbnail, $c_final, $qualidade);
    imagedestroy($thumbnail);
    return 'ok';
}
开发者ID:amorimlima,项目名称:Hospital,代码行数:60,代码来源:Thumbs.php

示例2: create_thumb

function create_thumb($path, $thumb_path, $width = THUMB_WIDTH, $height = THUMB_HEIGHT)
{
    $image_info = getImageSize($path);
    // see EXIF for faster way
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                // not the same as IMAGETYPE
                $o_im = @imageCreateFromGIF($path);
            } else {
                throw new Exception('GIF images are not supported');
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $o_im = @imageCreateFromJPEG($path);
            } else {
                throw new Exception('JPEG images are not supported');
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $o_im = @imageCreateFromPNG($path);
            } else {
                throw new Exception('PNG images are not supported');
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $o_im = @imageCreateFromWBMP($path);
            } else {
                throw new Exception('WBMP images are not supported');
            }
            break;
        default:
            throw new Exception($image_info['mime'] . ' images are not supported');
            break;
    }
    list($o_wd, $o_ht, $html_dimension_string) = $image_info;
    $ratio = $o_wd / $o_ht;
    $t_ht = $width;
    $t_wd = $height;
    if (1 > $ratio) {
        $t_wd = round($o_wd * $t_wd / $o_ht);
    } else {
        $t_ht = round($o_ht * $t_ht / $o_wd);
    }
    $t_wd = $t_wd < 1 ? 1 : $t_wd;
    $t_ht = $t_ht < 1 ? 1 : $t_ht;
    $t_im = imageCreateTrueColor($t_wd, $t_ht);
    imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
    imagejpeg($t_im, $thumb_path, 85);
    chmod($thumb_path, 0664);
    imageDestroy($o_im);
    imageDestroy($t_im);
    return array($t_wd, $t_ht);
}
开发者ID:sztanpet,项目名称:aoiboard,代码行数:57,代码来源:functions.php

示例3: imageConverter

 function imageConverter()
 {
     /* parse arguments */
     $numargs = func_num_args();
     $imagefile = func_get_arg(0);
     $convertedtype = func_get_arg(1);
     $output = 0;
     if ($numargs > 2) {
         $this->output = func_get_arg(2);
     }
     /* ask the type of original file */
     $fileinfo = pathinfo($imagefile);
     $imtype = $fileinfo["extension"];
     $this->imname = basename($fileinfo["basename"], "." . $imtype);
     $this->imtype = $imtype;
     /* create the image variable of original file */
     switch ($imtype) {
         case "gif":
             $this->im = imageCreateFromGIF($imagefile);
             break;
         case "jpg":
             $this->im = imageCreateFromJPEG($imagefile);
             break;
         case "png":
             $this->im = imageCreateFromPNG($imagefile);
             break;
         case "wbmp":
             $this->im = imageCreateFromWBMP($imagefile);
             break;
             /*
             		mail me if you have/find this functionality bellow  */
             /*
             case "swf":
             	$this->im 	= $this->imageCreateFromSWF($imagefile);
             	break;
             */
     }
     /* convert to intended type */
     $this->convertImage($convertedtype);
 }
开发者ID:rsuryawanshi,项目名称:corp,代码行数:40,代码来源:imageconverter.class.php

示例4: __open

 /**
  * Open the source and target image for processing it
  *
  * @param Asido_TMP &$tmp
  * @return boolean
  * @access protected
  */
 function __open(&$tmp)
 {
     $error_source = false;
     $error_target = false;
     // get image dimensions
     //
     if ($i = @getImageSize($tmp->source_filename)) {
         $tmp->image_width = $i[0];
         $tmp->image_height = $i[1];
     }
     // image type ?
     //
     switch (@$i[2]) {
         case 1:
             // GIF
             $error_source = false == ($tmp->source = @imageCreateFromGIF($tmp->source_filename));
             $error_target = false == ($tmp->target = imageCreateTrueColor($tmp->image_width, $tmp->image_height));
             $error_target &= imageCopyResampled($tmp->target, $tmp->source, 0, 0, 0, 0, $tmp->image_width, $tmp->image_height, $tmp->image_width, $tmp->image_height);
             break;
         case 2:
             // JPG
             $error_source = false == ($tmp->source = imageCreateFromJPEG($tmp->source_filename));
             $error_target = false == ($tmp->target = imageCreateFromJPEG($tmp->source_filename));
             break;
         case 3:
             // PNG
             $error_source = false == ($tmp->source = @imageCreateFromPNG($tmp->source_filename));
             $error_target = false == ($tmp->target = @imageCreateFromPNG($tmp->source_filename));
             break;
         case 15:
             // WBMP
             $error_source = false == ($tmp->source = @imageCreateFromWBMP($tmp->source_filename));
             $error_target = false == ($tmp->target = @imageCreateFromWBMP($tmp->source_filename));
             break;
         case 16:
             // XBM
             $error_source = false == ($tmp->source = @imageCreateFromXBM($tmp->source_filename));
             $error_target = false == ($tmp->target = @imageCreateFromXBM($tmp->source_filename));
             break;
         case 4:
             // SWF
         // SWF
         case 5:
             // PSD
         // PSD
         case 6:
             // BMP
         // BMP
         case 7:
             // TIFF(intel byte order)
         // TIFF(intel byte order)
         case 8:
             // TIFF(motorola byte order)
         // TIFF(motorola byte order)
         case 9:
             // JPC
         // JPC
         case 10:
             // JP2
         // JP2
         case 11:
             // JPX
         // JPX
         case 12:
             // JB2
         // JB2
         case 13:
             // SWC
         // SWC
         case 14:
             // IFF
         // IFF
         default:
             $error_source = false == ($tmp->source = @imageCreateFromString(file_get_contents($tmp->source_filename)));
             $error_target = false == ($tmp->source = @imageCreateFromString(file_get_contents($tmp->source_filename)));
             break;
     }
     return !($error_source || $error_target);
 }
开发者ID:ashanrupasinghe,项目名称:dnp,代码行数:86,代码来源:class.driver.gd.php

示例5: thumbComplete

 public static function thumbComplete($o_file, $fileName, $t_ht = 100, $x, $y, $width, $height, $ow, $sizes = array())
 {
     $image_info = getImageSize($o_file);
     // see EXIF for faster way
     switch ($image_info['mime']) {
         case 'image/gif':
             if (imagetypes() & IMG_GIF) {
                 // not the same as IMAGETYPE
                 $o_im = imageCreateFromGIF($o_file);
             }
             break;
         case 'image/jpeg':
             if (imagetypes() & IMG_JPG) {
                 $o_im = imageCreateFromJPEG($o_file);
             }
             break;
         case 'image/png':
             if (imagetypes() & IMG_PNG) {
                 $o_im = imageCreateFromPNG($o_file);
             }
             break;
         case 'image/wbmp':
             if (imagetypes() & IMG_WBMP) {
                 $o_im = imageCreateFromWBMP($o_file);
             }
             break;
         default:
             break;
     }
     $o_wd = imagesx($o_im);
     $o_ht = imagesy($o_im);
     $size = $o_wd / $ow;
     echo $size . '<br>';
     echo $x * $size . '<br>';
     echo $y * $size . '<br>';
     echo $sizes['width'] . '<br>';
     echo $sizes['height'] . '<br>';
     echo $width * $size . '<br>';
     echo $height * $size . '<br>';
     //        die;
     $new_im = imageCreateTrueColor($width, $height);
     if (empty($sizes)) {
         imagecopyresampled($new_im, $o_im, 0, 0, $x * $size, $y * $size, $width * $size, $height * $size, $width * $size, $height * $size);
     } else {
         imagecopyresampled($new_im, $o_im, 0, 0, $x * $size, $y * $size, $sizes['width'], $sizes['height'], $width * $size, $height * $size);
     }
     imageJPEG($new_im, $fileName, 100);
     chmod($fileName, 0777);
     imageDestroy($o_im);
     imageDestroy($new_im);
     return true;
 }
开发者ID:alexchitoraga,项目名称:tunet,代码行数:52,代码来源:Upload.class.php

示例6: MakeThumbnail

 public function MakeThumbnail($o_file, $fileName, $quality, $width, $height)
 {
     $image_info = getImageSize($o_file);
     switch ($image_info['mime']) {
         case 'image/gif':
             if (imagetypes() & IMG_GIF) {
                 // not the same as IMAGETYPE
                 $o_im = imageCreateFromGIF($o_file);
             }
             break;
         case 'image/jpeg':
             if (imagetypes() & IMG_JPG) {
                 $o_im = imageCreateFromJPEG($o_file);
             }
             break;
         case 'image/png':
             if (imagetypes() & IMG_PNG) {
                 $o_im = imageCreateFromPNG($o_file);
             }
             break;
         case 'image/wbmp':
             if (imagetypes() & IMG_WBMP) {
                 $o_im = imageCreateFromWBMP($o_file);
             }
             break;
         default:
             break;
     }
     $o_wd = imagesx($o_im);
     $o_ht = imagesy($o_im);
     // thumbnail width = target * original width / original height
     if ($o_ht > $o_wd) {
         $t_wd = round($o_wd * $height / $o_ht);
         $t_ht = $height;
     }
     if ($o_ht < $o_wd) {
         $t_ht = round($o_ht * $width / $o_wd);
         $t_wd = $width;
     }
     if ($t_ht > $height) {
         $t_wd = round($o_wd * $height / $o_ht);
         $t_ht = $height;
     }
     $t_im = imageCreateTrueColor($t_wd, $t_ht);
     imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
     imageJPEG($t_im, $fileName, 100);
     imageDestroy($o_im);
     imageDestroy($t_im);
     return true;
 }
开发者ID:alexchitoraga,项目名称:tunet,代码行数:50,代码来源:TFiles.class.php

示例7: makeThumbnail

function makeThumbnail($o_file, $t_file, $t_ht = 100)
{
    $image_info = getImageSize($o_file);
    // see EXIF for faster way
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                // not the same as IMAGETYPE
                $o_im = imageCreateFromGIF($o_file);
            } else {
                $ermsg = 'GIF images are not supported<br />';
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $o_im = imageCreateFromJPEG($o_file);
            } else {
                $ermsg = 'JPEG images are not supported<br />';
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $o_im = imageCreateFromPNG($o_file);
            } else {
                $ermsg = 'PNG images are not supported<br />';
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $o_im = imageCreateFromWBMP($o_file);
            } else {
                $ermsg = 'WBMP images are not supported<br />';
            }
            break;
        default:
            $ermsg = $image_info['mime'] . ' images are not supported<br />';
            break;
    }
    if (!isset($ermsg)) {
        $o_wd = imagesx($o_im);
        $o_ht = imagesy($o_im);
        // thumbnail width = target * original width / original height
        //
        if ($o_ht > $o_wd && $o_ht > $t_ht) {
            $new_w = $t_ht / $o_ht * $o_wd;
            $new_h = $t_ht;
        } else {
            if ($o_wd > $t_ht) {
                $new_h = $t_ht / $o_wd * $o_ht;
                $new_w = $t_ht;
            } else {
                $new_h = $o_ht;
                $new_w = $o_wd;
            }
        }
        //
        //$t_wd = round($o_wd * $t_ht / $o_ht) ;
        $t_im = imageCreateTrueColor($new_w, $new_h);
        imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $new_w, $new_h, $o_wd, $o_ht);
        imageJPEG($t_im, $t_file);
        imageDestroy($o_im);
        imageDestroy($t_im);
    }
    return isset($ermsg) ? $ermsg : NULL;
}
开发者ID:jackmolnar,项目名称:glit_website_new,代码行数:65,代码来源:upload_script.php

示例8: imageCreateFromJPEG

        if (imagetypes() & IMG_JPG) {
            $insert2 = imageCreateFromJPEG($foto);
        } else {
            $ermsg = 'JPEG images are not supported<br />';
        }
        break;
    case 'image/png':
        if (imagetypes() & IMG_PNG) {
            $insert2 = imageCreateFromPNG($foto);
        } else {
            $ermsg = 'PNG images are not supported<br />';
        }
        break;
    case 'image/wbmp':
        if (imagetypes() & IMG_WBMP) {
            $insert2 = imageCreateFromWBMP($foto);
        } else {
            $ermsg = 'WBMP images are not supported<br />';
        }
        break;
    default:
        $ermsg = $image_info['mime'] . ' images are not supported<br />';
        break;
}
imagealphablending($insert, false);
imagesavealpha($insert, true);
imagecolortransparent($insert, imagecolorat($insert, 0, 0));
imagecolortransparent($insert2, imagecolorat($insert2, 0, 0));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
$is = imagesx($insert2);
开发者ID:kevinmel2000,项目名称:id-card-generator,代码行数:31,代码来源:images.php

示例9: image_resize_local

 /**
  * Function image_resize_local will resize the target image
  * @param string $source
  * @param string $dest
  * @param int $targetHeight
  * @param int $targetWidth
  * @return string
  */
 function image_resize_local($source, $dest, $targetHeight = 75, $targetWidth = 100)
 {
     $image_info = @getImageSize($source);
     // see EXIF for faster way
     switch ($image_info['mime']) {
         case 'image/gif':
             if (imagetypes() & IMG_GIF) {
                 $src_handle = imageCreateFromGIF($source);
             } else {
                 $ermsg = 'GIF images are not supported<br />';
             }
             break;
         case 'image/jpeg':
             if (imagetypes() & IMG_JPG) {
                 $src_handle = imageCreateFromJPEG($source);
             } else {
                 $ermsg = 'JPEG images are not supported<br />';
             }
             break;
         case 'image/png':
             if (imagetypes() & IMG_PNG) {
                 $src_handle = imageCreateFromPNG($source);
             } else {
                 $ermsg = 'PNG images are not supported<br />';
             }
             break;
         case 'image/wbmp':
             if (imagetypes() & IMG_WBMP) {
                 $src_handle = imageCreateFromWBMP($source);
             } else {
                 $ermsg = 'WBMP images are not supported<br />';
             }
             break;
         default:
             $ermsg = $image_info['mime'] . ' images are not supported<br />';
             break;
     }
     if (!isset($ermsg)) {
         $org_w = imagesx($src_handle);
         $org_h = imagesy($src_handle);
         $width = $org_w;
         $height = $org_h;
         $arrDimentions = clsUtil::fnSetImageHeighWidth($source, $targetHeight, $targetWidth);
         $dest_handle = imageCreateTrueColor($arrDimentions['width'], $arrDimentions['height']);
         imageCopyResampled($dest_handle, $src_handle, 0, 0, 0, 0, $arrDimentions['width'], $arrDimentions['height'], $org_w, $org_h);
         imageJPEG($dest_handle, $dest);
         imageDestroy($src_handle);
         imageDestroy($dest_handle);
     }
     return isset($ermsg) ? $ermsg : NULL;
 }
开发者ID:vikrantlabde,项目名称:marmik,代码行数:59,代码来源:clsUtil.php

示例10: image_arr_resize_to_folder

/**
 * upload image to destination folder, return file name
 * @author ivan lubis
 * @param $source_pic array string source file
 * @param $destination_folder string destination upload folder
 * @param $filename string file name
 * @param $max_width string maximum image width
 * @param $max_height string maximum image height
 * @return array string of edited file name
 */
function image_arr_resize_to_folder($source_pic, $destination_folder, $filename, $max_width, $max_height)
{
    $tmp_dest = $destination_folder;
    for ($index = 0; $index < count($source_pic['tmp_name']); $index++) {
        $destination_folder = $tmp_dest;
        $image_info = getimagesize($source_pic['tmp_name'][$index]);
        $source_pic_name = $source_pic['name'][$index];
        $source_pic_tmpname = $source_pic['tmp_name'][$index];
        $source_pic_size = $source_pic['size'][$index];
        $source_pic_width = $image_info[0];
        $source_pic_height = $image_info[1];
        $x_ratio = $max_width / $source_pic_width;
        $y_ratio = $max_height / $source_pic_height;
        if ($source_pic_width <= $max_width && $source_pic_height <= $max_height) {
            $tn_width = $source_pic_width;
            $tn_height = $source_pic_height;
        } elseif ($x_ratio * $source_pic_height < $max_height) {
            $tn_height = ceil($x_ratio * $source_pic_height);
            $tn_width = $max_width;
        } else {
            $tn_width = ceil($y_ratio * $source_pic_width);
            $tn_height = $max_height;
        }
        switch ($image_info['mime']) {
            case 'image/gif':
                if (imagetypes() & IMG_GIF) {
                    $src = imageCreateFromGIF($source_pic['tmp_name'][$index]);
                    $destination_folder .= "{$filename[$index]}.gif";
                    $namafile = "{$filename[$index]}.gif";
                }
                break;
            case 'image/jpeg':
                if (imagetypes() & IMG_JPG) {
                    $src = imageCreateFromJPEG($source_pic['tmp_name'][$index]);
                    $destination_folder .= "{$filename[$index]}.jpg";
                    $namafile = "{$filename[$index]}.jpg";
                }
                break;
            case 'image/pjpeg':
                if (imagetypes() & IMG_JPG) {
                    $src = imageCreateFromJPEG($source_pic['tmp_name'][$index]);
                    $destination_folder .= "{$filename[$index]}.jpg";
                    $namafile = "{$filename[$index]}.jpg";
                }
                break;
            case 'image/png':
                if (imagetypes() & IMG_PNG) {
                    $src = imageCreateFromPNG($source_pic['tmp_name'][$index]);
                    $destination_folder .= "{$filename[$index]}.png";
                    $namafile = "{$filename[$index]}.png";
                }
                break;
            case 'image/wbmp':
                if (imagetypes() & IMG_WBMP) {
                    $src = imageCreateFromWBMP($source_pic['tmp_name'][$index]);
                    $destination_folder .= "{$filename[$index]}.bmp";
                    $namafile = "{$filename[$index]}.bmp";
                }
                break;
        }
        //chmod($destination_pic,0777);
        $tmp = imagecreatetruecolor($tn_width, $tn_height);
        imagecopyresampled($tmp, $src, 0, 0, 0, 0, $tn_width, $tn_height, $source_pic_width, $source_pic_height);
        //**** 100 is the quality settings, values range from 0-100.
        switch ($image_info['mime']) {
            case 'image/jpeg':
                imagejpeg($tmp, $destination_folder, 100);
                break;
            case 'image/gif':
                imagegif($tmp, $destination_folder, 100);
                break;
            case 'image/png':
                imagepng($tmp, $destination_folder);
                break;
            default:
                imagejpeg($tmp, $destination_folder, 100);
                break;
        }
        $url[] = $namafile;
    }
    return $url;
}
开发者ID:xemmex,项目名称:codeigniter3-custom-cms,代码行数:92,代码来源:cms_helper.php

示例11: CreateThumbnail

 /**
  * Creates a thumbnail of the image passed and saves it to $thumbnail
  * Thumbnail uses either width or height, whichever is larger in the original, and then maintains aspect ratio
  *
  * @param string $original path and filename of original/uploaded image
  * @param string $thumbnail location to store thumbnail image
  * @param integer $width
  * @param integer $height
  * @param integer $quality
  */
 protected function CreateThumbnail($original, $thumbnail, $width, $height, $quality)
 {
     list($width_orig, $height_orig) = getimagesize($original);
     if ($width && $width_orig < $height_orig) {
         $width = $height / $height_orig * $width_orig;
     } else {
         $height = $width / $width_orig * $height_orig;
     }
     $image_p = imagecreatetruecolor($width, $height);
     switch ($this->strType) {
         case 'image/gif':
             $image = imageCreateFromGIF($original);
             break;
         case 'image/jpeg':
         case 'image/pjpeg':
             $image = imageCreateFromJPEG($original);
             break;
         case 'image/png':
         case 'image/x-png':
             $image = imageCreateFromPNG($original);
             break;
         case 'image/wbmp':
             $image = imageCreateFromWBMP($original);
             break;
     }
     imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
     imagejpeg($image_p, $thumbnail, $quality);
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:38,代码来源:QImageFileControl.class.php

示例12: typeCreateImage

 protected function typeCreateImage($pointer)
 {
     $filename = $this->image[$pointer];
     $mime = $this->mime[$pointer];
     if (imagetypes() & $mime) {
         switch ($mime) {
             case 2:
                 return imageCreateFromJPEG($filename);
                 break;
             case 15:
                 return imageCreateFromWBMP($filename);
                 break;
             case 1:
                 return imageCreateFromGIF($filename);
                 break;
             case 3:
                 return imageCreateFromPNG($filename);
                 break;
             case 16:
                 return imageCreateFromXBM($filename);
                 break;
         }
     } else {
         return false;
     }
 }
开发者ID:GoPlaceIn,项目名称:siacc,代码行数:26,代码来源:Image.class.php

示例13: avatar_resize

function avatar_resize($infile, $outfile, $size)
{
    $image_info = getImageSize($infile);
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                $src_img = imageCreateFromGIF($infile);
            } else {
                $ermsg = 'GIF images are not supported<br />';
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $src_img = imageCreateFromJPEG($infile);
            } else {
                $ermsg = 'JPEG images are not supported<br />';
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $src_img = imageCreateFromPNG($infile);
            } else {
                $ermsg = 'PNG images are not supported<br />';
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $src_img = imageCreateFromWBMP($infile);
            } else {
                $ermsg = 'WBMP images are not supported<br />';
            }
            break;
        default:
            $ermsg = $image_info['mime'] . ' images are not supported<br />';
            break;
    }
    if (isset($ermsg)) {
        echo "Error: {$ermsg}";
        die;
    }
    $dst_img = ImageCreateTrueColor($size, $size);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $size, $size, imagesx($src_img), imagesy($src_img));
    imagejpeg($dst_img, $outfile, 85);
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:44,代码来源:avatars.php

示例14: resizeImage_gd

 private function resizeImage_gd($cacheFileName, $width, $height, $crop = false, $cropOffset = 1, $forceSize = false, $usePiramidalSizes = true, $resize = true)
 {
     $objImg = null;
     if (file_exists($this->getFileName())) {
         $imagetype = $this->getOriginalImageType();
         switch ($imagetype) {
             case 'image/gif':
                 if (function_exists('imageCreateFromGIF')) {
                     $objImg = imageCreateFromGIF($this->getFileName());
                 } else {
                     $objImg = imageCreateFromPNG($this->getFileName());
                 }
                 break;
             case 'image/jpeg':
                 $objImg = imageCreateFromJPEG($this->getFileName());
                 break;
             case 'image/png':
                 $objImg = imageCreateFromPNG($this->getFileName());
                 break;
             case 'image/vnd.wap.wbmp':
                 $objImg = imageCreateFromWBMP($this->getFileName());
                 break;
             default:
                 //	$ermsg = $imageInfo['mime'].' images are not supported<br />';
                 break;
         }
     }
     $originalSizes = $this->getOriginalSizes();
     if (!is_null($objImg)) {
         $finalSizes = $this->resizeImageGetFinalSizes($width, $height, $crop, $cropOffset, $forceSize);
         $img = imageCreateTrueColor($crop ? $width : $finalSizes['width'], $crop ? $height : $finalSizes['height']);
         $w = imagecolorallocate($img, 255, 255, 255);
         imagefill($img, 0, 0, $w);
         if ($resize) {
             imageCopyResampled($img, $objImg, $finalSizes['cropX'], $finalSizes['cropY'], 0, 0, $finalSizes['width'], $finalSizes['height'], $originalSizes['width'], $originalSizes['height']);
             $unsharpMask = __Config::get('glizy.media.image.unsharpMask');
             if ($unsharpMask) {
                 list($a, $r, $t) = explode(',', $unsharpMask);
                 glz_importLib('phpUnsharpMask/phpUnsharpMask.php');
                 phpUnsharpMask::applyUnsharpMask($img, $a, $r, $t);
             }
         } else {
             imageCopy($img, $objImg, 0, 0, 0, 0, $originalSizes['width'], $originalSizes['height']);
         }
         if ($this->watermark) {
             $this->insertWatermark($img, $crop ? $width : $finalSizes['width'], $crop ? $height : $finalSizes['height'], 'gd', false);
         }
         imageJPEG($img, $cacheFileName, org_glizy_Config::get('JPG_COMPRESSION'));
         imageDestroy($objImg);
         imageDestroy($img);
         unset($objImg);
         unset($img);
         @touch($cacheFileName, filemtime($this->getFileName()));
         @chmod($cacheFileName, 0777);
         $retInfo = array('imageType' => IMG_JPG, 'fileName' => $cacheFileName, 'width' => $crop ? $width : $finalSizes['width'], 'height' => $crop ? $height : $finalSizes['height'], 'originalWidth' => $originalSizes['width'], 'originalHeight' => $originalSizes['height']);
     } else {
         $fileName = org_glizy_Assets::get('ICON_MEDIA_IMAGE');
         list($width, $height, $imagetypes) = getImageSize($fileName);
         $retInfo = array('imageType' => IMG_GIF, 'fileName' => $fileName, 'width' => $width, 'height' => $height, 'originalWidth' => $width, 'originalHeight' => $height);
     }
     return $retInfo;
 }
开发者ID:GruppoMeta,项目名称:Movio,代码行数:62,代码来源:Image.php

示例15: init_watermark

 function init_watermark($sWatermarkFilename, $hPosition = 'right', $vPosition = 'bottom', $edgePadding = 15, $bMakeSourceWatermark = true)
 {
     $size = getimagesize($sWatermarkFilename);
     switch ($size[2]) {
         case IMAGETYPE_GIF:
             $this->img["wm"] = imageCreateFromGIF($sWatermarkFilename);
             break;
         case IMAGETYPE_JPEG:
             $this->img["wm"] = imageCreateFromJPEG($sWatermarkFilename);
             break;
         case IMAGETYPE_PNG:
             $this->img["wm"] = imageCreateFromPNG($sWatermarkFilename);
             break;
         case IMAGETYPE_WBMP:
             $this->img["wm"] = imageCreateFromWBMP($sWatermarkFilename);
             break;
         default:
             return;
     }
     $this->img["wm_width"] = $size[0];
     $this->img["wm_height"] = $size[1];
     $this->img["wm_h_pos"] = $hPosition;
     $this->img["wm_v_pos"] = $vPosition;
     $this->img["wm_padding"] = $edgePadding;
     //накладываем watermark на файл ($this->sSourcePath2file)
     //на тот случай если bSaveAsOriginal (тогда оригинал уже будет с watermark)
     if ($bMakeSourceWatermark) {
         $this->img["only_src"] = imageCreateTrueColor($this->img["width"], $this->img["height"]);
         ImageCopy($this->img["only_src"], $this->img["src"], 0, 0, 0, 0, $this->img["width"], $this->img["height"]);
         $this->make_watermark("only_src", $this->img["width"], $this->img["height"]);
         switch ($this->img['format']) {
             case IMAGETYPE_GIF:
                 imageGIF($this->img["only_src"], $this->sSourcePath2file);
                 break;
             case IMAGETYPE_JPEG:
                 imageJPEG($this->img["only_src"], $this->sSourcePath2file, $this->img["quality"]);
                 break;
             case IMAGETYPE_PNG:
                 imagePNG($this->img["only_src"], $this->sSourcePath2file);
                 break;
             case IMAGETYPE_WBMP:
                 imageWBMP($this->img["only_src"], $this->sSourcePath2file);
                 break;
         }
         imageDestroy($this->img["only_src"]);
     }
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:47,代码来源:thumbnail.php


注:本文中的imageCreateFromWBMP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。