SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2001
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DJPEG, CJPEG and PNMSCALE alternatives??

    Hi all!
    My web host does'nt seem to support the DJPEG, CJPEG and PNMSCALE utils..I'm told that I can use GD library instead. Now, the prob is I an NEW to PHP and have no idea how to write the following "un-supported" lines with GD "alteratives". Could someone PLEASE PLEASE help?

    $x = 100;
    $y = 150;
    $tmp_tmb = "/tmp/$newname.tmb";
    $command = "djpeg -pnm $filename | pnmscale -xsize $x -ysize $y | cjpeg > $tmp_tmb";
    system($command);
    echo $tmp_tmb;

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does your code resize an image and print it to the browser?

    If it does see this:

    http://www.sitepointforums.com/showt...threadid=33888

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Member
    Join Date
    Sep 2001
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    here's my code

    it doesn't work:

    function copy_file($filename,$newname, $orientation)
    {
    global $dir_arq;
    global $dir_thumb;

    $file = basename($filename);

    $tmp_upload_path = "/tmp/";
    $new_file_name = $dir_arq . $newname;
    $new_thumb_name = $dir_thumb . $newname;

    $size = GetImageSize($filename);
    $width = $size[0];
    $height = $size[1];

    if ($orientation == 0 )
    {
    //Landscape
    $x = 150;
    $y = 100;
    }
    else
    {
    //portrait
    $x = 100;
    $y = 150;
    }
    $src = ImageCreateFromJpeg($filename);
    $dst = ImageCreate($x,$y);
    ImageCopyResized($dst, $src, 0, 0, 0, 0,$x,$y,$width,$height);
    ImageJpeg($dst, $new_file_name, 1);


    if ( copy($src, $new_file_name) )
    {
    echo "copied to archive folder!";
    if ( copy($dst, $new_thumb_name) )
    {
    echo "copied to thumbnail folder";
    return true;
    }
    else
    {
    echo "<script> alert('Error copying to thumbnails folder!');document.location.href=\"index.php?SID=$SID\" ;</script>";
    }
    }
    else
    {
    echo "<script> alert('Error copying to archives folder!');document.location.href=\"index.php?SID=$SID\" ;</script>";
    }
    return false;
    }
    ImageDestroy($src);
    ImageDestroy($dst);

    if ( $img == "ok" )
    {
    $sql = "INSERT INTO images (img_description, img_date, img_format, FK_cat_id, FK_phot_id, img_name, img_orientation, img_photographer, img_caption) VALUES ('$description', '$gbl_date','$File_type', '$category', '1', '$File_name', '$orientation', '$photographer', '$caption')";
    mysql_query( $sql );

    $idget = mysql_insert_id();

    //imagem
    copy_file($File, $idget, $orientation );

    echo "<script> alert('Inserted picture successfully!');document.location.href=\"index.php?SID=$SID\" ;</script>";

    }


    I'v even asked my friend to post thins one in the php-list yahoo groups and still no luck :-(


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •