dezkit Posted November 6, 2008 Share Posted November 6, 2008 Hey, I have this code: if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "<font color=\"red\" size=\"+1\">Image has been uploaded!</font><br><br>"; if (file_exists("./uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { $filename = $_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["tmp_name"], $target); $thumbn = $sein . "th-" . $fale; cropImage(83, 60, "$target", "$ext", "$thumbn"); include("config.php"); $thumbnailss = "th-".$fale; mysql_query("INSERT INTO gallery (thumb_url, full_url) VALUES('$thumbnailss', '$fale' ) ") or die(mysql_error()); } } How do i make it so that the file is going to be re sized half its size? There are no tutorials on this, i have searched google, thanks guys. Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/ Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 I have found this code: <?php // File and new size $filename = 'test.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?> But how do i implement that code into my code? Thanks Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683410 Share on other sites More sharing options...
Third_Degree Posted November 6, 2008 Share Posted November 6, 2008 cropImage()? Are you using ImageMagick? Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683420 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 cropImage()? Are you using ImageMagick? That's a function I created to make a thumbnail of the uploaded file, but this is what i want user uploads an image (done) uploaded image gets half sized and saved to /uploads/ (getting help from you guys!) using my function cropImage() to crop the uploaded image and save the image to /uploads/ (done) Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683422 Share on other sites More sharing options...
Third_Degree Posted November 6, 2008 Share Posted November 6, 2008 I'm sorry for not understanding but when you say half sized, do you literally mean half of the bytes or half the resolution? If it's resolution, just use the code you found without the header() line, and using a second parameter for imagejpeg() (http://www.php.net/imagejpeg if you haven't used this before). If you need more help, I guess I could whip you up some code. Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683425 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 Half resolution, but i don't really know how to do it, i can't mess with the code or i can ruin it. Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683427 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 bump before i go to sleep, night guys Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-683439 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 bump ;P Link to comment https://forums.phpfreaks.com/topic/131582-php-image-resize/#findComment-684064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.