# Back again

**URL:** <https://forum.kirupa.com/t/back-again/165804>\
**Category:** Uncategorized\
**Created:** [October 14, 2005, 1:32am UTC](https://forum.kirupa.com/t/back-again/165804 "2005-10-14T01:32:57Z")\
**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:** [October 14, 2005, 1:32am UTC](https://forum.kirupa.com/t/back-again/165804/1 "2005-10-14T01:32:57Z")

</div>

i’m still having problems with the php script i’m using to convert my JPEGs to thumbnails. I have imagemagick installed and i’m trying to use that but i’ve run into the same error:  
**Warning** : imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in **/home/theoldd/public\_html/submit.php** on line **30**

**Warning** : imagecreatefromjpeg(): ‘uploads/memberspics/user.jpg’ is not a valid JPEG file in **/home/theoldd/public\_html/submit.php** on line **30**  
my script is as follows:

```php

<?php
if($uploadedfile_type="image/jpeg" || $uploadedfile_type="image/jpg" ){
$target = "uploads/memberspics/";
$pic = $target . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg;
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $pic);
}
}
fopen("$pic", "a+");
function cmyk2rgb($pic) {
   $mgck_wnd = NewMagickWand();
   MagickReadImage($mgck_wnd, $pic);
   
   $img_colspc = MagickGetImageColorspace($mgck_wnd);
   if ($img_colspc == MW_CMYKColorspace) {
	   echo "$file was in CMYK format<br />";
	   MagickSetImageColorspace($mgck_wnd, MW_RGBColorspace);
   }
   MagickWriteImage($mgck_wnd, str_replace('.', '-rgb.', $pic));
}
$im = imageCreateFromJPG($pic);
imageinterlace($im, 0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =250;  
$n_height = ($height*250)/$width;  
$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);
fopen("$pic", "r");
$target_path = "uploads/memberspics/thumbnails/";
$im = imageCreateFromJPEG($pic);
imageinterlace($im, 0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =100;  
$n_height = ($height*100)/$width; 
$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);
$thumb = $target_path . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg;
chmod("$pic",0777);
?>

```

as you can see, i’m trying to open a file and convert it to RGB with imagemagick, then have that file resized using the gdlibrary. Any suggestions, does anyone see the problem??  
Thanks!!
