I am sorry if i post in the wrong form , please correct me if !
Any way , i have an Image 2000*2000 bmp format.
I have an Array of 3000 coordinate XY. and i want to collect the RGB color value for each pixel.
will , i know the command line , which is
Code: Select all
/usr/bin/convert ./twitter.bmp -format '%[pixel:p{232,345}]' info:-
How i determinate that ?
ok let see this Bash code :
Code: Select all
#!/bin/bash
for (( c=1; c<=3000; c++ ))
do
x=$(( $RANDOM % 2000 ));
y=$(( $RANDOM % 2000 ));
/usr/bin/convert ./twitter.bmp -format '%[pixel:p{'$x','$y'}]' info:- >> testfile.txt
done
this code take more than 3 min to complete !
try it by your self and see how much time it take , my server is very powerful , cor i7 * 4 and 64 GB of ram !
I am sure there is some thing wrong with the code ,
Ps i did test PHP
Code: Select all
<?
$startTime = microtime(true);
for ($i =0 ; $i <= 3000 ; $i ++){
$x = rand(0,2000);
$y = rand(0,2000);
exec("/usr/bin/convert ./twitter.bmp -format '%[pixel:p{".$x.",".$y."}]' info:- 2>&1", $json);
}
$endTime = microtime(true);
$elapsed = $endTime - $startTime;
echo "Execution time : $elapsed seconds \n\n\n";
?>
and this one :
Code: Select all
<?
$startTime = microtime(true);
$image = new Imagick('./twitter.bmp');
for ($i =0 ; $i <= 3000 ; $i ++){
$x = rand(0,2000);
$y = rand(0,2000);
$pixel = $image->getImagePixelColor($x, $y);
$colors = $pixel->getColor();
}
$endTime = microtime(true);
print_r($colors);
$elapsed = $endTime - $startTime;
echo "Execution time : $elapsed seconds \n\n\n";
?>
all of these samples take a huge time to complete .
So what the magic behind the imagemagick !
any way lets see what imagemagick can do regarding this !
Thank you and best regards.