日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php mvc urlencode,PHP – LIUGUOFENG

發布時間:2025/3/12 php 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php mvc urlencode,PHP – LIUGUOFENG 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/**

* @param $img 圖片地址

* @param string $width 寬

* @param string $height 高

* @param string $ratio 保持原比例

* @return string 生成的地址

*/

public function resize_fuc($img, $width, $height, $ratio)

{

$info = get_img_info($img);

$name = pathinfo($img)['filename'];

$dirname = pathinfo($img)['dirname'];

$ext = pathinfo($img)['extension'];

$im = NULL;

$type = strtolower($info['type']);

if (!in_array($type, ['jpg', 'jpeg', 'gif', 'png'])) {

return FALSE;

}

$type = ($type == 'jpg' ? 'jpeg' : $type);

$scale = $info['width'] / $info['height'];

if ($ratio == TRUE) {

$forScale = $width / $height;

$x = 0;

$y = 0;

if ($scale >= $forScale) {

$width = (int)($height * $scale);

$rate = $info['height']/$height;

} else {

$height = (int)($width / $scale);

$rate = $info['width']/$width;

}

} else {

$forScale = $width / $height;

if ($scale >= $forScale) {

$x = ($info['width'] - $info['height'] * $forScale) / 2;

$y = 0;

$rate = $info['height'] / $height;

} else {

$x = 0;

$y = ($info['height'] - $info['width'] / $forScale) / 2;

$rate = $info['width'] / $width;

}

}

if($width>$info['width'] || $height>$info['height']){

return;

}

$imageCreateFun = 'imagecreatefrom' . $type;

$im = $imageCreateFun($img);

$thumb = $dirname . '/' . $name . '_tmp' . "." . $ext;

$imageFun = 'image' . $type;

$imageFun($im, $thumb);

$thumbNew = imagecreatetruecolor($width, $height);

imagecopyresampled(

$thumbNew, $im,

0, 0, intval($x), intval($y),

intval($width * 1), intval($height * 1), intval($width * $rate), intval($height * $rate)

);

$imageFun($thumbNew, $thumb);

imagedestroy($im);

imagedestroy($thumbNew);

rename($thumb,$img);

return $img;

}

function get_img_info($img) {

if(!is_file($img) || !in_array(strtolower(pathinfo($img)['extension']),['jpg','jpeg','bmp','gif','png'])){

return false;

}

$img_info = getimagesize($img);

if ($img_info !== false) {

$img_type = strtolower(substr(image_type_to_extension($img_info[2]), 1));

$info = array("width" => $img_info[0], "height" => $img_info[1], "type" => $img_type, "mime" => $img_info['mime'], );

return $info;

} else {

return false;

}

}

總結

以上是生活随笔為你收集整理的php mvc urlencode,PHP – LIUGUOFENG的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。