I can upload and resize image - I need to apply a PNG or GIF border
07-30-2009, 01:27 AM
|
I can upload and resize image - I need to apply a PNG or GIF border
|
Posts: 14
|
I'm trying to compile a few php scripts together. I'm not good enough to write my own PHP code yet.
There is a script here I would like to use:
http://bokehman.com/watermark
The error I am getting is "Cannot modify header information - headers already sent"
Here is the code so far:
PHP Code:
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ; $modwidth = 400; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ;
$save = "images/sml_" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "<img src='images/".$imagepath."'><br>"; } } ?>
|
|
|
|
07-30-2009, 03:59 PM
|
Re: I can upload and resize image - I need to apply a PNG or GIF border
|
Posts: 9
Name: Daniel
|
Try this:
PHP Code:
<?php
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "images/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "images/" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "images/sml_" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 80;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$myImage = $imagepath;
}
}
?>
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
</form>
<img src='images/<?=$myImage ?>'><br>
__________________
Daniel S.
Please login or register to view this content. Registration is FREE Toronto
|
|
|
|
07-30-2009, 04:01 PM
|
Re: I can upload and resize image - I need to apply a PNG or GIF border
|
Posts: 9
Name: Daniel
|
Just a quick look at it - if that doesnt do the job - let me know, I will write it for you, no problem.
__________________
Daniel S.
Please login or register to view this content. Registration is FREE Toronto
|
|
|
|
|
« Reply to I can upload and resize image - I need to apply a PNG or GIF border
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|