Re: [PHP] Php and Imagemagick problems

2009-06-10 Thread Simon
What exactly is the problem or error message you get?

Also if this is your script, really, it needs a LOT of cleanup!!

Here's an example that could point out the problem:

>  $FileName =
> str_replace(".jpg", "", $FileName);
>
>  $FileName =
> str_replace("/", "", $ImageName);
>  $FileName = str_replace(".jpg", "",
> $ImageName);
>
>   //actual path to the files with NO file extension
> as found on the hard drive
> $SysPath =
> "C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/test/$FileName";

You realize that you have overwritten the value in $FileName a couple
times in a useless manner?
Here you see, $FileName is _just_ equal to str_replace(".jpg", "",
$ImageName); and nothing more, the 2 previous lines are useless.

Also, you do realize that str_replace("/", "", $ImageName);  will just
strip out the slashes from $ImageName?  So if i have
"some/path/to/some/image.jpg", it would become
"somepathtosomeimage.jpg"... is this really what you want?  Same thing
for the str_replace(".jpg")  it strips out the extension so that
$Filename would be something like "image" and not "image.jpg".
Finally, $SysPath has forward slashes in the windows path, i'm not
sure how PHP can tolerate this on windows, but windows path use
backslashes ( like this: C:\some\path\to\some\image.jpg).

Good luck!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Php and Imagemagick problems

2009-06-09 Thread Miller, Terion
I am having a heck of a time getting a script to convert images to
workit worked fine for a few hours, then someone "tweaked it" and now it
doesn't work and I can't get it back...they "tweaked" the original file

The script runs and uploads files but no longer "converts" them with the
ImageMagick..wondering if anyone else has run into this

Code:
--

// -- Get Images from
folder--- //

 $FileName = $row['Image'];   

 $ImageName = $row['Image'];
 
 $ImageName = str_replace("/",
"", $ImageName);
 
 
 
 //the many confusing paths
 

//Local path on localhost of image names with NO file extenstion on them as
seen through the webserver
 $FilePath =
"http://127.0.0.1/HarrisAutomate/output/WebImagesHiRes/test/$ImageName";;


 
 //same as $SysPath not sure why - as of this point
$FileName and $ImageName are the same thing
 $FullSysPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/test/$ImageName";

 $BackupPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/backup/test/";
  


//add jpg extenstion to the filename stored in the harris folder


$FileName = str_replace("/", "", $FileName);
  
  $FileName =
str_replace(".jpg", "", $FileName);
 
 
  $FileName =
str_replace("/", "", $ImageName);
  $FileName = str_replace(".jpg", "",
$ImageName);
  
   //actual path to the files with NO file extension
as found on the hard drive
 $SysPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/test/$FileName";

 
 
  //lets do some echos
  echo $FileName .'';
  echo
$ImageName  .'';

// include ("VariableReveal3.php");

  
echo
($FileName) . '';
echo ($FilePath) . '';
echo '' . '';

 if (file_exists($SysPath))   {
echo
"The file $ImageName Exists!! Hooray!!"  . '';


} else {

echo "The file $FileName located at $SysPath does not exist"  . '';
}




//--If they exist go ahead and convert them
WINDOWS VERSION//


if (file_exists($SysPath)) {
  
  
   $command =
"convert.exe mogrify -format eps *.jpg -normalize -density 200x200 -trim
-resize 150 -colorspace rgb -filter Sinc -quality 100 ñtrim -identify
-verbose ";
$command .= addslashes($SysPath . $FileName) ." ";

$command .= addslashes($FilePath . $FileName) .".jpg";
   
  /*

$command = "convert.exe -normalize -density 200x200 -trim -resize 150
-colorspace rgb -filter Sinc -quality 100  -identify -verbose ";

$command .= addslashes($SysPath) ." ";
  $command .=
addslashes($FullSysPath) ." ";
 */
  
//echo the command for
the image not so magick
   echo $command . "";


//--Error Reporting about the
Conversions-//



if (system($command, $status) === false) {
echo ($command).
'';

 echo "Image Failed" . '';
} else {

echo "Image Processed" . '';
  }


 


//---Once Converted Then connect to the php
server online//


$ftp_server = "20.20.20.20.";

 $ftp_user_name = "blah blah ";

 $ftp_user_pass = "blahblah";


 $conn_id = ftp_connect($ftp_server);

  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);


$FilePath =  
"http://127.0.0.1/HarrisAutomate/output/WebImagesHiRes/$FileName";;

$remote_path = "/httpdocs/Announcements/photos/obitsTest/$ImageName";


echo "I'm going to upload $FilePath to $remote_path." . '';


set_time_limit(120);
ftp_pasv($conn_id, true);

// upload a
file
if (ftp_put($conn_id, $remote_path, $SysPath, FTP_BINARY)) {

echo "successfully uploaded $ImageName\n";
} else {

echo "There was a problem while uploading $ImageName\n";
}


 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php