fmw42 wrote:cappsie wrote:Hi,
I have the tif watermarking working. I haven't been able to get the -path working correctly - if you have pointers, I'd appreciate it.
Thanks,
Adam.
Please clarify. What -path? Are you using mogrify or convert? What is your exact command?
If mogrify, you must create a new directory to hold the output images before using mogrify. IM cannot create a new directory.
see
http://www.imagemagick.org/Usage/basics/#mogrify
I do not believe that convert uses -path. You just specify the path for the output in the filename. The convert options page needs to modified to not that -path is for mogrify, if I am not mistaken about my comment.
Hi,
I've pasted the code below:
Code: Select all
<?php
function clean($name, $max) {
// Remove everything except letters numbers . and @ in the variable
preg_replace("/[^A-Za-z0-9.\-_@]/","",$name);
// Do not allow excessively long entries - length set in function call
// Could use a word wrap here - add a \n after a certain amount of characters
$name = substr($name, 0, $max);
return $name;
}
// If the form has been submitted do this
if(isset($_FILES['filename']['tmp_name'])) {
// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];
$filePath = realpath($_FILES["filename"]["tmp_name"]);
// Name to save the image as - in this case the same as the original
// The same folder as the code
$new_image = $_FILES['filename']['name'];
// Cleanup the text.
$text_submitted = clean ( $_POST['text_submitted'], 18 );
// Build the imagemagick command - using rgba so the opacity of the text can be set
// $cmd = "$original_image -font C:/Windows/Fonts/ARIAL.TTF -fill black -pointsize 50 -gravity south -annotate +0+0 \"$text_submitted\" -fill white -annotate +3+3 \"$text_submitted\" -fill blue -annotate +5+5 \"$text_submitted\" -write $original_image " ;
$cmd = "$original_image -font C:/Windows/Fonts/ARIAL.TTF -fill rgba(0,0,0,0.4) -pointsize 50 -gravity south -annotate +0+0 \"$text_submitted\" -write $original_image " ;
// Coment out to display the command - good for debugging
//echo $cmd;
// Setup the array for the error reporting
$array = array();
// The array is to hold any errors you may get
// Comment out the if function after debugging
exec("C:/ImageMagick/IMconvert $cmd $new_image 2>&1", $array);
echo "Graded image saved as: <a href=\"$filePath\"> $original_image s </a>";
echo "<BR />";
echo "<BR />";
echo "Graded text: <B>$text_submitted</B>";
if ( !empty($array) ){
echo "<br />There were some errors during the Imagemagick conversion:<br />
<pre><br />".print_r($array)."<br>";
echo "</pre>";
}
}
else { ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<label>Upload file for grading</label>
<input type="file" name="filename" /><BR /><BR />
<label>Grading Text</label>
<input type="text" name="text_submitted" /><br /><BR /><BR />
<input type="Submit" name="Submit" value="Grade File" />
</form>
<?php } ?>
Once the tif image has been watermarked, I wanted to offer a link to download it. Oddly I'm only seeing the Windows temporary directory. I suspect either my variables are wrong or the convert command can only display the Widows temp folder.
I've looked over the links you've offered, but I didn't really find anything that helped. However, this page did offer what I need, though I'm unable to work it into the current code:
http://salman-w.blogspot.co.uk/2008/11/ ... using.html
Are you able to assist?
Sorry for being a n00b. :-/
Thanks,
Adam.