40esp Posted June 7, 2008 Share Posted June 7, 2008 Im trying to follow a turorial located at: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php to resize images being uploaded. The tutorial says to use: <?php if( isset($_POST['submit']) ) { include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(150); $image->output(); } else { ?> I've modified it to my needs as so: <?php if( isset($_POST['upload']) ) { include('resize.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(150); $image->output(); } ?> but there is no option to output it to a specific directory... I don't understand what to do. Anyhelp would be appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 7, 2008 Share Posted June 7, 2008 The first 4 code examples at the tutorial link you posted show how to save an image to a file instead of outputting it. Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559867 Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 Yeah, it specifically shows the save() method. Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559879 Share on other sites More sharing options...
40esp Posted June 7, 2008 Author Share Posted June 7, 2008 How would I write it then? would i specify where to save the original upload before that script? can someone throw an example my way? Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559891 Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 Well, this is the save method: function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) So therefore, you can do: $image->save("picture2.png", IMG_PNG, 100, 755); That'll give you a PNG at picture2.png, with 100% compression (though I don't think you can use compression with PNG in this class), and you'll CHMOD it to 755. But think it's a bit unnecessary, and it may cause permission problems, so you can probably get away with: $image->save("picture2.png", IMG_PNG); Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559895 Share on other sites More sharing options...
40esp Posted June 7, 2008 Author Share Posted June 7, 2008 is there anyway in the save method that i could maintain the original filename? Thanks so much for everything so far. Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559900 Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 Yeah, just put the original filename into the function call, lol. Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559901 Share on other sites More sharing options...
40esp Posted June 7, 2008 Author Share Posted June 7, 2008 I know php but not to that extent in simpler terms. I dont know how to approach that basically. Im sorry Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559903 Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 Didn't realize you were using it with image uploads. This'll be the easier route: $image->save($_FILES['uploaded_image']['name'], $image->image_type); Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559911 Share on other sites More sharing options...
40esp Posted June 7, 2008 Author Share Posted June 7, 2008 THANKS! Link to comment https://forums.phpfreaks.com/topic/109146-solved-php-image-help/#findComment-559912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.