0

Hi guys, i'm a php beginner

I was trying to create a function to merge two images into one. I have been successfully merging a frame(png) on top of an image uploaded (jpeg) on low res.

Then i move on to increase the image file size so that i have better resolution that can be print. I increase both my frame(.png / about 2.7mb) and image(.jpg / 1.9mb) resolution into 2048px * 1536px and when i run the exact same function by tweaking the following it doesn't work anymore. I also have an html form below the image preview ( which i mention above that doesn't display after i increase the image resolution ) also it no longer display.

imagecopy($image, $frame, 0, 0, 0, 0, 2048, 1536);

My code applies as shown below:

<?php
                $image = imagecreatefromstring(file_get_contents("img/source.jpg");
		$frame = imagecreatefrompng('img/frame_test.png');
		
		imagealphablending($frame, true);
		imagesavealpha($frame, true);
		
		imagecopy($image, $frame, 0, 0, 0, 0, 2048, 1536);
		
		header('Content-Type: image/png');
		
		imagejpeg($image, 'img/done.jpg');
		
		$photoframe = 'img/done.jpg';
		
		imagedestroy($image);
		imagedestroy($frame);
	?>
  <div id="preview">
  	<img class="preview-img" src="<?php echo $photoframe; ?>" alt="Your Image" title="Your Image" />
  </div>
  <div id="cust-form"> ...
3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by jbennet
1

Maybe it's a memory limit issue, i.e. the memory used by PHP scripts, did you get any error? If error reporting is disabled, place <?php error_reporting(E_ALL); ?> at top of the script and see what it happens.

0

Hi Cereal
Seems like memory limit issue :-)
It works fine after i change the maximum limit to 128M from php.ini.

Thank you for your help.

1

Image manipulation in php is always iffy, make sure that people can't keep hammering it or your server will grind to a halt.

Edited by jbennet: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.