Ben bir yöntem bir kullanıcı görüntüleri uplaod edecek, birçok fotoğraf işlemlerini yapan bir sınıf oluşturmak için çalışıyorum ama ben de bir URL'den bir fotoğraf kapmak ve üzerinde diğer yöntemleri çalıştırmak için bir yöntem kurmak gerek duyuyorum sadece tarih ediliyordu eğer gibi kullanıcıdan gelen bir POST form ile.
Aşağıdaki URL'den görüntü almak için işlevi benim başlangıç, çalışıyor ama hala çalışmak gerekir. Kod Aşağıda bu fonksiyon varlık koştu sonucu olan bir resim görebilirsiniz. Ayrıca ne gibi görünmelidir görmek için orijinal görüntü. Bu işlev görüntü bu saydam görüntü üzerinde siyah bir arka plan var yapan görebilirsiniz. Onu nasıl görünmelidir gibi daha iyi görünmesi caqn?
$url = 'http://a0.twimg.com/a/1262802780/images/twitter_logo_header.png';
//run our function
savePhotofromURL($url, 'no');
// photo function should grab an photo from a URL
function savePhotofromURL($photo_url, $saveimage = 'yes'){
if(isset($photo_url) && $photo_url != '') {
//get info about photo
$photo_info = getimagesize($photo_url);
$source_width = $photo_info['0'];
$source_height = $photo_info['1'];
$source_type = $photo_info['mime'];
//grab the Photo from URL
$photo = imagecreatefromstring(file_get_contents($photo_url));
if (is_resource($photo) === true){
if($saveimage === 'yes'){
// TO DO: resize image and make the thumbs code would go here if we are saving image:
// TO DO: resize source image if it is wider then 800 pixels
// TO DO: make 1 thumbnail that is 150 pixels wide
}else{
// We are not saving the image show it in the user's browser
// TO DO: we will add in correct photo type soon
header('Content-Type: image/gif');
imagejpeg($photo, null, 100);
imagedestroy($photo);
}
}else{
// not a valid resource, show error
echo 'error getting URL photo from ' .$photo_url;
}
}else{
// url of image was empty
echo 'The URL was not passed into our funtion';
}
}
The result looks like this
Instead of like this