I'm doing resize on jpg, after that i would like to get md5 from it and then save new image with that MD5 name.
Code looks like that:
$extension = 'jpg';
$img = imagecreatefromjpeg($source);
$tmp_img = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $newWidth, $newHeight, $plik, $plik);
//$md5 - here i need to get md5...
Can you do at the top...
$md5 = md5_file($source);
I've also seen a technique where you stream the image file into an output buffer and capture that.
ob_start(); imagejpeg($tmp_img); $data = ob_get_clean(); $md5 = md5($data);
You could then create your file with...
file_put_contents($md5 . '.' . $extension, $data);