01. september 2005 - 08:53Der er
31 kommentarer og 1 løsning
Vandmærke af billede.
Hej, jeg har et script der uploade et billede til servern også ville jeg skrive det sammen med et vandmærke script, men det kan jeg ikke få til at virke, da jeg ikke er den store php haj. De 2 scripts kan ses nedeunder
upload script:
<?php
include('includes/config.php');
include('allows.php'); // Name of the uploaded file if($image != "") { // Random 25 chars+nums . . . $your_25_digit_code = substr(md5(rand(0,9999)), 17, 25); // Get the file apart by ., so the 25 chars can be added before the extension $temp_arr = explode(".", $image_name); // Default it $original_name = ''; // Make sure the file isn't something like // image.something.whatever.hi.hello.what.s.up.png // Minus 2 because it would come out to // (file_name).(random_chars).(extension), // with this it comes out to (file_name)(random_chars).(extension) for ($x = 0; $x < count($temp_arr)-2; $x++) { // Add to it $original_name .= $temp_arr[$x] . '.'; } // The new file name $new_file = $original_name . $temp_arr[$x] . $your_25_digit_code . '.' . $temp_arr[$x+1];
// Load function require("./phpWatermark.inc.php");
// Instantiate phpWatermark // The only parameter currently required is the name // of the image, which should get marked $wm = new watermark("/path/to/image.png");
// Optionally specify the position of // the watermark on the image $wm->setPosition("RND");
// Optionally specify a fixed color for the text $wm->setFixedColor("#FF00FF"); // or $wm->setFixedColor(array(255, 0, 255));
// Add a watermark containing the string // "phpWatermark" to the image specified above $wm->addWatermark("phpWatermark", "TEXT");
// Fetch the marked image $im = $wm->getMarkedImage();
Med kunstig intelligens skaber HP’s nye OmniBook X 14 en unik og skræddersyet brugeroplevelse målrettet dem, der ønsker høj ydeevne og intelligente funktioner
Nu fik jeg den her: Your current PHP setup does not support images Ved godt hvad det betyder, men hvad kan jeg gøre ved det? Er det fordi jeg har lavet koks i scriptet?
// Load function til vandmærkning require("./phpWatermark.inc.php");
include('includes/config.php');
include('allows.php'); // Name of the uploaded file if($image != "") { // Random 25 chars+nums . . . $your_25_digit_code = substr(md5(rand(0,9999)), 17, 25); // Get the file apart by ., so the 25 chars can be added before the extension $temp_arr = explode(".", $image_name); // Default it $original_name = ''; // Make sure the file isn't something like // image.something.whatever.hi.hello.what.s.up.png // Minus 2 because it would come out to // (file_name).(random_chars).(extension), // with this it comes out to (file_name)(random_chars).(extension) for ($x = 0; $x < count($temp_arr)-2; $x++) { // Add to it $original_name .= $temp_arr[$x] . '.'; } // The new file name $new_file = $original_name . $temp_arr[$x] . $your_25_digit_code . '.' . $temp_arr[$x+1];
// Vandmærkning $wm = new watermark("$newb_file"); // Optionally specify the position of // the watermark on the image $wm->setPosition("RND");
// Optionally specify a fixed color for the text $wm->setFixedColor("#FF00FF"); // or $wm->setFixedColor(array(255, 0, 255));
// Add a watermark containing the string // "phpWatermark" to the image specified above $wm->addWatermark("phpWatermark", "TEXT");
// Fetch the marked image $im = $wm->getMarkedImage();
Stadig den samme fejl. Fandt dette i include filen: Det tyde lidt på jeg ikke har GDLib installeret, hvordan finde jeg precist ud af det?
// Public Watermark // You need to specify either a filename or an image resource // when instatiating phpWatermark function Watermark($res) { list($this->type, $this->image) = $this->_getImage($res);
if (!$this->image) { $this->_die_error("Your current PHP setup does not support ". $this->type ." images"); }
/***************************************************/ /* File types/Extensions you allow for upload */ /* NOTE: DO NOT!!! touch the 'pjpeg', it's so */ /* Firefox will work with this script. */ /***************************************************/ $types_array = array('image/gif','image/jpeg','image/pjpeg','image/jpg','image/png','image/bmp','image/tiff');
<left>| <a class="toplinks" href="/index.php"> TILBAGE </a> <?php
/**********************************/ /* DO NOT TOUCH !!! */ /* No relevant data */ /**********************************/
include('includes/config.php');
if($_POST['upload']) {
if($_FILES['image']['name'] == "") { echo "<font color=red>Vælg venligst et billede!\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
if(!in_array($_FILES['image']['type'], $types_array)) { echo "<font color=blue>Den filtype er ikke tiladt!\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
$max_filesize_kb = ($max_filesize / 1024);
if($_FILES['image']['size'] > $max_filesize) { echo "<font color=blue>Dit billede overskrider grænsen på </font>".$max_filesize_kb."<font color=blue> kb\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
if($imagewidth > $maxwidth || $imageheight > $maxheight) { echo "<font color=blue>Dit billede er for stort,billedet må være op til </font>".$maxwidth."<font color=blue> x </font>".$maxheight."<font color=blue> size\n</font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; } move_uploaded_file($_FILES['image']['tmp_name'], $uploads.'/'.$_FILES['image']['name']) or die ("Couldn't upload ".$_FILES['image']['name']."\n"); }
<left>| <a class="toplinks" href="/index.php"> TILBAGE </a> <?php
/**********************************/ /* DO NOT TOUCH !!! */ /* No relevant data */ /**********************************/
include('includes/config.php');
if($_POST['upload']) {
if($_FILES['image']['name'] == "") { echo "<font color=red>Vælg venligst et billede!\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
if(!in_array($_FILES['image']['type'], $types_array)) { echo "<font color=blue>Den filtype er ikke tiladt!\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
$max_filesize_kb = ($max_filesize / 1024);
if($_FILES['image']['size'] > $max_filesize) { echo "<font color=blue>Dit billede overskrider grænsen på </font>".$max_filesize_kb."<font color=blue> kb\n </font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; }
if($imagewidth > $maxwidth || $imageheight > $maxheight) { echo "<font color=blue>Dit billede er for stort,billedet må være op til </font>".$maxwidth."<font color=blue> x </font>".$maxheight."<font color=blue> size\n</font>"; include ('form.php'); for ($i=1; $i<=19; $i++) { echo "<br />";} include ('footer.php'); exit; } move_uploaded_file($_FILES['image']['tmp_name'], $uploads.'/'.$_FILES['image']['name']) or die ("Couldn't upload ".$_FILES['image']['name']."\n"); }
Så er der fest fyverkeri: Den der watermark.png den ikke kan finde er det, det nye billede?
Warning: imagecreatefrompng(watermark.png): failed to open stream: No such file or directory in /home/www/web1/html/allows.php on line 63
Warning: imagesx(): supplied argument is not a valid Image resource in /home/www/web1/html/allows.php on line 65
Warning: imagesy(): supplied argument is not a valid Image resource in /home/www/web1/html/allows.php on line 66
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/www/web1/html/allows.php on line 68
Warning: Cannot modify header information - headers already sent by (output started at /home/www/web1/html/allows.php:2) in /home/www/web1/html/allows.php on line 78
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/www/web1/html/allows.php on line 97
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/www/web1/html/allows.php on line 111
Troede den printet teksten på... Er ved at blive gak i hovedet af det script... Okay, nu har jeg lavet et vandmærke billede også er den her fejl:
Warning: Cannot modify header information - headers already sent by (output started at /home/www/web1/html/allows.php:2) in /home/www/web1/html/allows.php on line 78
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.