Fonction php - sur une image

jarodjarod Messages postés 49 Date d'inscription samedi 7 juillet 2007 Statut Membre Dernière intervention 5 mai 2017 - 10 juin 2010 à 16:27
jarodjarod Messages postés 49 Date d'inscription samedi 7 juillet 2007 Statut Membre Dernière intervention 5 mai 2017 - 10 juin 2010 à 16:28
Bonjour à tous,

Voila, je suis blocké devant une fonction de stéganographie compliqué, enfin je comprend en générale ce qu'elle fait mais je cherche à mieux comprend le code :

/*
* This function encodes the contained file into the container JPEG picture
* Return : An array containing the name of the returned picture, and the PNG picture itself hidding the contained file
* Throw Exceptions
*/
function Encode() {
$data=$this->PrepareData();
$dataBin="";
for($i=0;$i<strlen($data);$i++)
$dataBin.=ConvCharBinString($data[$i]);
unset($data);
$imageProperties=@getImageSize($this->containerPicture["tmp_name"]);
$image=@ImageCreateFromJPEG($this->containerPicture["tmp_name"]);

if (strlen($dataBin)>$imageProperties[0]*$imageProperties[1]*3) {
ImageDestroy($image);
global $CONTAINER_TOO_SMALL;
throw new Exception($CONTAINER_TOO_SMALL);
}
else {
$ptDataBin=0;
for ($x=0;$x<$imageProperties[0] && $ptDataBin<strlen($dataBin);$x++) {
for ($y=0;$y<$imageProperties[1] && $ptDataBin<strlen($dataBin);$y++) {
$rgb=ImageColorAt($image,$x,$y);
$r=($rgb>>16)&0xFF;
$g=($rgb>>8)&0xFF;
$b=$rgb&0xFF;

if ($dataBin[$ptDataBin]=="1")
$r|=0x01;
else if ($r%2==1)
$r-=1;
$ptDataBin++;

if ($ptDataBin<strlen($dataBin)) {
if ($dataBin[$ptDataBin]=="1")
$g|=0x01;
else if ($g%2==1)
$g-=1;
$ptDataBin++;
}

if ($ptDataBin<strlen($dataBin)) {
if ($dataBin[$ptDataBin]=="1")
$b|=0x01;
else if ($b%2==1)
$b-=1;
$ptDataBin++;
}

$color=ImageColorAllocate($image,$r,$g,$b);
ImageSetPixel($image,$x,$y,$color);
}
}

$outputName="";
$posDot=strpos($this->containerPicture["name"],".");
if ($posDot!=false)
$outputName=substr($this->containerPicture["name"],0,$posDot).".png";
else
$outputName=$this->containerPicture["name"].".png";

return array($outputName,$image);
}
}



Merci pour vos reponse, je suis tres reconnaissant

1 réponse

jarodjarod Messages postés 49 Date d'inscription samedi 7 juillet 2007 Statut Membre Dernière intervention 5 mai 2017
10 juin 2010 à 16:28
0
Rejoignez-nous