image magick and mogrify

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JaNE

    image magick and mogrify

    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
    v.10.3.5))?

    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:
    $sitepath/$galerpath/$uname/tmb/)
    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,$sitepa th,$galerpath,$ uname,$phfile;
    $blabla = copy($phfile1, $phfile2);
    $newtmb = "mogrify -thumbnail {$smal}x{$smal} $phfile";
    `$newtmb`;
    }

    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_arr ay($result);
    $uploaddir = "$sitepath/$galerpath/$uname/";
    reset($_FILES['userfile']['name']);
    $names = array($name_pho to['numbr']['photo_name']);
    reset($names);
    print_r($names) ;
    while (list($key,$phf ile) = each($_FILES['userfile']['name'])) {
    $uploadfile = $uploaddir . basename($phfil e);
    if (move_uploaded_ file($_FILES['userfile']['tmp_name'][$key],
    $uploadfile)) {
    echo "file [$phfile] uploaded";
    mysql_query("IN SERT INTO slike (ph_name,ph_fil e,ph_txt,uid) VALUES
    ('$ph_name','$p h_file','$ph_tx t','$uid'");
    } else {
    echo "$uid - something is wrong";
    print_r($_FILES );
    }
    }
    }

    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?
    fotografija = zapisano svjetlom | fotozine = foto-e-zin

    --
Working...