Combine 2-3 transparent PNG images on top of each other with PHP
$image_1 = imagecreatefrompng('image_1.png');
$image_2 = imagecreatefrompng('image_2.png');
imagealphablending($image_1, true);
imagesavealpha($image_1, true);
imagecopy($image_1, $image_2, 0, 0, 0, 0, 100, 100);
imagepng($image_1, 'image_3.png');
merge Transparent PNG images with other PNG images - PHP
the solution was to use
imagecopy($dest, $src, ($offsetY + 250), $offset, 0, 0, imagesx($src),imagesy($src));
not
imagecopymerge($dest, $src, ($offsetY + 250), $offset, 0, 0, imagesx($src),imagesy($src), 99);
Merging two images with PHP
I got it working from one I made.
<?php
$dest = imagecreatefrompng('vinyl.png');
$src = imagecreatefromjpeg('cover2.jpg');
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc.
header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
?>
how do i create a transparent canvas, then add transparent pngs to it?
$img = imagecreatetruecolor(...);
imagealphablending($img,false);
//rest of code.
Automatically align and resize 3 images into a small image with PHP?
The easiest way is just to always fit the face/hair/beard in the same area of the image. Then just crop that area out.
If you must, you can store extra data for each image specifying a rectangle in the image that must be visible in the small avatar. Then take the maximum extremities of these rectangles in all the images you compose, and crop+shrink that down to your small avatar size.
However, be aware that resizing PNG images by a few pixels (e.g. 83x83 -> 80x80) can substantially reduce the quality, particularly for images with lots of defined edges. This is because there are many pixels in the new image that are [nearly] evenly split between 4 pixels from the original image, and in images with sharp edges this leads to blurring.
So, shrinking an image to fit a portrait is not just difficult but also reduces quality. I'd cut off the beard instead!
Put PNG over a JPG in PHP
<?
$png = imagecreatefrompng('./mark.png');
$jpeg = imagecreatefromjpeg('./image.jpg');
list($width, $height) = getimagesize('./image.jpg');
list($newwidth, $newheight) = getimagesize('./mark.png');
$out = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($out, $jpeg, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagecopyresampled($out, $png, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);
imagejpeg($out, 'out.jpg', 100);
?>
Related Topics
Session_Start() Creates New Session Every Refresh
PHP SQL Select Where Like Search Item with Multiple Words
How to Create a Nested-List of Categories in Laravel
Parse Timezone Int to String (Timezone Name) (Facebook API)
In Laravel How to Add Values to a Request Array
Clean Way to Throw PHP Exception Through Jquery/Ajax and JSON
How to Add PHP Pagination in Array'S
Automatic Logout After 15 Minutes of Inactive in PHP
How to Get the Last Char of a String in PHP
Why Are Escape Characters Being Added to the Value of the Hidden Input
How to Easily Remove the Last Comma from an Array
Avoiding Recursion with Doctrine Entities and Jmsserializer
How to Format an Utc Date to Use the Z (Zulu) Zone Designator in PHP
How to Get Values of Xml Elements
Using Xampp, How to Swap Out PHP 5.3 for PHP 5.2