當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImageSX函數代碼示例

本文整理匯總了PHP中ImageSX函數的典型用法代碼示例。如果您正苦於以下問題:PHP ImageSX函數的具體用法?PHP ImageSX怎麽用?PHP ImageSX使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ImageSX函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: kicsinyites

function kicsinyites($forras, $kimenet, $max)
{
    if (!isset($max)) {
        $max = 120;
    }
    # maximum size of 1 side of the picture.
    $src_img = ImagecreateFromJpeg($forras);
    $oh = imagesy($src_img);
    # original height
    $ow = imagesx($src_img);
    # original width
    $new_h = $oh;
    $new_w = $ow;
    if ($oh > $max || $ow > $max) {
        $r = $oh / $ow;
        $new_h = $oh > $ow ? $max : $max * $r;
        $new_w = $new_h / $r;
    }
    // note TrueColor does 256 and not.. 8
    $dst_img = ImageCreateTrueColor($new_w, $new_h);
    /* imageantialias($dst_img, true); */
    /* ImageCopyResized($dst_img, $src_img, 0,0,0,0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img)); */
    ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img));
    ImageJpeg($dst_img, "{$kimenet}");
}
開發者ID:kolesar-andras,項目名稱:miserend.hu,代碼行數:25,代碼來源:functions.php

示例2: ResizeWidthHeight

function ResizeWidthHeight($picture, $smallfile, $rewidth, $reheight)
{
    $picsize = getimagesize($picture);
    if ($picsize[2] == 1) {
        //@header("Content-Type: imgage/gif");
        $dstimg = ImageCreatetruecolor($rewidth, $reheight);
        $srcimg = @ImageCreateFromGIF($picture);
        ImageCopyResized($dstimg, $srcimg, 0, 0, 0, 0, $rewidth, $reheight, ImageSX($srcimg), ImageSY($srcimg));
        Imagegif($dstimg, $smallfile, 100);
    } elseif ($picsize[2] == 2) {
        //@header("Content-Type: images/jpeg");
        $dstimg = ImageCreatetruecolor($rewidth, $reheight);
        $srcimg = ImageCreateFromJPEG($picture);
        imagecopyresampled($dstimg, $srcimg, 0, 0, 0, 0, $rewidth, $reheight, ImageSX($srcimg), ImageSY($srcimg));
        Imagejpeg($dstimg, $smallfile, 100);
    } elseif ($picsize[2] == 3) {
        //@header("Content-Type: images/png");
        $srcimg = ImageCreateFromPNG($picture);
        $dstimg = imagecreate($rewidth, $reheight);
        $black = imagecolorallocate($dstimg, 0x0, 0x0, 0x0);
        $white = imagecolorallocate($dstimg, 0xff, 0xff, 0xff);
        $magenta = imagecolorallocate($dstimg, 0xff, 0x0, 0xff);
        imagecolortransparent($dstimg, $black);
        imagecopyresampled($dstimg, $srcimg, 0, 0, 0, 0, $rewidth, $reheight, ImageSX($srcimg), ImageSY($srcimg));
        Imagepng($dstimg, $smallfile, 0);
    }
    @ImageDestroy($dstimg);
    @ImageDestroy($srcimg);
}
開發者ID:eosliebe,項目名稱:rb,代碼行數:29,代碼來源:thumb.func.php

示例3: __construct

 public function __construct($cSym)
 {
     switch (strlen($cSym)) {
         case 3:
             $this->base = $cSym;
             $this->key = base2view($cSym);
             $this->bsw = key2bsw($this->key);
             break;
         case 5:
             $this->base = substr($cSym, 0, 3);
             $this->key = $cSym;
             $this->bsw = key2bsw($this->key);
             break;
         case 9:
             $this->base = substr($cSym, 0, 3);
             $this->key = bsw2key($cSym);
             $this->bsw = $cSym;
             break;
     }
     $this->png = key2png($this->key);
     $img = imagecreatefromstring($this->png);
     $this->width = ImageSX($img);
     $this->height = ImageSY($img);
     $this->centerX = ImageSX($img) / 2;
     $this->centerY = ImageSY($img) / 2;
     imagedestroy($img);
 }
開發者ID:alanpost,項目名稱:lodockikumazvati_www,代碼行數:27,代碼來源:swclasses.php

示例4: __construct

 /**
  * Loads image source and its properties to the instanciated object
  *
  * @param string $filename
  * @return ImageResize
  * @throws \Exception
  */
 public function __construct($filename)
 {
     $image_info = @getimagesize($filename);
     if (!$image_info) {
         throw new \Exception('Could not read file');
     }
     list($this->original_w, $this->original_h, $this->source_type) = $image_info;
     switch ($this->source_type) {
         case IMAGETYPE_GIF:
             $this->source_image = imagecreatefromgif($filename);
             break;
         case IMAGETYPE_JPEG:
             $this->source_image = $this->imageCreateJpegfromExif($filename);
             // set new width and height for image, maybe it has changed
             $this->original_w = ImageSX($this->source_image);
             $this->original_h = ImageSY($this->source_image);
             break;
         case IMAGETYPE_PNG:
             $this->source_image = imagecreatefrompng($filename);
             break;
         default:
             throw new \Exception('Unsupported image type');
             break;
     }
     return $this->resize($this->getSourceWidth(), $this->getSourceHeight());
 }
