Hi again,
I seem to have messed something up as I'm receiving this error message:
Array ( [0] => IMconvert.exe: unable to open image `C:\Documents': No such file or directory @ error/blob.c/OpenBlob/2658. [1] => IMconvert.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501. [2] => IMconvert.exe: unable to open image `and': No such file or directory @ error/blob.c/OpenBlob/2658. [3] => IMconvert.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501. [4] => IMconvert.exe: unable to open image `Settings\adam.capps\Local': No such file or directory @ error/blob.c/OpenBlob/2658. [5] => IMconvert.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501. [6] => IMconvert.exe: unable to open image `Settings\Temp\php430.tmp': No such file or directory @ error/blob.c/OpenBlob/2658. [7] => IMconvert.exe: unable to open module file `C:\ImageMagick\modules\coders\IM_MOD_RL_TMP_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/672. [8] => IMconvert.exe: no decode delegate for this image format `TMP' @ error/constitute.c/ReadImage/501. [9] => IMconvert.exe: unable to open image `and': No such file or directory @ error/blob.c/OpenBlob/2658. [10] => IMconvert.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501. [11] => IMconvert.exe: unable to open image `Settings\adam.capps\Local': No such file or directory @ error/blob.c/OpenBlob/2658. [12] => IMconvert.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501. [13] => IMconvert.exe: unable to open image `Settings\Temp\php430.tmp': No such file or directory @ error/blob.c/OpenBlob/2658. [14] => IMconvert.exe: unable to open module file `C:\ImageMagick\modules\coders\IM_MOD_RL_TMP_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/672. [15] => IMconvert.exe: no decode delegate for this image format `TMP' @ error/constitute.c/ReadImage/501. [16] => IMconvert.exe: no images defined `Homer.tif' @ error/convert.c/ConvertImageCommand/3187. )
This is the code I'm using:
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"]);
// Additional variables
// $docroot = $_SERVER['DOCUMENT_ROOT'];
// $scriptroot = $_SERVER['SCRIPT_FILENAME'];
// $location = "\\\\sohced004\\cedscans$\\ENT";
// 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 rgba(0,0,0,0.5) -pointsize 50 -gravity Center -annotate 40x40+0+0 \"$text_submitted\" -write $original_image " ;
// Comment 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);
// Uncomment this line to view the image path
// echo "The new image is saved as $new_image<br>";
// Uncomment this line to view the image
echo "<img src=\"$new_image\"><br>";
echo "Graded image saved as: <a href=\"$new_image\">$new_image</a>";
echo "<BR />";
echo "<BR />";
echo "Graded text: <B>$text_submitted</B>";
echo "<BR />";
echo "<BR />";
if ( !empty($array) ){
echo "<br />There were errors grading the image<br />
<pre><br />".print_r($array)."<br>";
echo "</pre>";
}
}
else { ?>
<html>
<head>
<!-- <script type="text/javascript" src="calendarDateInput.js"></script> -->
</head>
<body>
<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 />
<input type="text" name="text_submitted" /><br /><BR /><BR />
<!-- <script>DateInput('orderdate', true, 'DD-MON-YYYY')</script><BR /> -->
<!-- <input type="button" onClick="alert(this.form.orderdate.value)" value="Show date value passed"> -->
<input type="Submit" name="Submit" value="Grade File" />
</form>
</body>
</html>
<?php } ?>
The intriguing part is the line:
unable to open image `C:\Documents' IMconvert seems to be trying to save the image to a temporary location or perhaps the C:\Documents and Settings\Username\etc...
I can't imagine where it is getting that from unless it is from the original file's localtion, which it shouldn't be as I've tried variations such as C:\Test.
Any thoughts
Thanks,
Adam.