Page 1 of 1
incorporate thumbnail class in existing image upload script
Posted: Thu Sep 11, 2003 7:43 am
by mesz
Code: Select all
<?php
$img = new ImageMagick($_FILES[file_form]);
$img->setTargetdir('whereever');
$img->Resize(100,100);
$img->Save();
$img->CleanUp();
?>
How do I incorporate the above code for thumbnail creation via image magick into my existing image upload script?
Code: Select all
<?php
<?php
$imagesdir = "./images/";
if (isset($_FILES['f1'])) {
if (!move_uploaded_file($_FILES['f1']['tmp_name'], $imagesdir . $_FILES['f1']['name'])) {
echo ' error ';
} else {
echo ' good upload ';
}
} else {
echo'file uploads';
}
?>
?>
Using this form
Code: Select all
<form action="<?php echo $_SERVERї'PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
<p>
<input type="file" class="form" name="f1" /><br>
<br>
<input type="submit" class="button" value="Send the file"/>
</p>
</form>
Posted: Thu Sep 11, 2003 10:12 am
by xisle
if i am not mistaken you will need to use a system command to access imageMagick functions...
system("convert -geometry 150 $source $destination");
Posted: Thu Sep 11, 2003 10:33 am
by mesz
xisle wrote:if i am not mistaken you will need to use a system command to access imageMagick functions...
system("convert -geometry 150 $source $destination");
This system command is all new to me.
Thanks for the response, I have a lot more work to do here obviously...
Posted: Thu Sep 11, 2003 12:22 pm
by mesz
I used this code:
Code: Select all
<?php
<?php
$imagesdir = "./images/";
if (isset($_FILES['f1']) && $_FILES['f1']['size'] > 0) {
$bigImage = $imagesdir . $_FILES['f1']['name'];
if (!move_uploaded_file($_FILES['f1']['tmp_name'], $bigImage)) {
echo ' error ';
} else {
echo ' good upload ';
}
$img = new ImageMagick($bigImage);
$img->setTargetdir('./thumbs');
$img->Resize(100,100);
$img->Save();
$img->CleanUp();
}
if (isset($_FILES['f1'])) {
if (!move_uploaded_file($_FILES['f1']['tmp_name'], $imagesdir . $_FILES['f1']['name'])) {
echo ' error ';
} else {
echo ' good upload ';
}
} else {
;
}
?>
?>
but got this ERROR:
Code: Select all
good upload
Fatal error: Cannot instantiate non-existent class: imagemagick in /home/.sites/14/site467/web/pic/f2.php on line 15
and nothing was written to ./thumbs
Why is it a non-existent class?
Posted: Fri Sep 12, 2003 3:35 pm
by xisle
I use a system command to access the ImageMagick application on a Linux install. The ImageMagick class would not exist unless you have written it or installed classes for ImageMagick. That is why the error says the class does not exist.
Maybe you just need to include the class file from some libraries you have downloaded? Sorry don't have much info to go on here..
mesz wrote:
$img = new ImageMagick($bigImage);
$img->setTargetdir('./thumbs');
$img->Resize(100,100);
$img->Save();
$img->CleanUp();
Posted: Mon Sep 15, 2003 3:27 am
by mesz
I know he original question I posted was so vague as to be untrue.
At the time I posted it I really didn't even know what Image Magick or GD library were.
I needed an image gallery in a rush so I have not had time to battle creating one myself - I have instead downloaded a script.
( I cannot think of the URL at the moment, but if anybody reading this wants to know, just ask and I will look it up ).
However I have learnt enough in the process of trying to create an image gallery that I will now do it at my leisure.
Cheers for your input.