# GD Library resize image Fatal error not enough memory HEEEELP!

**URL:** https://forum.kirupa.com/t/gd-library-resize-image-fatal-error-not-enough-memory-heeeelp/108694
**Category:** Uncategorized
**Created:** [April 27, 2004, 10:02pm UTC](https://forum.kirupa.com/t/gd-library-resize-image-fatal-error-not-enough-memory-heeeelp/108694 "2004-04-27T22:02:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ScriptFlipper](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@ScriptFlipper](https://forum.kirupa.com/u/ScriptFlipper)
#### Post date: [April 27, 2004, 10:02pm UTC](https://forum.kirupa.com/t/gd-library-resize-image-fatal-error-not-enough-memory-heeeelp/108694/1 "2004-04-27T22:02:26Z")

</div>

okay guys, this is an emergency! if someone could help me on this one, it would be awesome!!

so, my problem is that I upload images to the webserver via a html form, and before the images are saved, they are resized to the width 410. so far so good.

but! if I add large resolution images, like 1600x1200 px, I get a fatal error saying that there’s not enough memory, but it works for images that are 640x480 pixels. I checked how much memory I have allocated on my webserver account, and it’s 8mb.

I have been thinking: if I could use the already uploaded image $\_FILES[‘image’][‘tmp\_name’] that (I think) already is allocated in the servers memory, I wouldn’t have to use the function imageCreateFromJPEG($tmp\_file);

but how am I supposed to achieve that??

here’s the code:

```php

$file = $_FILES['image']['name']; 
$tmp_file = $_FILES['image']['tmp_name'];
$ext = strstr($file,"."); 
$ext = strtolower($ext);
if($ext != ".jpg" && $ext != ".jpeg") { 
	echo("You can only upload JPEG files."); 
} else { 
	$t_wd = 410;
	$o_im = imageCreateFromJPEG($tmp_file);
	imagesx($o_im);
	imagesy($o_im);
	$t_ht = round($o_ht * $t_wd / $o_wd); 

	$t_im = imageCreateTrueColor($t_wd,$t_ht);
	
	#imageCopyResized($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
	
	imageJPEG($t_im,"../images/".$file);
	
	imageDestroy($o_im);
	imageDestroy($t_im);

```

Thank you so much in advance!
