Hirdetés
- Milyen videókártyát?
- Intel Core i5 / i7 / i9 "Alder Lake-Raptor Lake/Refresh" (LGA1700)
- Fejhallgató erősítő és DAC topik
- Épített vízhűtés (nem kompakt) topic
- Amlogic S905, S912 processzoros készülékek
- Gaming notebook topik
- Fujifilm X
- Hisense LCD és LED TV-k
- LG LCD és LED TV-k
- Milyen notebookot vegyek?
Ú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
- HP EliteBook 640 G10 i5-1335U 16GB RAM 256GB SSD FHD 1 év gyári helyszíni garancia
- Lenovo ThinkPad P14s Ryzen 5 PRO 32GB RAM 512GB SSD 4GB dedikált VGA Érintőkijelző
- Eladó Apple MacBook Air M2 (2022) hibátlan, magyar billentyűzet, csak külső monitorral használt!
- Eladó Apple iPhone 11 128 GB hibátlan állapot + Apple Care Plusz!
- LENOVO Legion Pro 5 16IRX8 - 16" WQXGA 240Hz - i5-13500HX - 16GB - 1TB - RTX 4060 - 9 Hó garancia
- Apple iPhone 15Pro 128GB Kártyafüggetlen 1Év Garanciával
- Bomba ár! HP EliteBook 830 G5 - i5-8G I 8GB I 256GB SSD I 13,3" FHD I HDMI I Cam I W11 I Gari!
- Eredeti Lenovo 300W töltők - ADL300SDC3A
- ÁRGARANCIA!Épített KomPhone i5 13400F 16/32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
- BESZÁMÍTÁS! Asus H310M i3 9100F 16GB DDR4 120GB SSD 500GB HDD GTX 970 4GB Zalman ZM-T7 FSP 400W
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest