Re: GD imagerectangle() function - background transparency?

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

 



Well, here's one of the test images - literally just a test image I took of a pseudo-toy a while ago:
https://dl.dropboxusercontent.com/u/13327195/13771158254.png

And, here's the current output/finished off version:
https://dl.dropboxusercontent.com/u/13327195/14watermarked.png

The two areas that should have had boxes drawn for them are:
And, the coordinates of the two test/text areas/box outlines are (x-y*x-y):
10-10*200-50
50-50*500-80

Thanks

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

----- Original Message ----- From: "Pierre Joye" <pierre.php@xxxxxxxxx>
To: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
Cc: "php-windows" <php-windows@xxxxxxxxxxxxx>
Sent: Friday, September 06, 2013 10:45 AM
Subject: Re: GD imagerectangle() function - background transparency?


thanks, but I was asking for the source image(s) and the resulting
image (use gimp or whatever to show what you would like to achieve),
easier to actually see what you want to do :)

About transparency, see imagealphablending and imagesavealpha

On Fri, Sep 6, 2013 at 9:39 AM, Jacob Kruger <jacob@xxxxxxxxxxxxx> wrote:
Ok, here's the test code - the drawBox() function is the current
application/implementation am now trying out:

<?php
function drawBox($img, $arCoords, $iColour, $iThickness=2) {
imagesetthickness($img, $iThickness);
$xLeft = intval($arCoords[0]);
$yTop = intval($arCoords[1]);
$xRight = intval($arCoords[2]);
$yBottom = intval($arCoords[3]);
imageline($img, $xLeft, $yTop, $xRight, $yTop, $iColour);
imageline($img, $xLeft, $yTop, $xLeft, $yBottom, $iColour);
imageline($img, $xRight, $yTop, $xRight, $yBottom, $iColour);
imageline($img, $xLeft, $yBottom, $xRight, $yBottom, $iColour);
return $img;
}//end of drawBox function

$imgOut = imagecreatefrompng("./images/test.png");
$colourYellow = imagecolorallocate($imgOut, 255, 255, 0);
$arBoxCoords = array(50, 50, 150, 150);
$imgOut = drawBox($imgOut, $arBoxCoords, $colourYellow, 2);
header("Content-Disposition: inline; filename=\"test.png\"");
header("Content-Type: image/png");
imagepng($imgOut);
imagedestroy($imgOut);
exit;
?>


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>
Cc: "Pierre Joye" <pierre.php@xxxxxxxxx>
Sent: Friday, September 06, 2013 8:39 AM

Subject: Re:  GD imagerectangle() function - background
transparency?


Effectively, I've got sort of template images, and want to sort of draw
multiple outline boxes onto them where users can then choose one to then
insert text onto image - almost like a form of eCard template rendition,
but, bit different.

I was originally trying to show the boxes/areas to the user using
relatively positioned template images, overlaid by absolutely positioned
div elements, with coloured borders, handled using CSS, and then jQuery to
manipulate the highlighted/chosen one by changing it's border-color CSS
attribute, client-side/at runtime, but, this doesn't always seem to
cooperate/implement it at run time.

Have now told them will try sort of dynamically generating a version of
the template image, server-side, with the various area outlines drawn onto
it, which can then reload at run-time when a new text outline area is
selected, but initially tried creating an image resource from the template
file, and then using imagerectangle to draw a rectangle onto it, after
allocating the relevant colour, and setting drawing thickness, but, it
seemed to be blanking out the template image, so I then tried creating a
new image resource of the same dimensions, filling it up with an obscure
colour, draw the rectangle onto it, set it's transparency to the obscure
colour, and then use either imagecopy() or imagecopymerge() to copy it
over the original template image, but, still seems to be just blocking out
the actual template image.

Now, suppose will maybe also try out splitting the blocks to be drawn up
into actual lines, and just try drawing the lines onto the original
template image, and see if that works, since at the moment, apparently the
combination output image is just a white background, with the coloured
boxes on it - as in, it's again just blocked out the original image, as
opposed to actually overlaying a somewhat transparent image onto it, and
suppose this could be due to pallett's not matching, or something..?

Anyway, let me quickly slap together a couple of tests, and will try post
a link, and source code, etc.

Thanks

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

----- Original Message ----- From: "Pierre Joye" <pierre.php@xxxxxxxxx>
To: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
Cc: "php-windows" <php-windows@xxxxxxxxxxxxx>
Sent: Friday, September 06, 2013 7:59 AM
Subject: Re:  GD imagerectangle() function - background
transparency?


hi!

On Thu, Sep 5, 2013 at 10:35 PM, Jacob Kruger <jacob@xxxxxxxxxxxxx> wrote:

Just wondering, if I load an existing image into an image resource, and
then draw a rectangle on it using the GD imagerectangle() function, and
specifically not using the imagefilledrectangle() function, does the new
rectangle/box overlay the existing image content, or just draw the
outlines thereof onto/overlaying the existing content?

Alternatively, should I load the existing image, then use something like
imagecreatetruecolor() to create another image resource of the same
dimensions, fill it with an obscure colour, draw the rectangle on it, set
the transparency colour for that specific image resource to the obscure
colour, and then copy it over the original/existing image resource before
outputting/returning the combination?


imagecopy supports alpha, imageoverlay lets you define the mode. But
I'm not sure what kind of results you try to achieve, please put a
link to an example result image with the two source images, it could
help :)

--
Pierre

@pierrejoye | http://www.libgd.org


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





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

  Powered by Linux