PDA

View Full Version : سوال: imaging class



farshad_persia
چهارشنبه 23 بهمن 1387, 21:06 عصر
با سلام
می بخشید که این سوال رو میپرسم راستش تمام پکیجهای PEAR و PHP CLASSES رو گشتم ولی این چیزی که میخ.ام پیدا نکردم :اشتباه:
یک کلاس میخوام که این عکس رو
http://i43.tinypic.com/vnkzg4.jpg

به این عکس تبدیل کنه
http://i43.tinypic.com/2znocr9.jpg

یعنی دور اون رو Rounded یا همون (گرد) کنه

ممنون میشم اگر کسی میدونه کمک کنه :چشمک::لبخند:

yaqubian
پنج شنبه 24 بهمن 1387, 09:50 صبح
دوست عزیز
این بدردتون می خوره؟

<?php
$image_file = $_GET['src'];
$corner_radius = isset($_GET['radius']) ? $_GET['radius'] : 20; // The default corner radius is set to 20px
$angle = isset($_GET['angle']) ? $_GET['angle'] : 0; // The default angle is set to 0º
$topleft = (isset($_GET['topleft']) and $_GET['topleft'] == "no") ? false : true; // Top-left rounded corner is shown by default
$bottomleft = (isset($_GET['bottomleft']) and $_GET['bottomleft'] == "no") ? false : true; // Bottom-left rounded corner is shown by default
$bottomright = (isset($_GET['bottomright']) and $_GET['bottomright'] == "no") ? false : true; // Bottom-right rounded corner is shown by default
$topright = (isset($_GET['topright']) and $_GET['topright'] == "no") ? false : true; // Top-right rounded corner is shown by default

$images_dir = 'images/';
$corner_source = imagecreatefrompng('images/rounded_corner.png');

$corner_width = imagesx($corner_source);
$corner_height = imagesy($corner_source);
$corner_resized = ImageCreateTrueColor($corner_radius, $corner_radius);
ImageCopyResampled($corner_resized, $corner_source, 0, 0, 0, 0, $corner_radius, $corner_radius, $corner_width, $corner_height);

$corner_width = imagesx($corner_resized);
$corner_height = imagesy($corner_resized);
$image = imagecreatetruecolor($corner_width, $corner_height);
$image = imagecreatefromjpeg($images_dir . $image_file); // replace filename with $_GET['src']
$size = getimagesize($images_dir . $image_file); // replace filename with $_GET['src']
$white = ImageColorAllocate($image,255,255,255);
$black = ImageColorAllocate($image,0,0,0);

// Top-left corner
if ($topleft == true) {
$dest_x = 0;
$dest_y = 0;
imagecolortransparent($corner_resized, $black);
imagecopymerge($image, $corner_resized, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);
}

// Bottom-left corner
if ($bottomleft == true) {
$dest_x = 0;
$dest_y = $size[1] - $corner_height;
$rotated = imagerotate($corner_resized, 90, 0);
imagecolortransparent($rotated, $black);
imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);
}

// Bottom-right corner
if ($bottomright == true) {
$dest_x = $size[0] - $corner_width;
$dest_y = $size[1] - $corner_height;
$rotated = imagerotate($corner_resized, 180, 0);
imagecolortransparent($rotated, $black);
imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);
}

// Top-right corner
if ($topright == true) {
$dest_x = $size[0] - $corner_width;
$dest_y = 0;
$rotated = imagerotate($corner_resized, 270, 0);
imagecolortransparent($rotated, $black);
imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);
}

// Rotate image
$image = imagerotate($image, $angle, $white);

// Output final image
imagejpeg($image);

imagedestroy($image);
imagedestroy($corner_source);
?>
موفق باشید

farshad_persia
پنج شنبه 24 بهمن 1387, 14:47 عصر
آقا یه دنیا ممنون کار میکنه اما جالبه تو FireFox کدهای عجیب غریب میاره اما تو IE کاملا کار میکنه :قهقهه:
این لینک رو بیبنین
http://www.assemblysys.com/dataServices/roundedCorners.php?src=bunny.jpg&radius=40

:لبخند:
ولی استاد یعقوبیان ممنون و سپاسگزار باز هم از لطفتون

amirhosein
جمعه 25 بهمن 1387, 18:57 عصر
اينو (http://www.google.com/custom?domains=www.phpclasses.org&q=thumbnail%2Bwatermark&sa=Search&sitesearch=www.phpclasses.org&client=pub-2951707118576741&forid=1&channel=5742870948&ie=ISO-8859-1&oe=ISO-8859-1&cof=GALT%3A%23663399%3BGL%3A1%3BDIV%3A%23222222%3B VLC%3A663399%3BAH%3Acenter%3BBGC%3AA3C5CC%3BLBGC%3 AA3C5CC%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000% 3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BLH%3A50%3BLW%3A2 56%3BL%3Ahttp%3A%2F%2Ffiles.phpclasses.org%2Fgraph ics%2Fgooglesearch.jpg%3BS%3Ahttp%3A%2F%2Fwww.phpc lasses.org%2Fsearch.html%3BFORID%3A1%3B&hl=en)ببين يه هوا كد داره!