PHP + Imagemagick ! Need Help

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
macom
Posts: 3
Joined: 2011-02-05T00:34:38-07:00
Authentication code: 8675308

PHP + Imagemagick ! Need Help

Post by macom »

Hello, I have a website (...), I use a module for uplod images and integrate them into other images.
the first code works great

Code: Select all

 <? $surse = "tyu4526265sdfDDQ"; 
for ($i = 0; $i <15; $i++) 
    { 
     $newsurse[$i] = $surse[rand(0,60)];
     $newsurse2[$i] = $surse[rand(0,60)];
    } 
   	$jpg = 'temp/'.implode("",$newsurse).'.jpg';
   	$png = 'temp/'.implode("",$newsurse2).'.png';
exec('convert '.$imagesurse2.' -resize 409!x468! '.$imagesurse2.'');
exec("convert ".$imagesurse2." -matte -background none -rotate -30  ".$png);
exec("convert  ".$patch."/card20.png  ".$png."  -geometry -49+31 -compose DstOver -composite   ".$jpg);
exec('convert '.$jpg.'  -quality 80 '.$jpg);
@unlink($imagesurse2);
@unlink($png);
$imagesurse2=$jpg;
But in the second code it doesnt work ! (perspective...)

Code: Select all

<?
$surse = "tyu4526265sdfDDQ"; 

for ($i = 0; $i <15; $i++) 
    { 
     $newsurse[$i] = $surse[rand(0,60)];
	 $newsurse2[$i] = $surse[rand(0,60)];
    } 
   
   	$jpg = 'temp/'.implode("",$newsurse).'.jpg';
   	$png = 'temp/'.implode("",$newsurse2).'.png';
exec('convert '.$imagesurse2.' -resize 195!x150! '.$imagesurse2.'');

exec("convert -size 210x205 xc:transparent  ".$imagesurse2."   -set option:distort:viewport 210x205   -matte -virtual-pixel transparent  -distort Perspective '0,0,0,91  0,150,73,205  195,0,142,0  195,150,210,115'  -composite  ".$png."");

exec("convert  ".$patch."/banner56.png  ".$png." -geometry +0+0 -compose DstOver -composite  ".$jpg);
exec('convert '.$jpg.' -quality 60 '.$jpg);
@unlink($imagesurse2);
@unlink($png);
$imagesurse2=$jpg;
:( :( :( Help me please
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP + Imagemagick ! Need Help

Post by Bonzo »

But in the second code it doesnt work ! (perspective...)
This is not realy much help - what does work. Have you tried echoing the tempory images and see what is and is not created.

Perspective was changed and the version of IM you are using has an effect on what the coordiantes are - what version are you using?

Have you tried the perspective out seperatly on an image to see if it works ? Start simple and then include it into your code when its working.

Try changing this line and see if you get any errors ( you should not need to put your variables in quotes unless they are like $variable[0] ):

Code: Select all

$array=array();
echo "<pre>";
exec("convert -size 210x205 xc:transparent  $imagesurse2 -set option:distort:viewport 210x205 -matte -virtual-pixel transparent -distort Perspective '0,0,0,91  0,150,73,205  195,0,142,0  195,150,210,115' -composite  $png  2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
Without setting up your directory structure and having your images I can not try your code.
macom
Posts: 3
Joined: 2011-02-05T00:34:38-07:00
Authentication code: 8675308

Re: PHP + Imagemagick ! Need Help

Post by macom »

thank you I'll try that
macom
Posts: 3
Joined: 2011-02-05T00:34:38-07:00
Authentication code: 8675308

Re: PHP + Imagemagick ! Need Help

Post by macom »

the truth is that I did not understand all this !!
I explain the script in this link works very well http://www.goupix.com/effects/Monkey.php and that's the code :

Code: Select all

<?
$surse = "123qwertyu456789QWERThjklzYUIOPAxcvSDFGHVBNMiopasdfgbnmJKLZXC"; 

for ($i = 0; $i <15; $i++) 
    { 
     $newsurse[$i] = $surse[rand(0,60)];
	 $newsurse2[$i] = $surse[rand(0,60)];
    } 
   
   	$jpg = 'temp/'.implode("",$newsurse).'.jpg';
exec('convert '.$imagesurse2.' -resize 206!x155! -rotate 10 '.$imagesurse2.'');

exec("convert  ".$patch."/banner48.png  ".$imagesurse2." -geometry +206+57 -compose DstOver -composite  ".$jpg);
exec('convert '.$jpg.' -quality 60 '.$jpg);
@unlink($imagesurse2);
$imagesurse2=$jpg;

?>

But not in this link : http://www.goupix.com/effects/Tulips.php & there is the code :

Code: Select all

<?
$surse = "123qwertyu456789QWERThjklzYUIOPAxcvSDFGHVBNMiopasdfgbnmJKLZXC"; 

for ($i = 0; $i <15; $i++) 
    { 
     $newsurse[$i] = $surse[rand(0,60)];
	 $newsurse2[$i] = $surse[rand(0,60)];
    } 
   
   	$jpg = 'temp/'.implode("",$newsurse).'.jpg';
   	$png = 'temp/'.implode("",$newsurse2).'.png';
exec('convert '.$imagesurse2.' -resize 509!x381! '.$imagesurse2.'');

exec("convert -size 509x387 xc:transparent  ".$imagesurse2."  -set option:distort:viewport 509x387  -matte -virtual-pixel transparent   -distort Perspective '0,0,200,0  0,381,0,208  509,0,509,152  509,381,345,387'  -composite  ".$png);


exec("convert  ".$patch."/card6.png   ".$png." -geometry +31+96 -compose DstOver -composite  ".$jpg);
exec('convert '.$jpg.' -quality 70 '.$jpg);
@unlink($imagesurse2);
@unlink($png);
$imagesurse2=$jpg;

?>

i dont know why !! that's make me crazy :(
Post Reply