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;

    • [deleted]

    Please please start by reading the GD-function descriptions in the PHP manual.
    It's not that difficult.

      thanks a lot vincent! but, did I mention that I'm a newbie!!? I really dont know how to do it!! Anyone out there?

        • [deleted]

        Did you read the manual? it explains how to get the GD to work. Even a newbie should be able to do it.

          I tried vincent..invain :_(

          Here's what I ended up with:

          $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);
          ImageDestroy($src);
          ImageDestroy($dst);

          if ( copy($filename, $new_file_name) )
          {
          echo "copied to archive folder!";
          if ( copy($tmp_tmb, $new_thumb_name) )
          {
          echo "copied to thumbnail folder";
          return true;
          }
          else
          {
          echo "Error copying to thumbnail folder!!.<br>\n";
          }
          }
          else
          {
          echo "Error copying to archives folder!!<br>\n";
          }
          return false;
          }

          How would I get the thumbnail image in to the thumbnails folder?? Can the GD Lib functions be assigned to variables?? I mean, can I give:

          $thumb=ImageJpeg($dst, $new_file_name, -1); ???

          My basic aim here is to resize the src image and put the source and the thumbnail in to two different folders.

            • [deleted]

            What's the error you get?

            and since when can you give a 'quality' factor of -1?

            Did you read the manual sections about all those functions?

              NO LUCK! Its simply doesn't work :_(

              Please help! Here's the code:

              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 "<br><br><script> alert('Error copying to thumbnails folder!');document.location.href=\"index.php?SID=$SID\" ;</script>";
              }
              }
              else
              {
              echo "<br><br><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 "<br><br><script> alert('Inserted picture successfully!');document.location.href=\"index.php?SID=$SID\" ;</script>";

              }

                Write a Reply...