開發者ID:saschanos,項目名稱:php-image-resize,代碼行數:33,代碼來源:ImageResize.php

示例5: getimagesize_remote

function getimagesize_remote($image_url)
{
    if (($handle = @fopen($image_url, "rb")) != true) {
        return;
    }
    $contents = "";
    $count = 0;
    if ($handle) {
        do {
            $count += 1;
            $data = fread($handle, 8192);
            if (strlen($data) == 0) {
                break;
            }
            $contents .= $data;
        } while (true);
    } else {
        return false;
    }
    fclose($handle);
    $im = ImageCreateFromString($contents);
    if (!$im) {
        return false;
    }
    $gis[0] = ImageSX($im);
    $gis[1] = ImageSY($im);
    // array member 3 is used below to keep with current getimagesize standards
    $gis[3] = "width={$gis[0]} height={$gis[1]}";
    ImageDestroy($im);
    return $gis;
}
開發者ID:startrekfinalfrontier,項目名稱:UI,代碼行數:31,代碼來源:stats.php

示例6: makeThumb1

 /**
  * 把圖片生成縮略圖1
  * @param string $srcFile	源文件			
  * @param string $dstFile	目標文件
  * @param int $dstW		目標圖片寬度		
  * @param int $dstH		目標文件高度
  * @param string $dstFormat	目標文件生成的格式, 有png和jpg兩種格式
  * @return 錯誤返回錯誤對象
  */
 public static function makeThumb1($srcFile, $dstFile, $dstW, $dstH, $dstFormat = "png")
 {
     //打開圖片
     $data = GetImageSize($srcFile, &$info);
     switch ($data[2]) {
         case 1:
             $im = @ImageCreateFromGIF($srcFile);
             break;
         case 2:
             $im = @imagecreatefromjpeg($srcFile);
             break;
         case 3:
             $im = @ImageCreateFromPNG($srcFile);
             break;
     }
     if (!$im) {
         throw new TM_Exception(__CLASS__ . ": Create image failed");
     }
     //設定圖片大小
     $srcW = ImageSX($im);
     $srcH = ImageSY($im);
     $ni = ImageCreate($dstW, $dstH);
     ImageCopyResized($ni, $im, 0, 0, 0, 0, $dstW, $dstH, $srcW, $srcH);
     //生成指定格式的圖片
     if ($dstFormat == "png") {
         imagepng($ni, $dstFile);
     } elseif ($dstFormat == "jpg") {
         ImageJpeg($ni, $dstFile);
     } else {
         imagepng($ni, $dstFile);
     }
 }
開發者ID:heiyeluren,項目名稱:tmphp,代碼行數:41,代碼來源:TM_Image.class.php

示例7: resize_image_gd

function resize_image_gd($src, $dest, $quality, $width, $height, $image_info)
{
    global $convert_options;
    $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
    if ($convert_options['convert_gd2']) {
        $thumb = imagecreatetruecolor($width, $height);
    } else {
        $thumb = imagecreate($width, $height);
    }
    $image_create_handle = "imagecreatefrom" . $types[$image_info[2]];
    if ($image = $image_create_handle($src)) {
        if ($convert_options['convert_gd2']) {
            imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
        } else {
            imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
        }
        if ($image_info[2] == 3) {
            $quality = 9;
        }
        $image_handle = "image" . $types[$image_info[2]];
        $image_handle($thumb, $dest, $quality);
        imagedestroy($image);
        imagedestroy($thumb);
    }
    return file_exists($dest) ? 1 : 0;
}
開發者ID:abhinay100,項目名稱:fourimages_app,代碼行數:26,代碼來源:image_utils.php

