areuban Posted October 4, 2010 Share Posted October 4, 2010 hi guys, im new here! first post i need to crop images from a database or directory. ive downloaded scripts and use them on their own. when i try to call the function like this <img src="crop.php?x=10&y=20&w=30&h=40&src=templates/new/images/site_header.jpg"> nothing works! what am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/ Share on other sites More sharing options...
litebearer Posted October 4, 2010 Share Posted October 4, 2010 it would help if we could see the script you are using Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118875 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 thanks for the prompt reply ill post the code here shortly. Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118876 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 here is the script im using [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118883 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 here is the script im using [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118884 Share on other sites More sharing options...
BlueSkyIS Posted October 4, 2010 Share Posted October 4, 2010 that file has nothing but functions. where is the code that utilizes the functions? Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118893 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 i tried this to utlise the function. im a real novice, learning each day <img src="crop.php?x=10&y=20&w=30&h=40&src=templates/new/images/site_header.jpg"> Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118895 Share on other sites More sharing options...
BlueSkyIS Posted October 4, 2010 Share Posted October 4, 2010 that will not utilize the function. you need to write a PHP file called crop.php, which then accepts the values for x, y, etc. then utilizes those functions to do what you want. Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118897 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 <?php $w=$_GET['w']; $h=isset($_GET['h'])?$_GET['h']:$w; $x=isset($_GET['x'])?$_GET['x']:0; $y=isset($_GET['y'])?$_GET['y']:0; $filename=$_GET['src']; header('Content-type: image/jpg'); header('Content-Disposition: attachment; filename='.$src); $image = imagecreatefromjpeg($filename); $crop = imagecreatetruecolor($w,$h); imagecopy ( $crop, $image, 0, 0, $x, $y, $w, $h ); imagejpeg($crop); ?> Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118921 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 UPDATE: ok this is the script i have now (SimpleImage.php) then i created this :<?php if( isset($_POST['submit']) ) { include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(150); $image->output(); } else { ?> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_image" /> <input type="submit" name="submit" value="Upload" /> </form> How can i then output the resulting image as part of an html file? after it has resized and saved it? please help [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118978 Share on other sites More sharing options...
BlueSkyIS Posted October 4, 2010 Share Posted October 4, 2010 after you have the file saved, just put it in html like any other image file: echo "<img src='" . "/path/to/image" . "'>"; Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1119007 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 thanks, when i save the file, how can i make it automatically save it as the originalfile with a thumb suffix... eg. jack.jpg and after it is resized, save it as jackthumb.jpg? Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1119026 Share on other sites More sharing options...
areuban Posted October 4, 2010 Author Share Posted October 4, 2010 and after the upload form can i make it automatically display the resized image on the same page? Link to comment https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1119027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.