天天看點

thinkphp 縮略圖制作實作

php 縮略圖生成的底層函數

imagecreatefromjpeg()

imagecreatefrompng()

imagecreatetruecolor()

imagecopyresampled()

執行個體化對象

打開已有圖檔

調用thumb方法

儲存圖檔到伺服器

制作縮略圖

$im=new \Think\Image();

$im->open('原圖路徑');

$im->thumb('縮略圖寬度','縮略圖高度');

$im->save('縮略圖保持路徑');

$_POST['goods_big_img']=ltrim($bigimg,'./');

$_POST['goods_small_img']=ltrim($smallimg,'./');

//入庫的邏輯

get_defined_constants(true);  //列印目前頁面的所有常量