Имам нужда от това:
правя това:
$top_file = 'image1.png';
$bottom_file = 'image2.png';
$top = imagecreatefrompng($top_file);
$bottom = imagecreatefrompng($bottom_file);
// get current width/height
list($top_width, $top_height) = getimagesize($top_file);
list($bottom_width, $bottom_height) = getimagesize($bottom_file);
// compute new width/height
$new_width = ($top_width > $bottom_width) ? $top_width : $bottom_width;
$new_height = $top_height + $bottom_height;
// create new image and merge
$new = imagecreate($new_width, $new_height);
imagecopy($new, $top, 0, 0, 0, 0, $top_width, $top_height);
imagecopy($new, $bottom, 0, $top_height+1, 0, 0, $bottom_width, $bottom_height);
// save to file
imagepng($new, 'merged_image.png');
.. но обединеното изображение няма и двете изображения. PHP съобщава това:
Warning: imagecreatefrompng(): '/Users/myusername/Work/www/projectname/staticimage.jpg' is not a valid PNG file in /Users/myusername/Work/www/projectname/imageWatermark.php on line 60
Warning: imagecopy() expects parameter 2 to be resource, boolean given in /Users/myusername/Work/www/projectname/imageWatermark.php on line 74
$new_width = max($top_width, $bottom_width)
. - person Barmar   schedule 23.01.2015imagecopyresized
за мащабиране на долното изображение, когато го копирате? - person Barmar   schedule 23.01.2015<?php
тагerror_reporting(E_ALL); ini_set('display_errors', 1);
вижте дали дава нещо. - person Funk Forty Niner   schedule 23.01.2015warnings
- person eozzy   schedule 23.01.2015staticimage.jpg'
, което трябва да бъде.png
според предупреждението. Тъй като използватеimagecreatefrompng()
- ще трябва да използватеimagecreatefromjpeg()
- person Funk Forty Niner   schedule 23.01.2015imagecreatefrompng()
иimagecreatefromjpeg()
заедно, което работи за мен по време на тестването. - person Funk Forty Niner   schedule 23.01.2015