Friday, August 16, 2013

Image Magick


convert Thumbs\2008-04-25\th_DSC_0004.jpg -bordercolor white ^
-border 6 ^
-bordercolor grey60 ^
-border 1 ^
-bordercolor none ^
-background none ^
( Thumbs\2008-04-25\th_DSC_0005.jpg -bordercolor white ^
-border 6 ^
-bordercolor grey60 ^
-border 1 ^
-bordercolor none ^
-background none ^
-affine 1.5,1.5,-1.5,1.5,100,100 -transform ) ^
( -clone 0 -rotate 3 ) ^
( -clone 0 -rotate -5 ) ^
( -clone 0 -rotate 0 ) ^
-delete 0 ^
-border 100x80 ^
-gravity center ^
-crop 1000x1000+0+0 ^
+repage ^
-flatten ^
-trim ^
+repage ^
-background black ( +clone -shadow 60x4+4+4 ) ^
+swap ^
-background none ^
-flatten poloroid_stack.png

function createPile($thumbnails_full_paths, $save_file_location, $max_images)
{
ini_set("max_execution_time", "3000");
$image_magick_path="C:\\Program Files\\ImageMagick";
//$image_magick_path="D:\\Program Files\\ImageMagick-6.5.4-Q16";
//$thumbnails_full_paths should be a list of the thumbnails properly escaped strings
//$save_file_location should be something like $thumbs_path\\{$folder}_{$rand_num}.png
$folder_thumb_command_start="\"$image_magick_path\\convert.exe\" ";
$folder_thumb_command_images_first="";
$folder_thumb_command_middle=" -bordercolor white -border 6 -bordercolor grey60 -border 1 -bordercolor none -border 1 -background none ";
$folder_thumb_command_images_second="";
$folder_thumb_command_end=" -border 2000x1000 -gravity center +repage -flatten -trim +repage -background black ( +clone -shadow 60x4+4+4 ) +swap -background none -flatten \"$save_file_location\"";
//-crop 2000x1000+0+0 broke it for win7 64bit system
$i=count($thumbnails_full_paths);//shuffle($files);
if($i<$max_images)
$stop=$i;
else
$stop=$max_images;
for($j=0; $j<$stop; $j++)
{
$angle=(3.14159*rand(-100,100))/800;
$cos_ang=cos($angle);
$sin_ang=sin($angle);
$min_sin_ang =-$sin_ang;
$pos_x = rand(20,500);
$pos_y = rand(20,200);
$folder_thumb_command_images_first=$folder_thumb_command_images_first."\"$thumbnails_full_paths[$j]\" ";
$folder_thumb_command_images_second=$folder_thumb_command_images_second."( -clone 0 -affine $cos_ang,$sin_ang,$min_sin_ang,$cos_ang,$pos_x,$pos_y -transform ) -delete 0 ";
}
$folder_thumb_command=$folder_thumb_command_start.$folder_thumb_command_images_first.$folder_thumb_command_middle.$folder_thumb_command_images_second.$folder_thumb_command_end;
//echo("\"$folder_thumb_command\"");
exec("\"$folder_thumb_command\"");
}

No comments:

Post a Comment