示例8: saveFile

 /**
  * Saves the specified file to the target directory.  File data and properties
  * are taken from an entry in the provided files array
  * 
  * @param array $filesArray
  * @param string $fileKey
  * @param string $destinationDir
  * @param string $destinationFile
  */
 public static function saveFile($filesArray, $fileKey, $destinationDir, $destinationFile)
 {
     if ($filesArray[$fileKey]["name"]) {
         if (!file_exists($destinationDir)) {
             mkdir($destinationDir);
         }
         $extension = self::getExtensionForMimeType($filesArray, $fileKey);
         $finalFile = $destinationDir . "/" . $destinationFile . "." . $extension;
         //$file = $upload_path;// . $new_cnt . "." . $extension;
         $result = move_uploaded_file($filesArray[$fileKey]["tmp_name"], $finalFile);
         // TODO update this for GIF, PNG, etc.
         if (self::isResizableImageType($extension)) {
             $ds = new dropShadow();
             // resize to 800 px wide IF this is a horizontal image (width > height)
             $ds->loadImage($finalFile);
             if (ImageSX($ds->_imgOrig) > ImageSY($ds->_imgOrig)) {
                 $ds->resizeToSize(800, 0);
             } else {
                 if (ImageSX($ds->_imgOrig) > 800) {
                     $ds->resizeToSize(800, 0);
                 }
             }
             $ds->saveFinal($finalFile);
         }
     }
 }
開發者ID:kirvin,項目名稱:the-nerdery,代碼行數:35,代碼來源:net.theirvins.nerdery.util.FileManager.php

示例9: SetVar

 function SetVar($srcFile, $echoType)
 {
     $this->srcFile = $srcFile;
     $this->echoType = $echoType;
     $info = '';
     $data = GetImageSize($this->srcFile, $info);
     switch ($data[2]) {
         case 1:
             if (!function_exists('imagecreatefromgif')) {
                 exit;
             }
             $this->im = ImageCreateFromGIF($this->srcFile);
             break;
         case 2:
             if (!function_exists('imagecreatefromjpeg')) {
                 exit;
             }
             $this->im = ImageCreateFromJpeg($this->srcFile);
             break;
         case 3:
             $this->im = ImageCreateFromPNG($this->srcFile);
             break;
     }
     $this->srcW = ImageSX($this->im);
     $this->srcH = ImageSY($this->im);
 }
開發者ID:badxchen,項目名稱:KODExplorer,代碼行數:26,代碼來源:imageThumb.class.php

示例10: SetVar

 function SetVar($srcFile, $echoType)
 {
     if (!file_exists($srcFile)) {
         echo '源圖片文件不存在!';
         exit;
     }
     $this->srcFile = $srcFile;
     $this->echoType = $echoType;
     $info = "";
     $data = GetImageSize($this->srcFile, $info);
     switch ($data[2]) {
         case 1:
             if (!function_exists("imagecreatefromgif")) {
                 echo "你的GD庫不能使用GIF格式的圖片,請使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
                 exit;
             }
             $this->im = ImageCreateFromGIF($this->srcFile);
             break;
         case 2:
             if (!function_exists("imagecreatefromjpeg")) {
                 echo "你的GD庫不能使用jpeg格式的圖片,請使用其它格式的圖片!<a href='javascript:go(-1);'>返回</a>";
                 exit;
             }
             $this->im = ImageCreateFromJpeg($this->srcFile);
             break;
         case 3:
             $this->im = ImageCreateFromPNG($this->srcFile);
             break;
     }
     $this->srcW = ImageSX($this->im);
     $this->srcH = ImageSY($this->im);
 }
開發者ID:sdgdsffdsfff,項目名稱:crm,代碼行數:32,代碼來源:re_dim_image.php

示例11: ImageResize

