Форуми / Cotonti / Extensions / Playing with stylish/rounded thumbnails

rounded corners on thumbs

Elgan
#1 03.04.2009 10:29
Okei so today i didnt get much work on actual things done, spent pretty much all the day after work researching and getting to know GD a little more and playing about and breaking up with some girl again. so anyway: GD has alot of funcs , i wanted to get to know it a little more in deph. now im tired, angry, and dont care anymore , work int he morning and thought it would be nicer to just share and chat!

THe lil function below i use after after making a thumbnail to round the corners of it. Posting it here as its still WIP. You can see some outcomes here:







More here

As you may notice on some conflicting colours (ie my hat) it still tries to make it transparent on the blend? Any ideas?

Note, i do know jpegs etc dont have an alpha channel, and some of you with poor browsers may get some issues.


function round_thumbnail($path)
{
	$extension = get_extension($path);
	switch($extension)
	{
		case 'gif':
			$image = imagecreatefromgif($path);
			break;

		case 'png':
			$image = imagecreatefrompng($path);
			break;

		default:
			$image = imagecreatefromjpeg($path);
			break;
	}

	// Get width and height
	$x = imagesx($image);
	$y = imagesy($image);

	// grey
	$grey = 0x007F7F7F;

	//  (black)
	$c_bg = 0x00000000;

	$new_img = imagecreatetruecolor($x,$y);
	imageFilledRectangle($new_img, 0,0, $x,$y, $grey);

	$step = 18;
	$angle = 40;
	// draw the head
	imagearc($new_img, $step, $step, $angle, $angle,  180, 270, $transparent);
	imagearc($new_img, $x - $step, $step, $angle, $angle,  270, 0, $transparent);
	imagearc($new_img, $x - $step,$y - $step, $angle, $angle,  0, 90, $transparent);
	imagearc($new_img, $step,$y - $step, $angle, $angle,  90, 180, $transparent);

	ImageFillToBorder($new_img,0,0,$transparent,$transparent);
	ImageFillToBorder($new_img,$x,$y,$transparent,$transparent);
	ImageFillToBorder($new_img,0,$y,$transparent,$transparent);
	ImageFillToBorder($new_img,$x,0,$transparent,$transparent);
	imagecolortransparent($new_img, $transparent);

	// so we only rplace on grey
	imagelayereffect($new_img, IMG_EFFECT_OVERLAY);

	imagecopy($new_img, $image, 0,0, 0,0, $x,$y);

	switch($extension)
	{
		case 'gif':
			imagegif($new_img, $path);
			break;

		case 'png':
			imagepng($new_img, $path);
			break;

		default:
			imagepng($new_img, $path);
			break;
	}

	imagedestroy($image);
	imagedestroy($new_img);
	return;
}


meh sorry ill comment it tomorrow. if any interest.

note i just used it like this:

	sed_createthumb($file_path, $thumbnail_path , $cfg['th_x'],$cfg['th_y'], $cfg['th_keepratio'], $thumbnail_extension, $filename, $file_size, $th_colortext, $cfg['th_textsize'], $th_colorbg, $cfg['th_border'], $cfg['th_jpeg_quality']);

	if(1)
	{
		round_thumbnail($thumbnail_path);
	}
chobblr
#2 19.05.2009 22:03
Where do i put this code ?
Elgan
#3 20.05.2009 01:12
errm anywhere thats loaded, functions.php if u wish. Then just call it.

but it's not compleatee, was my first attempt. ive recently found better thumbnail classes, that look to work nice, ive not tried some yet.

not sure where i found it now

http://www.cotonti.com/pastebin/32
chobblr
#4 20.05.2009 01:22
does the above link (to code) output look good ?
Elgan
#5 20.05.2009 01:44
im just trying it now.

Unlike mine it seems to have a set colour background, where i was trying for a transparent background. im still playing.


css :D?
chobblr
#6 20.05.2009 01:48
a transparent background for what ?

edit: if you mean the border color you can just stick "transparent" in the color settings on the admin panel > PFS

Відредаговано: chobblr (20.05.2009 01:54, 15 років тому)
Elgan
#7 20.05.2009 03:14