- Hivatalos a OnePlus 13 startdátuma
- iPhone topik
- Milyen okostelefont vegyek?
- Samsung Galaxy S23 Ultra - non plus ultra
- A mostaninál szélesebb Foldon dolgozhat a Samsung
- Yettel topik
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Samsung Galaxy S24 - nos, Exynos
- Garmin Forerunner 965 - csúcs
- Samsung Galaxy Watch4 és Watch4 Classic - próbawearzió
Új hozzászólás Aktív témák
-
Speeedfire
félisten
Van egy ilyen kódom, fura dolog van vele. Ha directbe megadom neki a képet (teszt.jpg), akkor okés, de ha már egy teltöltött kép tmp_name az értéke, akkor kiírja, hogy unsupported, holott a getimagesize() ugyan azokat az értékeket dobja vissza.
public function img_resize($src, $dst, $width, $height, $crop=0){
if(!list($w, $h) = getimagesize($src)) return "Unsupported picture type!";
$type = strtolower(substr(strrchr($src,"."),1));
if($type == 'jpeg') $type = 'jpg';
switch($type){
case 'bmp': $img = imagecreatefromwbmp($src); break;
case 'gif': $img = imagecreatefromgif($src); break;
case 'jpg': $img = imagecreatefromjpeg($src); break;
case 'png': $img = imagecreatefrompng($src); break;
default : return "Unsupported picture type!";
}
// resize
if($crop){
if($w < $width or $h < $height) return "Picture is too small!";
$ratio = max($width/$w, $height/$h);
$h = $height / $ratio;
$x = ($w - $width / $ratio) / 2;
$w = $width / $ratio;
}
else{
if($w < $width and $h < $height) return "Picture is too small!";
$ratio = min($width/$w, $height/$h);
$width = $w * $ratio;
$height = $h * $ratio;
$x = 0;
}
$new = imagecreatetruecolor($width, $height);
// preserve transparency
if($type == "gif" or $type == "png"){
imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
imagealphablending($new, false);
imagesavealpha($new, true);
}
imagecopyresampled($new, $img, 0, 0, $x, 0, $width, $height, $w, $h);
switch($type){
case 'bmp': imagewbmp($new, $dst); break;
case 'gif': imagegif($new, $dst); break;
case 'jpg': imagejpeg($new, $dst); break;
case 'png': imagepng($new, $dst); break;
}
return true;
}
Új hozzászólás Aktív témák
- GYÖNYÖRŰ iPhone 15 Pro Max 512GB Blue Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS4089
- GYÖNYÖRŰ iPhone 14 128GB Starlight -1 ÉV GARANCIA -Kártyafüggetlen, MS3677
- Apple iPhone 13 128GB, Kártyafüggetlen, 1 Év Garanciával
- Jabra Speak2 75 MS Teams USB-bluetooth hangszóró
- iPhone 12 64GB 100% (1év Garancia)
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: BroadBit Hungary Kft.
Város: Budakeszi


