2017-03-05 10 views
0

透かし画像の座標を左上に変更する方法はたくさんありましたが、どの変数が上、左、右、下隅を定義しているのか分かりません。右下の代わりに左上にPHPで透かしを並べる

私はまあ、それはあなたのコードにだあなたは

//Source folder where all images are placed 
$source="source"; 

//Destination folder where all images with watermark will be copied 
$destination="destination"; 

//Creating an image object of watermark image 
$watermark=imagecreatefrompng("watermark.png"); 

//Margin of watermark from right and bottom of the main image 
$margin_right=10; 
$margin_bottom=10; 

//Height ($sy) and Width ($sx) of watermark image 
$sx=imagesx($watermark); 
$sy=imagesy($watermark); 

//Get list of images in source folder 
$images=array_diff(scandir($source), array('..', '.')); 

foreach($images as $image){ 
    //Create image object of main image 
    $img=imagecreatefromjpeg($source.'/'.$image); 

    //Copying watermark image into the main image 
    imagecopy($img, $watermark, imagesx($img) - $sx - $margin_right, imagesy($img) - $sy - $margin_bottom, 0, 0, $sx, $sy); 

    //Saving the merged image into the destination folder 
    imagejpeg($img, $destination.'/'.$image,100); 

    //Destroying the main image object 
    imagedestroy($img); 
} 

//Destroying watermark image object 
imagedestroy($watermark); 

?> 

答えて

0

を助けることを願って!

//Margin of watermark from right and bottom of the main image 
$margin_right=10; 
$margin_bottom=10; 

私はどのようにあなたのスクリプトの作業わからないんだけど、あなたは追加することができます:

$margin_left=10; 
$margin_top=10; 

と削除を:

$margin_right=10; 
$margin_bottom=10; 

それはPHPには本当に関連はありません!それはCSSの設定のように見えます!

+0

コードを少し良く見て、あなたが表示されます –

+0

私はそれについて何も表示されません! – Soheyl

+0

$ margin-right = 10は表示されません。 $ margin-bottom = 10;変数だけですか? margin-leftとmargin-topに変更した場合、imagecopyには$ margin-rightと$ margin-bottomという名前の変数が必要なので、エラーが発生しますか? –

関連する問題