Hi all,
I'm looking to run a simple image resize option using ImageMagick.
I tried to combine script that I had with the functionality of ImageMagick but was hitting a wall. Probably over a silly mistake.
There are two files:
- Uploading the image file.
- Resizing the image file and displaying it.
The file is uploaded ok (I think), but fails on the processing
call.
//***** UPLOAD OF FILE ***
<?php
echo "<HTML>
<HEAD>
<TITLE>Upload Image</TITLE>";
echo "</HEAD><BODY>";
echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=\"0.php\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" align=\"right\">
<tr>
<td width=\"50%\">
<p align=\"right\">
<INPUT TYPE=\"FILE\" NAME=\"File\"></p>
</td>
</tr>
<tr>
<td width=\"50%\"><BR>
<p align=\"right\">
<INPUT TYPE=\"submit\" VALUE=\"upload image\"></p>
</td>
</tr>
<tr>
</tr>
</table>";
echo "<BR></FORM><BR><BR><BR><BR><BR><BR></p>";
echo "<p dir=\"rtl\">";
echo "</body></html>"
?>
//*** PROCESSSING THE FILE **
<?php
// get contents of a file into a string
$fd = fopen( $File, "r");
$data = addslashes(fread($fd, filesize($File)));
fclose($fd);
$size=getimagesize($File);
if($File_type=="image/jpeg" || $File_type=="image/pjpeg")
{
system("composite -gravity center -geometry 100x100 $File -size 100x100 xc:black > $File.tmb");
$fd = fopen( "$File.tmb", "r");
$tmb = addslashes(fread($fd, filesize("$File.tmb")));
fclose($fd);
unlink("$File.tmb");
}
echo "<HTML><HEAD><TITLE>Hello World!</TITLE>";
echo "</HEAD><BODY>";
echo "<img border=\"0\" SRC=\"$data\">";
echo "<BR>";
echo "<img border=\"0\" SRC=\"$tmb\">";
echo "<BR>";
echo "<BR>Size0: $size[0]<BR>Size1: $size[1]<BR></span></font></p>";
echo "</body></html>";
?>
So.. this I must be doing something wrong and would appreciate it if you have worked this sample before.
Thanks,
-Alon.
js@wsco.com
For those of you who are not familiar with it, ImageMagick is one of the best image manipulation softwares that are out there.
http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi
Just see what it does!