本文整理汇总了PHP中imageSX函数的典型用法代码示例。如果您正苦于以下问题:PHP imageSX函数的具体用法?PHP imageSX怎么用?PHP imageSX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageSX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: malaslika
function malaslika($name, $filename, $new_w, $new_h)
{
$system = explode('.', $name);
if (preg_match('/jpg|jpeg/i', $system[1])) {
$src_img = imagecreatefromjpeg($name);
}
if (preg_match('/png/i', $system[1])) {
$src_img = imagecreatefrompng($name);
}
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w = $new_w;
$thumb_h = $old_y * ($new_h / $old_x);
}
if ($old_x < $old_y) {
$thumb_w = $old_x * ($new_w / $old_y);
$thumb_h = $new_h;
}
if ($old_x == $old_y) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
$dst_img = imagecreatetruecolor($thumb_w, $thumb_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
if (preg_match("/png/i", $system[1])) {
imagepng($dst_img, $filename);
} else {
imagejpeg($dst_img, $filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
示例2: imgSize
private function imgSize()
{
if (!$this->error) {
$this->img_heigth = imageSY($this->img);
$this->img_width = imageSX($this->img);
}
}
示例3: createLogo
function createLogo($name, $filename, $new_w, $new_h)
{
$system = explode(".", $name);
if (preg_match("/jpg|jpeg/", $system[1])) {
$src_img = imagecreatefromjpeg($name);
}
if (preg_match("/png/", $system[1])) {
$src_img = imagecreatefrompng($name);
}
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x == $new_w) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
if ($old_x > $new_w) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
if ($old_x < $new_w) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 10, 0, $thumb_w, $thumb_h, $new_w, $new_h);
if (preg_match("/png/", $system[1])) {
imagepng($dst_img, $filename);
} else {
imagejpeg($dst_img, $filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
示例4: createthumb
function createthumb($originalImage, $newName, $new_w, $new_h)
{
$src_img = imagecreatefromjpeg($originalImage);
$newName .= ".jpg";
# Maintain proportions
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w = $new_w;
$thumb_h = $old_y * ($new_h / $old_x);
}
if ($old_x < $old_y) {
$thumb_w = $old_x * ($new_w / $old_y);
$thumb_h = $new_h;
}
if ($old_x == $old_y) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
# Create destination-image-resource
$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
# Copy source-image-resource to destination-image-resource
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
# Create the final image from the destination-image-resource
imagejpeg($dst_img, $newName);
# Delete our image-resources
imagedestroy($dst_img);
imagedestroy($src_img);
# Show results
return $newName;
}
示例5: resize
function resize($src, $dest, $new_width, $new_height)
{
if (!file_exists($src)) {
die('No source to sample picture: ' . $src);
}
$image_big = ImageCreateFromJpeg($src);
$height = imageSY($image_big);
$width = imageSX($image_big);
$ratio_hor = 1;
$ratio_ver = 1;
if ($height > $new_height) {
$ratio_ver = $new_height / $height;
}
if ($width > $new_width) {
$ratio_hor = $new_width / $width;
}
$ratio = min($ratio_hor, $ratio_ver);
$new_height = round($height * $ratio);
$new_width = round($width * $ratio);
$image_redim = imagecreatetruecolor($new_width, $new_height);
#l'apercu de l'image (plus petite)
imagecopyresampled($image_redim, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_redim, $dest, IMAGE_REDUCED_QUALITY);
#ecrit l'apercu sur le disque
}
示例6: addWatermark
/**
* function addWatermark
*
* @param string $imageFile
* @param string $destinationFile
*/
function addWatermark($imageFile, $destinationFile = true)
{
if ($destinationFile) {
$destinationFile = $imageFile;
}
$watermark = @imagecreatefrompng($this->watermarkFile) or exit('Cannot open the watermark file.');
imageAlphaBlending($watermark, false);
imageSaveAlpha($watermark, true);
$image_string = @file_get_contents($imageFile) or exit('Cannot open image file.');
$image = @imagecreatefromstring($image_string) or exit('Not a valid image format.');
$imageWidth = imageSX($image);
$imageHeight = imageSY($image);
$watermarkWidth = imageSX($watermark);
$watermarkHeight = imageSY($watermark);
if ($this->position == 'center') {
$coordinate_X = ($imageWidth - $watermarkWidth) / 2;
$coordinate_Y = ($imageHeight - $watermarkHeight) / 2;
} else {
$coordinate_X = $imageWidth - 5 - $watermarkWidth;
$coordinate_Y = $imageHeight - 5 - $watermarkHeight;
}
imagecopy($image, $watermark, $coordinate_X, $coordinate_Y, 0, 0, $watermarkWidth, $watermarkHeight);
if ($this->imageType == 'jpg') {
imagejpeg($image, $destinationFile, 100);
} elseif ($this->imageType == 'gif') {
imagegif($image, $destinationFile);
} elseif ($this->imageType == 'png') {
imagepng($image, $destinationFile, 100);
}
imagedestroy($image);
imagedestroy($watermark);
}
示例7: createImage
function createImage($name, $filename, $new_w, $new_h)
{
$system2 = explode('.', strtolower(basename($filename)));
$system2[1] = $system2[1];
$src_img = imagecreatefromstring(readFileData($name));
$old_w = imageSX($src_img);
$old_h = imageSY($src_img);
$thumb_w = $new_w;
$thumb_h = $new_h;
if ($new_w > $old_w) {
$thumb_w = $old_w;
$thumb_h = $thumb_w / $old_w * $old_h;
} else {
$thumb_w = $new_w;
$thumb_h = $thumb_w / $old_w * $old_h;
}
if ($thumb_h > $new_h) {
$thumb_h = $new_h;
$thumb_w = $thumb_h / $old_h * $old_w;
}
$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
imagealphablending($dst_img, false);
imagesavealpha($dst_img, true);
$transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
imagefilledrectangle($dst_img, 0, 0, $thumb_w, $thumb_h, $transparent);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h);
if (preg_match("/png/", $system2[1])) {
imagepng($dst_img, $filename);
} else {
imagejpeg($dst_img, $filename, 90);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
示例8: imageResize
function imageResize($file, $info, $destination)
{
$height = $info[1];
//высота
$width = $info[0];
//ширина
//определяем размеры будущего превью
$y = 150;
if ($width > $height) {
$x = $y * ($width / $height);
} else {
$x = $y / ($height / $width);
}
$to = imageCreateTrueColor($x, $y);
switch ($info['mime']) {
case 'image/jpeg':
$from = imageCreateFromJpeg($file);
break;
case 'image/png':
$from = imageCreateFromPng($file);
break;
case 'image/gif':
$from = imageCreateFromGif($file);
break;
default:
echo "No prevue";
break;
}
imageCopyResampled($to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to), imageSX($from), imageSY($from));
imagepng($to, $destination);
imagedestroy($from);
imagedestroy($to);
}
示例9: ImageResize
function ImageResize($fupload_name, $from_dir, $to_dir, $resize)
{
//direktori gambar
$vdir_upload = $from_dir;
$vfile_upload = $vdir_upload . $fupload_name;
//Simpan gambar dalam ukuran sebenarnya
move_uploaded_file($_FILES["fupload"]["tmp_name"], $vfile_upload);
//identitas file asli
$im_src = imagecreatefromjpeg($vfile_upload);
$src_width = imageSX($im_src);
$src_height = imageSY($im_src);
//Simpan dalam versi small 350 pixel
//Set ukuran gambar hasil perubahan
$dst_width = $resize;
//perubahan ukuran gambar
$dst_height = $dst_width / $src_width * $src_height;
//proses perubahan ukuran
$im = imagecreatetruecolor($dst_width, $dst_height);
imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
//Simpan gambar
imagejpeg($im, $to_dir . "small_" . $fupload_name);
//Hapus gambar di memori komputer
imagedestroy($im_src);
imagedestroy($im);
}
示例10: resize_image_crop
function resize_image_crop($src_image, $width, $height)
{
$src_width = imageSX($src_image);
$src_height = imageSY($src_image);
$width = $width <= 0 ? $src_width : $width;
$height = $height <= 0 ? $src_height : $height;
$prop_width = $src_width / $width;
$prop_height = $src_height / $height;
if ($prop_height > $prop_width) {
$crop_width = $src_width;
$crop_height = round($prop_width * $height);
$srcX = 0;
$srcY = round($src_height / 2) - round($crop_height / 2);
} else {
$crop_width = round($prop_height * $width);
$crop_height = $src_height;
$srcX = round($src_width / 2) - round($crop_width / 2);
$srcY = 0;
}
$new_image = imageCreateTrueColor($width, $height);
$tmp_image = imageCreateTrueColor($crop_width, $crop_height);
imageCopy($tmp_image, $src_image, 0, 0, $srcX, $srcY, $crop_width, $crop_height);
imageCopyResampled($new_image, $tmp_image, 0, 0, 0, 0, $width, $height, $crop_width, $crop_height);
imagedestroy($tmp_image);
image_unsharp_mask($new_image);
return $new_image;
}
示例11: UploadImage
function UploadImage($fupload_name)
{
//direktori gambar
$vdir_upload = "../../image/";
$vfile_upload = $vdir_upload . $fupload_name;
//Simpan gambar dalam ukuran sebenarnya
move_uploaded_file($_FILES["file"]["tmp_name"], $vfile_upload);
//identitas file asli
$tipe_file = $_FILES['file']['type'];
if ($tipe_file == "image/png") {
$im_src = imagecreatefrompng($vfile_upload);
} else {
if ($tipe_file == "image/jpeg") {
$im_src = imagecreatefromjpeg($vfile_upload);
}
}
$src_width = imageSX($im_src);
$src_height = imageSY($im_src);
//Simpan dalam versi small 110 pixel
//Set ukuran gambar hasil perubahan
$small_width = 50;
$small_height = $small_width / $src_width * $src_height;
//proses perubahan ukuran
$im = imagecreatetruecolor($small_width, $small_height);
imagecopyresampled($im, $im_src, 0, 0, 0, 0, $small_width, $small_height, $src_width, $src_height);
//Simpan gambar
imagejpeg($im, $vdir_upload . "ttd_" . $fupload_name);
//Hapus gambar di memori komputer
imagedestroy($im_src);
imagedestroy($im);
unlink($vdir_upload . "" . $fupload_name);
}
示例12: createImage
public function createImage($text = '', $fontSize = 5)
{
// GD's built-in fonts are numbered from 1 - 5
$font_size = $fontSize;
// Calculate the appropriate image size
$image_height = intval(imageFontHeight($font_size) * 2);
$image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
// Create the image
$image = imageCreate($image_width, $image_height);
// Create the colors to use in the image
// gray background
$back_color = imageColorAllocate($image, 216, 216, 216);
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
$y = ($image_height - imageFontHeight($font_size)) / 2;
// Draw the text
imageString($image, $font_size, $x, $y, $text, $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
}
示例13: run
public function run($file)
{
$res = $this->open_image($file);
if ($res != TRUE) {
return FALSE;
}
$this->image_progressive = isset($this->settings['field_settings']['progressive_jpeg']) === TRUE && $this->settings['field_settings']['progressive_jpeg'] == 'yes' ? TRUE : FALSE;
if (function_exists('imagefilter') === TRUE) {
@imagefilter($this->EE->channel_images->image, IMG_FILTER_GRAYSCALE);
} else {
$img_width = imageSX($this->EE->channel_images->image);
$img_height = imageSY($this->EE->channel_images->image);
// convert to grayscale
$palette = array();
for ($c = 0; $c < 256; $c++) {
$palette[$c] = imagecolorallocate($this->EE->channel_images->image, $c, $c, $c);
}
for ($y = 0; $y < $img_height; $y++) {
for ($x = 0; $x < $img_width; $x++) {
$rgb = imagecolorat($this->EE->channel_images->image, $x, $y);
$r = $rgb >> 16 & 0xff;
$g = $rgb >> 8 & 0xff;
$b = $rgb & 0xff;
$gs = $r * 0.299 + $g * 0.587 + $b * 0.114;
imagesetpixel($this->EE->channel_images->image, $x, $y, $palette[$gs]);
}
}
}
$this->save_image($file);
return TRUE;
}
示例14: imagecreator
function imagecreator($filename)
{
$nx = 16;
$ny = 8;
$zoom = 4;
$im = imageCreateFromJpeg("uploads/" . $filename);
$temp_dir = "dir_{$filename}";
mkdir("uploads/" . $temp_dir, 0744);
$temp_dir = "uploads/" . $temp_dir;
//return;
$imSX = imageSX($im);
$imSY = imageSY($im);
$kusokX = $imSX / $nx;
$kusokY = $imSY / $ny;
for ($k = 0; $k < $ny; $k++) {
for ($i = 0; $i < $nx; $i++) {
$im2 = imagecreatetruecolor(512, 512);
imagecopyresized($im2, $im, 0, 0, $i * $kusokX, $k * $kusokY, 512, 512, $kusokX, $kusokY);
//imageInterlace($im2, 1);
imagejpeg($im2, "{$temp_dir}/" . "1_{$zoom}_{$i}_{$k}_.jpeg", 90);
$im2 = null;
}
}
$factor = 2;
$zoom = $zoom - 1;
for ($k = 0; $k < $ny / $factor; $k++) {
for ($i = 0; $i < $nx / $factor; $i++) {
$im2 = imagecreatetruecolor(512, 512);
imagecopyresized($im2, $im, 0, 0, $i * $kusokX * $factor, $k * $kusokY * $factor, 512, 512, $kusokX * $factor, $kusokY * $factor);
//imageInterlace($im2, 1);
imagejpeg($im2, "{$temp_dir}/" . "1_{$zoom}_{$i}_{$k}_.jpeg", 90);
$im2 = null;
}
}
$factor = 4;
$zoom = $zoom - 1;
for ($k = 0; $k < $ny / $factor; $k++) {
for ($i = 0; $i < $nx / $factor; $i++) {
$im2 = imagecreatetruecolor(512, 512);
imagecopyresized($im2, $im, 0, 0, $i * $kusokX * $factor, $k * $kusokY * $factor, 512, 512, $kusokX * $factor, $kusokY * $factor);
//imageInterlace($im2, 1);
imagejpeg($im2, "{$temp_dir}/" . "1_{$zoom}_{$i}_{$k}_.jpeg", 90);
$im2 = null;
}
}
$factor = 8;
$zoom = $zoom - 1;
for ($k = 0; $k < $ny / $factor; $k++) {
for ($i = 0; $i < $nx / $factor; $i++) {
$im2 = imagecreatetruecolor(512, 512);
imagecopyresized($im2, $im, 0, 0, $i * $kusokX * $factor, $k * $kusokY * $factor, 512, 512, $kusokX * $factor, $kusokY * $factor);
//imageInterlace($im2, 1);
imagejpeg($im2, "{$temp_dir}/" . "1_{$zoom}_{$i}_{$k}_.jpeg", 90);
$im2 = null;
}
}
$im2 = imagecreatetruecolor(512, 512);
imagecopyresized($im2, $im, 0, 0, 0, 0, 512, 256, $imSX, $imSY);
imagejpeg($im2, "{$temp_dir}/" . "1_0_0_0_.jpeg", 90);
}
示例15: createthumb
function createthumb($name, $filename, $new_w, $new_h)
{
$extention = pathinfo($name, PATHINFO_EXTENSION);
if (preg_match('/jpg|jpeg/', $extention)) {
$src_img = imagecreatefromjpeg($name);
}
if (preg_match('/png/', $extention)) {
$src_img = imagecreatefrompng($name);
}
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w = $new_w;
$thumb_h = $old_y * ($new_h / $old_x);
}
if ($old_x < $old_y) {
$thumb_w = $old_x * ($new_w / $old_y);
$thumb_h = $new_h;
}
if ($old_x == $old_y) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
if (preg_match("/png/", $extention)) {
imagepng($dst_img, $filename);
} else {
imagejpeg($dst_img, $filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}