# If() to big resize image function

**URL:** https://forum.kirupa.com/t/if-to-big-resize-image-function/131816
**Category:** Uncategorized
**Created:** [December 20, 2004, 7:53am UTC](https://forum.kirupa.com/t/if-to-big-resize-image-function/131816 "2004-12-20T07:53:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sWo0p](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sWo0p](https://forum.kirupa.com/u/sWo0p)
#### Post date: [December 20, 2004, 7:53am UTC](https://forum.kirupa.com/t/if-to-big-resize-image-function/131816/1 "2004-12-20T07:53:15Z")

</div>

i need a resize function so i started with this… but somehow it does’nt work… whats wrong with this…

```php

$imgsize = getimagesize($pieces[3]); 
	if($imgsize[0] < 300 || $imgsize[1] < 250) { 
     echo "<img src=\" ". $pieces[3] ." \" width=\85%\" height=\"85%\" hspace=\"2\" vspace=\"2\"></td>";
		}else{
 		 echo "</td>"; }
	elseif($pieces[3] != '') {
    	echo "<img src=\" ". $pieces[3] ." \" hspace=\"2\" vspace=\"2\"></td>";
    		}else{
 		 		echo "</td>";
	}

```

it must resize the $pieces[3] if its to big, if possible resize to within 300x300px… can someone help???
