本文整理汇总了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}");
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}