בעקבות מערכת שאני בונה חיפשתי סקריפט ברשת ולא מצאתי אחד שמאחד בין jpeg לpng,
לכן למען הדורות הבאים אני מפרסם אותו.
הסקריפט מקבע לוגו על קובץ, נבנה עבור מערכת העלאת קבצים.
PHP קוד:
<?php
$logo_file = "logo.png";
$image_file = "img.jpg";
$targetfile = "img2.jpg";
$photo = imagecreatefromjpeg($image_file);
$fotoW = imagesx($photo);
$fotoH = imagesy($photo);
$logoImage = imagecreatefrompng($logo_file);
$logoW = imagesx($logoImage);
$logoH = imagesy($logoImage);
$photoFrame = imagecreatetruecolor($fotoW,$fotoH);
$dest_x = $fotoW - $logoW;
$dest_y = $fotoH - $logoH;
imagecopyresampled($photoFrame, $photo, 0, 0, 0, 0, $fotoW, $fotoH, $fotoW, $fotoH);
imagecopy($photoFrame, $logoImage, $dest_x, $dest_y, 0, 0, $logoW, $logoH);
imagejpeg($photoFrame, $targetfile);
echo '<img src="'.$targetfile.'" />';
/**
* By santin1991[at]gmail[dot]com
**/
?>
כדי לשים את הלוגו על הקובץ הקיים בלי ליצור עוד קובץ, פשוט להחליף את targetfile
PHP קוד:
$targetfile = $image_file;
המשך יום טוב.