Background Removal command
Posted: 2009-10-20T03:15:29-07:00
Hi all,
Im desperatly trying to find a solution to removing the colour black from an image(the backfround is black with a white object in front) . I have tried image masking but no succses. Im currently using the -transparent command...and was hoping if someone could have a quick look at the code to see where im going wrong...(no image is been displayed)
<?php
// If the form has been submitted do this
if ( $Submit ) {
// Temporary upload image name
$original_image = $_FILES['all.jpg']['all.jpg'];
// Name to save the image as - in this case the same as the original
$new_image = $_FILES['all.jpg']['all.jpg'];
//command to remove the background
$cmd = " $filename -transparent black ";
// $new_Iimage is the output_filename
exec(" convert $cmd $new_image ");");
echo "File uploaded<br>";
echo "<img src=\"".$new_image."\">";
}
else { ?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<input type="file" name="filename" />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php } ?>
Any suggestions where im going wrong...id really appreciate any help..so thanks to anyone who might know and can help!!!
Kind Rgrds,
Mary
Im desperatly trying to find a solution to removing the colour black from an image(the backfround is black with a white object in front) . I have tried image masking but no succses. Im currently using the -transparent command...and was hoping if someone could have a quick look at the code to see where im going wrong...(no image is been displayed)
<?php
// If the form has been submitted do this
if ( $Submit ) {
// Temporary upload image name
$original_image = $_FILES['all.jpg']['all.jpg'];
// Name to save the image as - in this case the same as the original
$new_image = $_FILES['all.jpg']['all.jpg'];
//command to remove the background
$cmd = " $filename -transparent black ";
// $new_Iimage is the output_filename
exec(" convert $cmd $new_image ");");
echo "File uploaded<br>";
echo "<img src=\"".$new_image."\">";
}
else { ?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<input type="file" name="filename" />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php } ?>
Any suggestions where im going wrong...id really appreciate any help..so thanks to anyone who might know and can help!!!
Kind Rgrds,
Mary