andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Help Required

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Functions
View previous topic :: View next topic  
Author Message
Adrian Fields
Newbie


Joined: 02 Mar 2007
Posts: 3

PostPosted: Fri Mar 02, 2007 3:24 pm    Post subject: Help Required Reply with quote

Hi,

This maybe complicated im a newbie at php and iv'e never used GD before but found this script extremely useful but i have problems and need help pointing me in the right direction i have a upload script which stores the images then passes the information on a click of a button to another page which i want the image function to work on and all i want the funtion to do is display the original image the have a dropdown with sepia and black and white in when one is selected it modifies the original but displays the edited image and not saves it is this possible and it must work with all images.

Code can be submitted to you via email as it will not let me post it on here....
Back to top
View user's profile Send private message Send e-mail
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sat Mar 03, 2007 3:41 pm    Post subject: Reply with quote

Hi, and welcome to the board!

When you say that it must work on all images you are actually limited by what your installation of GD can handle. Typically that's jpg, gif, png and wmp. If you need it to do tiffs, cymk images, or things of that nature then you wont be able to do it with GD - use ImageMagick for that (and not this class).

One way to do what you want is have the script that handles the file upload then display the image and form. This will then send the selected option, sepia tone or black and white, to another script which will do the update and display to the user. So let's pretend that the first file is called 'upload.php' and the second one is called 'update.php', and for ease we're going to assume you're uploading jpgs only, it might go something like this...

upload.php:

Code:
<?php

// file handling here...
// pretend that you've copied it to a folder called 'original'
// and that the $_FILES array is still populated...

?>

<img src="originals/<?php echo $_FILES['upload']['name']; ?>" />
<form action="update.php" method="post">
<input type="hidden" name="file" value="<?php echo $_FILES['upload']['name']; ?>" />
<select name="type">
    <option value="sepia">Sepia tone</option>
    <option value="greyscale">Grey scale</option>
    <option value="threshold">Black and white (threshold)</option>
</select>
<input type="submit" value="go!" />
</form>


update.php:

Code:
<?php

require('class.image.php');
$img = imagecreatefromjpeg('originals/'.$_POST['file']);
switch($_POST['type']) {
    case 'sepia':
        Image::sepia($img);
        break;
    case 'greyscale':
        Image::greyscale($img);
        break;
    case 'threshold':
        Image::threshold($img);
        break;
}
header('Content-type: image/jpg');
imagejpeg($img);

?>


That's the simplest way. If you wanted to display the updated image within some html then you might want to use an image tag something like this:

Code:
<img src="update.php?img=filename.jpg&option=sepia" />


and then the update.php script would use the $_GET array rather than $_POST.

That should give you abroad enough overview on how to use it with different options.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Adrian Fields
Newbie


Joined: 02 Mar 2007
Posts: 3

PostPosted: Sun Mar 04, 2007 7:06 am    Post subject: Thanks Reply with quote

Thanks for your help but im extremely confused i'm very new at PHP and i am having problems with my upload script passing the correct information on to the second part of my script and although i appreciate you help im afraid im useless at it.
Back to top
View user's profile Send private message Send e-mail
Adrian Fields
Newbie


Joined: 02 Mar 2007
Posts: 3

PostPosted: Sun Mar 04, 2007 8:23 am    Post subject: Reply with quote

Hi Amnuts iv'e sent you an email if you would have a look at it for me.
also on the output when it displays the converted image can i add text to that like right click on the image to save if so can you tell me how and im sorry to bother you.
also this only works at the moment with JPEGS how would i go about making it work with GIF's and PNG'S so that no matter what one of the three images was selected it would identify the ext and do the relevant changes.

Cheers for your help...
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Functions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group