我想在另一个图像(png)中隐藏/加密图像(png)并在PHP GD中获取加密图像。我试图添加每个RGB像素值并获取新图像。但是它仍然无法隐藏原始图像。
<?php
ini_set('memory_limit','-1');
header("Content-type: image/png");
$im = imagecreatefrompng("sar.png");
$cipher = imagecreatefrompng("sar_cipher.png");
for($x = 0 ; $x<1024; $x++){
for($y =0; $y<768; $y++){
$rgb = imagecolorat($im, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$ciRgb = imagecolorat($cipher, $x, $y);
$Cr = ($ciRgb >> 16) & 0xFF;
$Cg = ($ciRgb >> 8) & 0xFF;
$Cb = $ciRgb & 0xFF;
$newRed = $r+$Cr;
$newGreen = $g+$Cg;
$newBlue = $b+$Cb;
if($newRed > 255 ) {
//echo "Red is ".$newRed;
$newRed = $newRed - 255;
}
if($newGreen > 255 )
$newGreen = $newGreen - 255;
if($newBlue > 255 )
$newBlue = $newBlue - 255;
// initialize new color
$newColor = $a | $newRed << 16 | $newGreen << 8 |$newBlue ;
// set color at x , y on image
imagesetpixel($im, $x, $y, $newColor);
}
}
imagepng($im,"encrypted_image.png");
imagepng($im);
imagedestroy($im);
?>
如何将原始图像完全隐藏在另一个图像中?