Jump to content

[SOLVED] IE7 seems to skip a chunk of code


envexlabs

Recommended Posts

Hello,

 

I have a image upload and crop script, but i've hit a road block and can't seem to find a solution.

 

This script works in firefox, but in ie7 it will generate the correct fullsize, but it wont create the thumbnail.

 

It is running through the script fine and not returning any error, which means the user is redirected to products.

 

Here is the chunk of code, anyone see anything i'm not?

 

	require $root.'/inc/php/classes/class.cropcanvas.php';

//lets crop the iamge
$cc =& new CropCanvas();
$cc->loadImage($root.'/user_files/' . $path . '/'.$_GET['pic']);
$cc->cropToDimensions($_GET['x1'], $_GET['y1'], $_GET['x2'], $_GET['y2']);
$cc->saveImage($root.'/user_files/' . $path . '/'.$_GET['pic']);

//lets resize the image

$pic = $root.'/user_files/' . $path . '/'.$_GET['pic'];
$thumbpic = $root.'/user_files/' . $path . '/thumb/'.$_GET['pic'];

$img_info = getimagesize($pic);

switch($img_info['mime']){
	case'image/jpeg':
		$src = imagecreatefromjpeg($pic);
		$tsrc = imagecreatefromjpeg($pic);
	break;
	case'image/jpg':
		$src = imagecreatefromjpeg($pic);
		$tsrc = imagecreatefromjpeg($pic);
	break;
	case'image/gif':
		$src = imagecreatefromgif($pic);
		$tsrc = imagecreatefromgif($pic);
	break;
	case'image/png':
		$src = imagecreatefrompng($pic);
		$tsrc = imagecreatefrompng($pic);
	break;
}

$tmp = imagecreatetruecolor($width,$height);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$width,$height,$img_info[0],$img_info[1]); 

if(imagejpeg($tmp,$pic,100)){

	//fullsize created

	//create the thumb
    $thumb = imagecreatetruecolor($thumbw,$thumbh);
    imagecopyresampled($thumb,$tsrc,0,0,0,0,$thumbw,$thumbh,$img_info[0],$img_info[1]); 
    
    if(imagejpeg($thumb,$thumbpic,100)){
    	//thumbnail created
    	
    	//send them hom
    	if($_GET['from'] == 'change'){
			header('Location: '.$from_change);
		}else{
			header('Location: '.$redirect);
		}

    }else{

		$class = 'error';
		$result['title'] = 'There was a problem changing your image';
		$result['text'] = 'We could not create the full-size version. Please try again!';	
    
    }

}else{
	$class = 'error';
	$result['title'] = 'There was a problem changing your image';
	$result['text'] = 'We could not create the full-size version. Please try again!';		
}	

 

Thanks,

 

envex

I knew it :P

 

When i print_r()'d before it was just giving me image/jpeg so i passed it by.

 

I will give this a shot.

 

Thanks!

 

UPDATE

 

That didn't seem to work, and on further investigation it's not cropping the fullsize image either. It's just displaying the original uploaded and uncropped image.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.