# Covert to RGB?

**URL:** https://forum.kirupa.com/t/covert-to-rgb/164187
**Category:** Uncategorized
**Created:** [September 29, 2005, 5:32am UTC](https://forum.kirupa.com/t/covert-to-rgb/164187 "2005-09-29T05:32:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pbrollwitme](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pbrollwitme](https://forum.kirupa.com/u/pbrollwitme)
#### Post date: [September 29, 2005, 5:32am UTC](https://forum.kirupa.com/t/covert-to-rgb/164187/1 "2005-09-29T05:32:18Z")

</div>

Hey all,  
I’m stuck with this php script.  
I have the following:

```php
<?php
if($submit){
$target = "uploads/memberspics/";
$pic = $target . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg;
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $pic);
}
fopen("$pic", "a+");
$im = imageCreateFromJPEG($pic);
imageInterlace($pic,0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =250;  
$n_height = 250; 
$newimage = ImageCreateTrueColor("$n_width","$n_height");				 
ImageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$pic ,75);
chmod("$pic",0777);
fclose($pic);
fopen("$pic", "r");
$target_path = "uploads/memberspics/thumbnails/";
$im = imageCreateFromJPEG($pic);
imageInterlace($pic,0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =100;  
$n_height = 100; 
$newimage = ImageCreateTrueColor("$n_width","$n_height");				 
ImageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$target_path . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg,75);
chmod("$pic",0777);
fclose($pic);
?>

```

really simple script and when it works, it works well…however, with alot of pics i am having the following problem:

imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error

i check it out on the php website and they said it was because the pics have to be in RGB format to convert! Is there a way around this?  
Thanks everyone!
