画像に透かしを追加してから、その画像をphpで別のファイルに保存しようとしています。これはこれまでのコードですが、何らかの理由で新しいディレクトリの画像に透かしが表示されません。元の画像はパスに保存されており、透かしを適用した後$old_path
に保存したい。$new_path
$old_path = "images_upload/".$name.".".$type;
$new_path = "images_main/".$name.".".$type;
////////////////////water mark
$main_image = imagecreatefromstring(file_get_contents($old_path));
// Load the logo image
$logoImage = imagecreatefrompng("assets/watermark.png");
imagealphablending($logoImage, true);
// Get dimensions
$imageWidth=imagesx($main_image);
$imageHeight=imagesy($main_image);
$logoWidth=imagesx($logoImage);
$logoHeight=imagesy($logoImage);
// Paste the logo
imagecopy(
// source
$main_image,
// destination
$logoImage,
// destination x and y
$imageWidth-$logoWidth, $imageHeight-$logoHeight,
// source x and y
0, 0,
// width and height of the area of the source to copy
$logoWidth, $logoHeight);
////////////////////////
rename($old_path, $new_path);// save image
私が間違っていることを教えてください。