# Resizing an Image

**URL:** <https://forum.kirupa.com/t/resizing-an-image/85128>\
**Category:** programming\
**Created:** [April 1, 2005, 11:59pm UTC](https://forum.kirupa.com/t/resizing-an-image/85128 "2005-04-01T23:59:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw06](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jw06](https://forum.kirupa.com/u/jw06)\
**Post date:** [April 1, 2005, 11:59pm UTC](https://forum.kirupa.com/t/resizing-an-image/85128/1 "2005-04-01T23:59:26Z")

</div>

I have this function:

```php

<?php
$new_width=100; //Image width Change if needed 
$new_height=100; //Image height Change if needed 

$source_path="../random/images"; //Source File path 
$destination_path="../random/thumbs";
function thumb_jpg($file) 
{ 
    global $source_path; 
    global $destination_path; 

    global $new_width; 
    global $new_height; 

    $destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image"); 

    $srcimg=ImageCreateFromJPEG($source_path.$image_name) or die("Problem In opening Source Image"); 

    ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing"); 

    ImageJPEG($destimg,$destination_path.$image_name) or die("Problem In saving"); 
}
?>

```

That creates a thumbnail of an image uploaded from a form.

I get the following errors however:

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/arctichosts/public\_html/admin/admin\_uploadrandom.php on line 24

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: ‘…/random/images’ is not a valid JPEG file in /home/arctichosts/public\_html/admin/admin\_uploadrandom.php on line 24  
Problem In opening Source Image

I have GDv2.0.28.

Any ideas?