function ImageResize($srcFile, $toW, $toH, $toFile = "")
{
    if ($toFile == "") {
        $toFile = $srcFile;
    }
    $info = "";
    $data = GetImageSize($srcFile, $info);
    switch ($data[2]) {
        case 1:
            if (!function_exists("imagecreatefromgif")) {
                echo "你的GD庫不能使用GIF格式的圖片,請使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
                exit;
            }
            $im = ImageCreateFromGIF($srcFile);
            break;
        case 2:
            if (!function_exists("imagecreatefromjpeg")) {
                echo "你的GD庫不能使用jpeg格式的圖片,請使用其它格式的圖片!<a href='javascript:go(-1);'>返回</a>";
                exit;
            }
            $im = ImageCreateFromJpeg($srcFile);
            break;
        case 3:
            $im = ImageCreateFromPNG($srcFile);
            break;
    }
    $srcW = ImageSX($im);
    $srcH = ImageSY($im);
    $toWH = $toW / $toH;
    $srcWH = $srcW / $srcH;
    if ($toWH <= $srcWH) {
        $ftoW = $toW;
        $ftoH = $ftoW * ($srcH / $srcW);
    } else {
        $ftoH = $toH;
        $ftoW = $ftoH * ($srcW / $srcH);
    }
    if ($srcW > $toW || $srcH > $toH) {
        if (function_exists("imagecreatetruecolor")) {
            @($ni = ImageCreateTrueColor($ftoW, $ftoH));
            if ($ni) {
                ImageCopyResampled($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
            } else {
                $ni = ImageCreate($ftoW, $ftoH);
                ImageCopyResized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
            }
        } else {
            $ni = ImageCreate($ftoW, $ftoH);
            ImageCopyResized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
        }
        if (function_exists('imagejpeg')) {
            ImageJpeg($ni, $toFile);
        } else {
            ImagePNG($ni, $toFile);
        }
        ImageDestroy($ni);
    }
    ImageDestroy($im);
}
開發者ID:chaobj001,項目名稱:tt,代碼行數:59,代碼來源:PHP生成縮略圖.php

示例12: watermark

 function watermark($pngImage, $left = 0, $top = 0)
 {
     ImageAlphaBlending($this->image, true);
     $layer = ImageCreateFromPNG($pngImage);
     $logoW = ImageSX($layer);
     $logoH = ImageSY($layer);
     ImageCopy($this->image, $layer, $left, $top, 0, 0, $logoW, $logoH);
 }
開發者ID:centaurustech,項目名稱:BenFund,代碼行數:8,代碼來源:resize.php

示例13: convert

 /**
  * Convert a GD image into a BMP string representation
  * @param resource $gdimage is a GD image
  * @return type
  */
 public static function convert($gdimage = null)
 {
     self::loadImg($gdimage);
     if (!is_resource(self::$img)) {
         return '';
     }
     $imageX = ImageSX(self::$img);
     $imageY = ImageSY(self::$img);
     $bmp = '';
     for ($y = $imageY - 1; $y >= 0; $y--) {
         $thisline = '';
         for ($x = 0; $x < $imageX; $x++) {
             $argb = self::getPixelColor(self::$img, $x, $y);
             $thisline .= chr($argb['blue']) . chr($argb['green']) . chr($argb['red']);
         }
         while (strlen($thisline) % 4) {
             $thisline .= "";
         }
         $bmp .= $thisline;
     }
     $bmpSize = strlen($bmp) + 14 + 40;
     // bitMapHeader [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
     $bitMapHeader = 'BM';
     // WORD bfType;
     $bitMapHeader .= self::littleEndian2String($bmpSize, 4);
     // DWORD bfSize;
     $bitMapHeader .= self::littleEndian2String(0, 2);
     // WORD bfReserved1;
     $bitMapHeader .= self::littleEndian2String(0, 2);
     // WORD bfReserved2;
     $bitMapHeader .= self::littleEndian2String(54, 4);
     // DWORD bfOffBits;
     // bitMapInfoHeader - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
     $bitMapInfoHeader = self::littleEndian2String(40, 4);
     // DWORD biSize;
     $bitMapInfoHeader .= self::littleEndian2String($imageX, 4);
     // LONG biWidth;
     $bitMapInfoHeader .= self::littleEndian2String($imageY, 4);
     // LONG biHeight;
     $bitMapInfoHeader .= self::littleEndian2String(1, 2);
     // WORD biPlanes;
     $bitMapInfoHeader .= self::littleEndian2String(24, 2);
     // WORD biBitCount;
     $bitMapInfoHeader .= self::littleEndian2String(0, 4);
     // DWORD biCompression;
     $bitMapInfoHeader .= self::littleEndian2String(0, 4);
     // DWORD biSizeImage;
     $bitMapInfoHeader .= self::littleEndian2String(2835, 4);
     // LONG biXPelsPerMeter;
     $bitMapInfoHeader .= self::littleEndian2String(2835, 4);
     // LONG biYPelsPerMeter;
     $bitMapInfoHeader .= self::littleEndian2String(0, 4);
     // DWORD biClrUsed;
     $bitMapInfoHeader .= self::littleEndian2String(0, 4);
     // DWORD biClrImportant;
     return $bitMapHeader . $bitMapInfoHeader . $bmp;
 }
開發者ID:ristone,項目名稱:posprint,代碼行數:62,代碼來源:GdtoBMP.php

示例14: drawBorder

function drawBorder(&$img, &$color, $thickness = 1)
{
    $x1 = 0;
    $y1 = 0;
    $x2 = ImageSX($img) - 1;
    $y2 = ImageSY($img) - 1;
    for ($i = 0; $i < $thickness; $i++) {
        ImageRectangle($img, $x1++, $y1++, $x2--, $y2--, $color_black);
    }
}
開發者ID:Alexzo20,項目名稱:gesior-aac,代碼行數:10,代碼來源:generate.php

示例15: main

 function main($inFile)
 {
     $img = ImageCreateFromPNG($inFile);
     $width = ImageSX($img);
     $height = ImageSY($img);
     if ($width != 640 || $height != 960) {
         $resizedImg = ImageCreateTrueColor(640, 960);
         ImageCopyResampled($resizedImg, $img, 0, 0, 0, 0, 640, 960, $width, $height);
         $img = $resizedImg;
     }
     $this->extractAppInfo($img);
 }
開發者ID:kenmaz,項目名稱:www.kenmaz.net,代碼行數:12,代碼來源:resize.php


注:本文中的ImageSX函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。