CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
i have an emergency please help

 

First page Previous page 1 2 Next page Last page  View All


gerble1000
User

Aug 15, 2012, 2:42 PM

Post #26 of 35 (1836 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

am i right in saying that it needs to be associated with c:/php/php.exe or is there some other exe ot should be associated with


FishMonger
Veteran / Moderator

Aug 15, 2012, 2:48 PM

Post #27 of 35 (1835 views)
Re: [gerble1000] i have an emergency please help [In reply to] Can't Post

That is what the .php extension should be associated with so that you can execute the scripts without prepending php.

If you can't execute the script directly, then that file type association is not setup correctly.


(This post was edited by FishMonger on Aug 15, 2012, 2:49 PM)


gerble1000
User

Aug 16, 2012, 6:53 AM

Post #28 of 35 (1823 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

ok i am now getting the error message from your script,
i have reinstalled php finally ,

Code
my $command = 'C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/myhiddendomainname/roundimage.php';  

system($command) == 0 or die "system call failed $?";


this is the error message

system call failed 256 at C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin/mydomainname//update2.pl line 20.

line 20 is the system command


gerble1000
User

Aug 16, 2012, 6:58 AM

Post #29 of 35 (1821 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

if i use this command
system('c:/php/php roundimage.php');
it works fine but outputs lots of junk code to the screen after it finishes like so.


Code
PNG  IHDRY IDATxwxՙ?}Fj\r7%Y$$rwMnؔˆ$6҃M %{cma["ɶz4M?d$}=cKr{{rF=BQ.9 `3#<fwNw.O9?W4~ tࡍ0?gFV>}iPi#ɇIF|sdgn8N !t'ôXBܮi]my'y{.<o iZl7 !lB4MGyM&q3=Ox y›GgD!Mc4wD+xG7<㬐'y{.<4.:#fjUy|дj#<›9g+΁NS3:H?l7b}:?`XiB~$GyGyG2lClvpIxP#<#<#GzExnyGyG?~jnW&9ȯ3ޏs{shmD36{:7ÛGst:B?!<#<#<>x4=GyGyU-p:A1ėJCȧ4m#?ȧ4+) |JCtSt:]@<#<#<n) 6'<#<#< BT#<#<UlJ[GyB7Ŀ9gbjӡƳP[4@{pn8W۟KrQ+bmPVKpI~6߃1Ը<>Jj͚}pk4c hg4k_f3ޟdd


just lots of this stuff.
but that does work but does not finish the perl script and show the print"successfully finished";


FishMonger
Veteran / Moderator

Aug 16, 2012, 7:09 AM

Post #30 of 35 (1818 views)
Re: [gerble1000] i have an emergency please help [In reply to] Can't Post

Looks like you need to troubleshoot the roundimage.php script.

If you want to have better control over the execution and output of the php script, then instead of using a system call, you should use IPC::Open3.
http://search.cpan.org/~rjbs/perl-5.16.1/ext/IPC-Open3/lib/IPC/Open3.pm

BTW, the 256 exit code needs to be bit shifted to get the actual code, which in this case is an exit code of 1. Does the php script have an explicit exit statement?


gerble1000
User

Aug 16, 2012, 7:21 AM

Post #31 of 35 (1817 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

this is the php script


Code
<?php 

$sourceImageFile = "file.jpg";
$radius = "20";
# test source image
if (file_exists($sourceImageFile)) {
$res = is_array($info = getimagesize($sourceImageFile));
}
else $res = false;

# open image
if ($res) {
$w = $info[0];
$h = $info[1];
switch ($info['mime']) {
case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
break;
case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
break;
case 'image/png': $src = imagecreatefrompng($sourceImageFile);
break;
default:
$res = false;
}
}

# create corners
if ($res) {

$q = 5; # change this if you want
$radius *= $q;

# find unique color
do {
$r = rand(0, 255);
$g = rand(0, 255);
$b = rand(0, 255);
}
while (imagecolorexact($src, $r, $g, $b) < 0);

$nw = $w*$q;
$nh = $h*$q;

$img = imagecreatetruecolor($nw, $nh);
$alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
imagealphablending($img, false);
imagesavealpha($img, true);
imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);

imagefill($img, 0, 0, $alphacolor);
imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);

imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
imagealphablending($img, true);
imagecolortransparent($img, $alphacolor);

# resize image down
$dest = imagecreatetruecolor($w, $h);
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);

# output image
$res = $dest;
imagedestroy($src);
imagedestroy($img);
}




header('Content-type: image/png');
imagepng($res, "file.png");
Imagepng($res);
imagedestroy($res);
?>



FishMonger
Veteran / Moderator

Aug 16, 2012, 7:51 AM

Post #32 of 35 (1814 views)
Re: [gerble1000] i have an emergency please help [In reply to] Can't Post

The "junk code" you refer to is the png image.

I'm not going to get involved in your php coding, other than to suggest adding an exit(0) statement at the end;


gerble1000
User

Aug 16, 2012, 7:57 AM

Post #33 of 35 (1812 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

ok i have added the exit code and it still does the same. why would it be showing the junk code anyway


FishMonger
Veteran / Moderator

Aug 16, 2012, 8:05 AM

Post #34 of 35 (1810 views)
Re: [gerble1000] i have an emergency please help [In reply to] Can't Post

Because that's what the last section of code tells it to do.


gerble1000
User

Aug 16, 2012, 8:26 AM

Post #35 of 35 (1808 views)
Re: [FishMonger] i have an emergency please help [In reply to] Can't Post

your a genius i got it.
i removed the Imagepng($res);
at the end of the php code and that stopped it trying to output the image as all i wanted to do was to save the file.png to folder.
now all i had to do with the script was to add php to the system command and now it all works.
now time to start with using loops in that awfull script.
thankyou fishmonger :)

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives