By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,364 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,364 IT Pros & Developers. It's quick & easy.

image magick and mogrify

P: n/a
Can anyone give me some simple function for resizing images and
thumbnail creation with image magick (I can't install GD2 on my Mac (OSX

I have functional upload function (well, not function, but part of
script...) and now I need to create thumbnails. but how?

I think I will use this set of lines:

$smal = "150";
$newtmb = "mogrify -thumbnail {$smal}x{$smal} $phfile";

I think I have to copy files to new location. new location is "tmb"
directory inside of users dir. (complete path will be:
so, in thumb function I will need a copy line? maybe like this:

copy($phfile1, $phfile2);

and where to describe to my script what is new, what old $phfile?

$phfile1 = "$sitepath/$galerpath/$uname/$phfile";
$phfile2 = "$sitepath/$galerpath/$uname/tmb/$phfile";

so, for my function... will it be something like this:

function photo_thumbnail() {
global MOGRIFY,$sitepath,$galerpath,$uname,$phfile;
$blabla = copy($phfile1, $phfile2);
$newtmb = "mogrify -thumbnail {$smal}x{$smal} $phfile";

I'm afraid it won't work... but I hope I'm not far from the solution...

here is my upload part:

if ($send) {
$query = "SELECT uname FROM user_basic WHERE uid='$uid'";
$result = mysql_query ($query) or die ("Query failed ($query)");
list($uname) = mysql_fetch_array($result);
$uploaddir = "$sitepath/$galerpath/$uname/";
$names = array($name_photo['numbr']['photo_name']);
while (list($key,$phfile) = each($_FILES['userfile']['name'])) {
$uploadfile = $uploaddir . basename($phfile);
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key],
$uploadfile)) {
echo "file [$phfile] uploaded";
mysql_query("INSERT INTO slike (ph_name,ph_file,ph_txt,uid) VALUES
} else {
echo "$uid - something is wrong";

can anyone help me with this? (not to mention that I will need later
some size check of uploaded image... but this one is more important. and
than double names... ouch...)

Jan ko?
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.