Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal asked on

Search Inside Array (Array From Imagemagick identify verbose)

Hi, I use identify of image magick for get some informations of one image, like you see in code box.....
The result is:
=========================================
Array
(
    [0] => Image: 5photos.jpg
    [1] =>   Format: JPEG (Joint Photographic Experts Group JFIF format)
    [2] =>   Class: DirectClass
    [3] =>   Geometry: 473x335+0+0
    [4] =>   Resolution: 100x100
    [5] =>   Print size: 4.73x3.35
    [6] =>   Units: PixelsPerInch
    [7] =>   Type: TrueColor
    [8] =>   Endianess: Undefined
    [9] =>   Colorspace: RGB
    [10] =>   Depth: 8-bit
    [11] =>   Channel depth:
    [12] =>     red: 8-bit
    [13] =>     green: 8-bit
    [14] =>     blue: 8-bit
    [15] =>   Channel statistics:
    [16] =>     red:
    [17] =>       min: 0 (0)
    [18] =>       max: 255 (1)
    [19] =>       mean: 117.824 (0.462055)
    [20] =>       standard deviation: 60.0605 (0.235531)
    [21] =>     green:
    [22] =>       min: 0 (0)
    [23] =>       max: 255 (1)
    [24] =>       mean: 120.322 (0.471852)
    [25] =>       standard deviation: 60.9865 (0.239163)
    [26] =>     blue:
    [27] =>       min: 0 (0)
    [28] =>       max: 255 (1)
    [29] =>       mean: 80.0232 (0.313817)
    [30] =>       standard deviation: 69.9419 (0.274282)
    [31] =>   Rendering intent: Undefined
    [32] =>   Interlace: None
    [33] =>   Background color: white
    [34] =>   Border color: rgb(223,223,223)
    [35] =>   Matte color: grey74
    [36] =>   Transparent color: black
    [37] =>   Page geometry: 473x335+0+0
    [38] =>   Dispose: Undefined
    [39] =>   Iterations: 0
    [40] =>   Compression: JPEG
    [41] =>   Quality: 38
    [42] =>   Orientation: Undefined
    [43] =>   Properties:
    [44] =>     comment: LEAD Technologies Inc. V1.01
    [45] =>     create-date: 2009-01-25T00:26:29+00:00
    [46] =>     jpeg:colorspace: 2
    [47] =>     jpeg:sampling-factor: 1x1,1x1,1x1
    [48] =>     modify-date: 2009-01-25T00:26:29+00:00
    [49] =>     signature: 204ae33f228d443047c10924a09de9298c4138b8f0b4eb4bfedf18846ca20276
    [50] =>   Artifacts:
    [51] =>     verbose: true
    [52] =>   Tainted: False
    [53] =>   Filesize: 22.209kb
    [54] =>   Number pixels: 154.74kb
    [55] =>   Version: ImageMagick 6.4.1 06/02/08 Q16 OpenMP http://www.imagemagick.org
)
==============================================
I want identify the 'quality' of each image, but the results not is allways the same, in this case quality appear in [41], and other images appear in [393] and so on.
So, if I cant identify the quality of each photo, I cant do a dinamic script.

For this problem, I thing is possible with search inside the array.
I want search where is the position of 'quality' of each image.

The best regars,
JC
exec("/usr/bin/identify -verbose 5photos.jpg", $varrr);
echo '<pre>';
print_r($varrr);
echo '</pre>';

Open in new window

PHP

Avatar of undefined
Last Comment
Pedro Chagas

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
hielo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Pedro Chagas

function getIndex($arr,$str){
  foreach($arr as $k => $v)
  {
    if(FALSE !== strpos($v,$str) )
    {
      return $k;
   }
  }
}

exec("/usr/bin/identify -verbose aaa.jpg", $varrr);
echo '
';
print_r($varrr);
echo '

Open in new window

';

echo getIndex($varrr, "Quality");
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy