Add TWO watermarks in the same image

See all posts Reply

Add TWO watermarks in the same image new!
by Paulo, 16 years, 9 months ago
Hi,

In my gallery a have to put one watermark on TOP and one on botton right, but when i try, only the last watermark stay on image.

//FAZ O PROCESSO DE MARCA D'AGUA
$ImgMod = new Upload($ImagemCompleta);
$ImgMod->file_auto_rename = false;
$ImgMod->file_overwrite = true;
	
//APLICA A MARCA 1 NO TOPO	
if ( file_exists($Marca1) == true ) {
  $ImgMod->image_watermark = $Marca1;
  $ImgMod->image_watermark_position = 'T';
}	

//APLICA A MARCA 2 NO CANTO INFERIOR DIREITO
if ( file_exists($Marca2) == true ) {
  $ImgMod->image_watermark = $Marca2;
  $ImgMod->image_watermark_position = 'BR';
}	

$ImgMod->process( $PastaTemp );
Reply
Re: Add TWO watermarks in the same image new!
by Paulo, 16 years, 9 months ago
Ops i forget say that is my code that dont do what i want...

My question is: How add two watermark on the same image?

Thx.Reply
Re: Add TWO watermarks in the same image new!
by colin, 16 years, 9 months ago
It is normal. The $ImgMod->image_watermark is not a method, it is a property. So the second time you set it, you remove the first value that you put there.

In order to add two watermarks, you need to call Process() twice.

For instance, something like this:
$ImgMod = new Upload($ImagemCompleta);
$ImgMod->file_auto_rename = false;
$ImgMod->file_overwrite = true;
	
if ( file_exists($Marca1) == true ) {
  $ImgMod->image_watermark = $Marca1;
  $ImgMod->image_watermark_position = 'T';
}	

$ImgMod->process( $PastaTemp );

$ImgMod = new Upload($PastaTemp);
$ImgMod->file_auto_rename = false;
$ImgMod->file_overwrite = true;

if ( file_exists($Marca2) == true ) {
  $ImgMod->image_watermark = $Marca2;
  $ImgMod->image_watermark_position = 'BR';
}	

$ImgMod->process( $PastaTemp );
Reply
Re: Add TWO watermarks in the same image new!
by Paulo, 16 years, 9 months ago
It no function, because the code take the same image and put other watermark.

I found a solution, fisrt, attach the watermark1, second, take this image and attach the other watermark.

:)
$ImagemTemp     = $PastaTemp.$imagem;

$ImgMod = new Upload($ImagemCompleta);
$ImgMod->file_auto_rename = false;
$ImgMod->file_overwrite = true;
	
if ( file_exists($Marca1) == true ) {
  $ImgMod->image_watermark = $Marca1;
  $ImgMod->image_watermark_position = 'T';
}	
 
$ImgMod->process( $PastaTemp );
 
$ImgMod = new Upload($ImagemTemp);
$ImgMod->file_auto_rename = false;
$ImgMod->file_overwrite = true;
 
if ( file_exists($Marca2) == true ) {
  $ImgMod->image_watermark = $Marca2;
  $ImgMod->image_watermark_position = 'BR';
}	
 
$ImgMod->process( $PastaTemp );

Thx...solved :)Reply
Re: Add TWO watermarks in the same image new!
by colin, 16 years, 9 months ago
Yes, it is what I meant.Reply