...

View Full Version : Resize Image



penny94
10-19-2012, 06:52 PM
I have a page that merges two pictures into one using the code below. I am trying to rezise the $src image. At the minute the last two numbers in imagecopymerg resizes what is displayed but it shows only part of the image and doesn't resize the image, for example it would show the top corner of the image.



<?php
$dest = imagecreatefrompng('polayoloright.png');
$src = imagecreatefromjpeg('tiffany_alvord_heart_2bg9s7p.sized.jpg');
imagealphablending($dest, false);
imagesavealpha($dest, true);
$src = imagecreatetruecolor(50,50);
imagecopymerge($dest, $src, 1, 1, 0, 20, 50, 50, 100);
header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
?>



I have tried adding the following. It resizes it but displays a black box, not the image.


$src = imagecreatetruecolor(50,50);


Any ideas?

Thanks

henryc06
10-21-2012, 05:18 PM
This is how i resize my image. Try to implement this to your code.

<?php
include('SampleImage.php'); //file name
$image = new SampleImage();
$image->load('picture.jpg'); //image name
$image->resize(250,400);
$image->save('picture2.jpg');
?>

tangoforce
10-21-2012, 05:29 PM
This is how i resize my image. Try to implement this to your code.

<?php
include('SampleImage.php'); //file name
$image = new SampleImage();
$image->load('picture.jpg'); //image name
$image->resize(250,400);
$image->save('picture2.jpg');
?>

Thats not very helpful to the op is it. You;'ve included the code to use a class (in SampleImage.php) but not given them the code for that file. What do you expect them to do with it? It's useless.

@penny White hat web design have a very good class with sample code on their website - I always recommend it as its very good:
http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

bjarneo
10-21-2012, 07:04 PM
And if you're not up to create this class yourself. TimThumb is an great option for resizing. TimThumb: http://www.binarymoon.co.uk/projects/timthumb/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum