Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Image copy error?

$
0
0

I'm using a simple script for Image Copy. It's adding an image to the bottom of another image. Both images are the same width. The script works fine, but it changes the color of my images and makes it blurry??? I have no clue why, can anyone help me out :)

 

<?php
$top_file = 'image1.jpg';
$bottom_file = 'image2.jpg';
 
$top = imagecreatefromjpeg($top_file);
$bottom = imagecreatefromjpeg($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
imagejpeg($new, 'uploads/merged_image.jpg');
?>

 

 

 

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles