WebDevon Posted March 4, 2007 Share Posted March 4, 2007 I have search around for a bit and cant really find the answer to this. If anyone has a free moment a little help would be greatly appreciated. Thanks in advance.... I would like to create 2 additional images from an image that I have uploaded. the first additional image is to be 33% of the uploaded image size and saved to images/main while the 2nd image is to be 16% of the uploaded image size and saved to image/list the file is uploaded under $_FILES["file"]["name"] (files are already filtered out by jpg/gif only) Thanks so much , and please if you know of another place where this is answered please post the URL and i will immediately close this topic. Link to comment https://forums.phpfreaks.com/topic/41161-solved-help-with-images/ Share on other sites More sharing options...
Barand Posted March 4, 2007 Share Posted March 4, 2007 To create a file 33% of the size of the original, scale the height and width by a factor of 0.577. Similarly, for a file 16% of the original size, scale by 0.4. Link to comment https://forums.phpfreaks.com/topic/41161-solved-help-with-images/#findComment-199399 Share on other sites More sharing options...
WebDevon Posted March 4, 2007 Author Share Posted March 4, 2007 hmmmmmmm ok. Could you give me a sample line that would do such a thing? my line of thinking from the research iv done was a little off. I was thinking that i could get the original H X W and then go something like $n_height = imagesx($file) * 33 $n_wid..... etc.. However during that call i receive an error stating call to invalid function or unknown function, something along those lines. Link to comment https://forums.phpfreaks.com/topic/41161-solved-help-with-images/#findComment-199424 Share on other sites More sharing options...
Barand Posted March 4, 2007 Share Posted March 4, 2007 Assuming it's a jpg, here's code to creat the 33% version <?php $fn = $_FILES['file']['name']; $im = imagecreatefromjpeg($_FILES['file']['tmp_name']); //uploaded file $iw = imagesx($im); $ih = imagesy($im); $iw33 = $iw*0.57; $ih33 = $ih*0.57; $im33 = imagecreatetruecolor($iw33, $ih33); imagecopyresampled($im33, $im, 0,0,0,0,$iw33,$ih33,$iw,$ih); // output to file imagejpeg($im33, 'full/path/to/file/'.$fn, 100); imagedestroy($im); imagedestroy($im33); ?> Link to comment https://forums.phpfreaks.com/topic/41161-solved-help-with-images/#findComment-199476 Share on other sites More sharing options...
WebDevon Posted March 5, 2007 Author Share Posted March 5, 2007 works great! Thanks! Link to comment https://forums.phpfreaks.com/topic/41161-solved-help-with-images/#findComment-199517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.