אני מנסה להפוך תמונה בצורה אופקית עם GD אבל תמיד כשיש רקע שקוף זה עושה לי בעיות,הנה הפונקציה שאני משתמש בה כדי להפוך את התמונה:
PHP קוד:
function flipHorizontal(&$img) {
$size_x = imagesx($img);
$size_y = imagesy($img);
$temp = imagecreatetruecolor($size_x, $size_y);
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
if ($x) {
$img = $temp;
}
else {
die("לא ניתן להפוך את התמונה ".$file);
}
}
והנה הקוד שבעזרתו אני קורא לפונקציה:
PHP קוד:
preg_match('/\.([a-zA-Z]+)$/',$file,$x);
$x = $x[1];
if($x == 'png'){
$myimage = imagecreatefrompng($file);
} elseif($x == 'gif'){
$myimage = imagecreatefromgif($file);
} elseif($x == 'jpg' || $x == 'jpeg'){
$myimage = imagecreatefromjpeg($file);
} else exit;
if(isset($_POST[md5($file)])){
flipHorizontal($myimage);
}
if($x == 'png'){
imagepng($myimage,'new'.$file);
} elseif($x == 'gif'){
imagegif($myimage,'new'.$file);
} elseif($x == 'jpg' || $x == 'jpeg'){
imagejpeg($myimage,'new'.$file);
} else exit;
אני שובר את הראש כבר שעות ולא מצליח,אז אם מישהו יודע איך לסדר את זה(וכן,חיפשתי פתרונות בגוגל וניסית imagesavealpha וכל מיני שיטות ולא עבד לי)
תודה לעוזרים