Jump to content

imagecopyresampled doing weird things


kredd

Recommended Posts

got a two-parter...

 

1. any reason why the code below would create a thumbnail but then not have a browser recognize it? the browser displays the original it was copied from and photoshop and fireworks both recognize it.

 

2. if i imagecopyresampled a 2400x3000 jpg down to a 100 px thumb, it looks like the thumb was cropped and resized inside the orig photo size...so it's a 100px thumb inside a 2400x3000px black box - and if i use imagecopyresized i just get a 2400x3000px black box.

 

 

if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$file_dest))) {
           
        
	$newname = '/my/server/path to/images/gallery/' . $dest_fldr . '_tmb/' . $filename_tmb; // file path on server for tmb
  		copy($file_dest, $newname);
	$thumbWidth = 100; // set witdth of thumbnails
	header('Content-type: image/jpeg');
	$new_img =  imageCreateFromJPEG($newname);
	$width = imagesx($new_img);
    	$height = imagesy($new_img);

	$new_width = 100; // width of thumbnail
	$new_height = floor( $height * ( $thumbWidth / $width ) ); // height of thumbnail

	$tmp_img = imagecreatetruecolor( $width, $height ); // temp big image

	imagecopyresampled( $tmp_img, $new_img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // create big

	// save the new images to their folders
	imagejpeg( $tmp_img, $newname,50 );
	imageDestroy($tmp_img);
	imageDestroy($new_img);

 

any ideas?? thanks!

Link to comment
https://forums.phpfreaks.com/topic/53312-imagecopyresampled-doing-weird-things/
Share on other sites

not sure i understand your reply....yes, it's being sent to a file, a .jpg file, right?? when i type in the url to that .jpg i get a 'page not found' error. it doesn't show up in my gallery either. but i can download it and open it up in photoshop and fireworks just fine.

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.