Re: Cropping images with fading outline effects, using GD, etc.?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


For example, the following imagick function might handle output image opacity setting, but, it would still be nice to just handle outline gradual fading on one go:

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Wednesday, August 07, 2013 9:46 AM
Subject: Cropping images with fading outline effects, using GD, etc.?

I need/want to be able to take either uploaded, or stored image files, and crop them into either rectangular, or elliptical pieces/shapes, and am using GD library thus far.

The basics are not an issue - for rectangular cropping, imagecopy and imagecopyresize, etc. are functions that can handle it easily enough, and in terms of elliptical cropping, I am drawing an elliptical shape onto the original image using a colour that's unlikely to be part of the original image resource, with drawing line thickness set to 2 pixels for now, and then I do a form of flood fill to border with that same colour outside the ellipsis, and then set that as the transparent colour of the image, before copying the relevant part to another image resource as well.

However, it now comes down to that the images to be saved might also need to have sort of faded/increasingly transparent outlines, and these would generally be photo's, and so, just choosing a single transparent colour won't really work too well.

Was thinking simplest will be to in fact take multiple instances of each image, with each of them going slightly smaller in terms of width/height, and then I could keep them centred on each other, but sort of overlay them with the most transparent/faded/widest image instance starting from back, and with sort of original colouration/narrowest one being applied to output resource last, and this should implement a form of faded/blurred outline/edging to output image?

However, it again comes down to trying to decide on best/simplest way to apply a form of global transparency filter to an image resource, without needing to specify a specific colour each time for something like the imagecolourtransparent function, since suppose would need to then figure out a way to determine which RGB value would work best per image - and don't think that could be made to work consistently either.

In other words, what am really looking for at moment is a way to set the opacity of an image resource - and if it comes down to capturing the output buffer while using something like imagepng to stream the image resource to the buffer, that's not an issue either since am already using a form of that to sometimes capture image resource data in another way, but, would need to find a way to somehow affect opacity of output stream image then as well.

While I am currently pretty much just using GD library, I would be open to other suggestions/workarounds/thoughts on the simplest way to implement something like this?

And, if I'm just missing, or haven't come across a simple way to implement faded/graded outlines for images, would also like to know that...<smile>


Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

PHP Windows Mailing List (
To unsubscribe, visit:

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux