From: "Ashley M. Kirchner" on

I'm trying to use Imagick:roundCorners() however the resulting image
has the background color on the corners set to black if I save the image
as a JPG format. If I save it as a PNG format, the rounded corners are
transparent. Does anyone know if the background color can be set to
white when saving as a JPG format? I'd rather have 122K over 371K for a
file size ...
From: Brady Mitchell on
On Thu, Nov 5, 2009 at 12:48 AM, Ashley M. Kirchner <ashley(a)pcraft.com> wrote:
>   I'm trying to use Imagick:roundCorners() however the resulting image has
> the background color on the corners set to black if I save the image as a
> JPG format.  If I save it as a PNG format, the rounded corners are
> transparent.  Does anyone know if the background color can be set to white
> when saving as a JPG format?  I'd rather have 122K over 371K for a file size

I'm sure it can be done, but without seeing your code we can't really help.

Brady
From: Ashley Sheridan on
On Thu, 2009-11-05 at 01:46 -0800, Brady Mitchell wrote:

> On Thu, Nov 5, 2009 at 12:48 AM, Ashley M. Kirchner <ashley(a)pcraft.com> wrote:
> > I'm trying to use Imagick:roundCorners() however the resulting image has
> > the background color on the corners set to black if I save the image as a
> > JPG format. If I save it as a PNG format, the rounded corners are
> > transparent. Does anyone know if the background color can be set to white
> > when saving as a JPG format? I'd rather have 122K over 371K for a file size
>
> I'm sure it can be done, but without seeing your code we can't really help.
>
> Brady
>


It might be that you need to define white as a first colour first and
fill the canvas with it. I've had similar problems in GD which were
solved like this.

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: "Ashley M. Kirchner" on
Brady Mitchell wrote:
> I'm sure it can be done, but without seeing your code we can't really
> help.
Easily solved. From the PHP manual
(http://www.php.net/manual/en/function.imagick-roundcorners.php):

<?php

$image = new Imagick();
$image->newPseudoImage(100, 100, "magick:rose");
$image->setImageFormat("png");

$image->roundCorners(5,3);
$image->writeImage("rounded.png");
?>

That produces a nice transparent cornered image, as it should.
However, try saving it as a JEPG instead. Set the image format to
'jpeg' and write it out as 'rounded.jpg' and you'll notice the corners
are now black.

I know JPEG doesn't support transparency, that's fine. What I want
is to change the black to white instead.

-- A
From: Ashley Sheridan on
On Thu, 2009-11-05 at 12:22 -0700, Ashley M. Kirchner wrote:

> Brady Mitchell wrote:
> > I'm sure it can be done, but without seeing your code we can't really
> > help.
> Easily solved. From the PHP manual
> (http://www.php.net/manual/en/function.imagick-roundcorners.php):
>
> <?php
>
> $image = new Imagick();
> $image->newPseudoImage(100, 100, "magick:rose");
> $image->setImageFormat("png");
>
> $image->roundCorners(5,3);
> $image->writeImage("rounded.png");
> ?>
>
> That produces a nice transparent cornered image, as it should.
> However, try saving it as a JEPG instead. Set the image format to
> 'jpeg' and write it out as 'rounded.jpg' and you'll notice the corners
> are now black.
>
> I know JPEG doesn't support transparency, that's fine. What I want
> is to change the black to white instead.
>
> -- A
>


Fill the background with white before you create the corners.

Thanks,
Ash
http://www.ashleysheridan.co.uk