Page 1 of 1

Adding Edge to image with php

Posted: Sat May 27, 2006 4:58 am
by mbaroz
Hi
I would like to add gradient edge to images (after uploaded)
I know that GD Lib can do this.
Does any one have some code sample ?
Thanks
moshe

Posted: Sat May 27, 2006 4:33 pm
by Soogn
If you can provide a little more info, someone (me) can code up a little example, GD isn't difficult.... are we talking like a 1px black border or something; or more complex structures like drop shadows, etc

Posted: Sat May 27, 2006 5:58 pm
by litebearer
Might look at this


http://www.scriptdungeon.com/script.php?ScriptID=865


Very flexible thumbnail generator. Output larger/smaller than source, entire image or cropped section, with/without configurable borders and/or background color. Source can be local file, remote file or database source. GIF reading supported with or without GD support. BMP reading support. Optional watermarking, optional unsharp mask sharpening, optional caching. EXIF thumbnails can be extracted. Supports any input formats via ImageMagick if available. Works with any GD version, PHP v4.0.6+



Lite...

Gradient border to image- more info

Posted: Sun May 28, 2006 12:22 am
by mbaroz
Hi
Thanks for helping.
When someone on my site upload an image i want to stroke the border of the image with white faded border.
You might look at this image(it is a ready one) for what im looking for as a result:
http://www.beads4sure.com/images/23415352.jpg

thanks
moshe

Posted: Sun May 28, 2006 6:01 am
by Soogn
Hey,

They affect is incrdibly difficult to acheive for someone with a lot of GD skill, best bet is to find an effect in the toolkit ^^ that is close, as without a lot of knowledge (or hiring someone) your going to struggle immensely;

Even if you got it to run, you could expect pretty high CPU load - as for the opacity you need calculate the colour, then the appropriate target colour after 1, 10, 20, 30% etc opacity yo get the fade (even if your not using transpacency, you have4 to calculate the shade of white to draw over the image).


The Alternative is to make `border` images, if all the images will be GD'd to the same size, then you can just make one image wtih a whitespace in the centre and `paste` your uploaded image onto it.

You might also considering making 4x corner images, and a top + left + bottom + right type images, and jigsawing those roungd your image --

if you let us know which would suit best (and try a few things -- paste them up) -- we can offer constyrctive criticism, and you'll find people more willing to help out too -

Posted: Sun May 28, 2006 5:05 pm
by John Cartwright
Moved to PHP-GD.

Posted: Mon May 29, 2006 5:48 am
by onion2k
Thank goodness for bank holidays .. I've written a class to make these sorts of thumbnails and added it to the list on phpgd.com ..

http://www.phpgd.com/scripts.php?script=39

Suprisingly complicated. I thought they'd be simpler when I started. At the moment there's no parameter to control the width of the gradient, only the size of the thumbnail and the color.

Posted: Mon May 29, 2006 12:18 pm
by onion2k
To save the file instead of outputting it to the browser, comment out the content type header and give the call to imagejpeg() a filename.

Code: Select all

//header("Content-type: image/jpeg;");
$i->imagejpeg("thumbnail.jpg");

Thanx

Posted: Tue May 30, 2006 12:13 am
by mbaroz
Hi
Thanx for the scripts, i loved it..
Moshe