how to parse stdout of imagick identify? - parsing

when i run
wget -q -O- 'https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png' | magick identify -verbose -
i get
Image: /tmp/magick-25620GqQdCVSm3pGs
Base filename: -
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 158x158+0+0
Units: Undefined
Colorspace: sRGB
Type: PaletteAlpha
Base type: Undefined
Endianess: Undefined
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
Channel statistics:
Pixels: 24964
Red:
min: 0 (0)
max: 255 (1)
mean: 204.299 (0.801172)
standard deviation: 97.6901 (0.383099)
kurtosis: 0.551289
skewness: -1.57203
entropy: 0.667467
Green:
min: 0 (0)
max: 255 (1)
mean: 194.141 (0.761339)
standard deviation: 99.0545 (0.388449)
kurtosis: -0.185686
skewness: -1.24476
entropy: 0.667467
Blue:
min: 0 (0)
max: 255 (1)
mean: 186.122 (0.729891)
standard deviation: 107.453 (0.421384)
kurtosis: -0.905696
skewness: -1.00834
entropy: 0.667467
Alpha:
min: 0 (0)
max: 255 (1)
mean: 31.3143 (0.122801)
standard deviation: 82.6297 (0.324038)
kurtosis: 3.32656
skewness: 2.29819
entropy: 0.103191
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 153.969 (0.603801)
standard deviation: 96.7068 (0.379243)
kurtosis: -1.75376
skewness: -0.433616
entropy: 0.526398
Alpha: srgba(255,255,255,0) #FFFFFF00
Colors: 215
Histogram:
4567: ( 0, 0, 0, 0) #00000000 none
1152: (188,187,187,255) #BCBBBBFF srgba(188,187,187,1)
1672: (244,128, 36,255) #F48024FF srgba(244,128,36,1)
14: (244,128, 36, 1) #F4802401 srgba(244,128,36,0.00392157)
9: (244,128, 36, 3) #F4802403 srgba(244,128,36,0.0117647)
8: (244,128, 36, 4) #F4802404 srgba(244,128,36,0.0156863)
8: (244,128, 36,247) #F48024F7 srgba(244,128,36,0.968627)
7: (244,128, 36, 2) #F4802402 srgba(244,128,36,0.00784314)
6: (244,128, 36, 12) #F480240C srgba(244,128,36,0.0470588)
6: (244,128, 36,136) #F4802488 srgba(244,128,36,0.533333)
6: (244,128, 36,248) #F48024F8 srgba(244,128,36,0.972549)
6: (244,128, 36,250) #F48024FA srgba(244,128,36,0.980392)
6: (244,128, 36, 11) #F480240B srgba(244,128,36,0.0431373)
5: (244,128, 36,249) #F48024F9 srgba(244,128,36,0.976471)
5: (244,128, 36,236) #F48024EC srgba(244,128,36,0.92549)
5: (244,128, 36,232) #F48024E8 srgba(244,128,36,0.909804)
5: (244,128, 36,252) #F48024FC srgba(244,128,36,0.988235)
5: (244,128, 36, 13) #F480240D srgba(244,128,36,0.0509804)
5: (244,128, 36,211) #F48024D3 srgba(244,128,36,0.827451)
5: (244,128, 36, 9) #F4802409 srgba(244,128,36,0.0352941)
5: (244,128, 36,254) #F48024FE srgba(244,128,36,0.996078)
5: (244,128, 36, 77) #F480244D srgba(244,128,36,0.301961)
5: (244,128, 36,253) #F48024FD srgba(244,128,36,0.992157)
5: (244,128, 36, 58) #F480243A srgba(244,128,36,0.227451)
4: (244,128, 36, 91) #F480245B srgba(244,128,36,0.356863)
4: (244,128, 36, 6) #F4802406 srgba(244,128,36,0.0235294)
4: (244,128, 36,230) #F48024E6 srgba(244,128,36,0.901961)
4: (244,128, 36, 40) #F4802428 srgba(244,128,36,0.156863)
4: (244,128, 36, 52) #F4802434 srgba(244,128,36,0.203922)
4: (244,128, 36, 93) #F480245D srgba(244,128,36,0.364706)
4: (244,128, 36,226) #F48024E2 srgba(244,128,36,0.886275)
4: (244,128, 36, 24) #F4802418 srgba(244,128,36,0.0941176)
4: (244,128, 36,148) #F4802494 srgba(244,128,36,0.580392)
4: (244,128, 36, 28) #F480241C srgba(244,128,36,0.109804)
4: (244,128, 36,104) #F4802468 srgba(244,128,36,0.407843)
4: (244,128, 36, 30) #F480241E srgba(244,128,36,0.117647)
4: (244,128, 36,183) #F48024B7 srgba(244,128,36,0.717647)
4: (244,128, 36, 15) #F480240F srgba(244,128,36,0.0588235)
4: (244,128, 36,234) #F48024EA srgba(244,128,36,0.917647)
4: (244,128, 36, 69) #F4802445 srgba(244,128,36,0.270588)
4: (244,128, 36,233) #F48024E9 srgba(244,128,36,0.913725)
3: (244,128, 36,170) #F48024AA srgba(244,128,36,0.666667)
3: (244,128, 36,231) #F48024E7 srgba(244,128,36,0.905882)
3: (244,128, 36,160) #F48024A0 srgba(244,128,36,0.627451)
3: (244,128, 36, 54) #F4802436 srgba(244,128,36,0.211765)
3: (244,128, 36, 56) #F4802438 srgba(244,128,36,0.219608)
3: (244,128, 36, 89) #F4802459 srgba(244,128,36,0.34902)
3: (244,128, 36,141) #F480248D srgba(244,128,36,0.552941)
3: (244,128, 36, 88) #F4802458 srgba(244,128,36,0.345098)
3: (244,128, 36,134) #F4802486 srgba(244,128,36,0.52549)
3: (244,128, 36,220) #F48024DC srgba(244,128,36,0.862745)
3: (244,128, 36,131) #F4802483 srgba(244,128,36,0.513725)
3: (244,128, 36, 96) #F4802460 srgba(244,128,36,0.376471)
3: (244,128, 36,117) #F4802475 srgba(244,128,36,0.458824)
3: (244,128, 36,122) #F480247A srgba(244,128,36,0.478431)
3: (244,128, 36,216) #F48024D8 srgba(244,128,36,0.847059)
3: (244,128, 36, 10) #F480240A srgba(244,128,36,0.0392157)
3: (244,128, 36,208) #F48024D0 srgba(244,128,36,0.815686)
3: (244,128, 36,206) #F48024CE srgba(244,128,36,0.807843)
3: (244,128, 36,207) #F48024CF srgba(244,128,36,0.811765)
3: (244,128, 36,205) #F48024CD srgba(244,128,36,0.803922)
3: (244,128, 36, 14) #F480240E srgba(244,128,36,0.054902)
3: (244,128, 36,238) #F48024EE srgba(244,128,36,0.933333)
3: (244,128, 36, 20) #F4802414 srgba(244,128,36,0.0784314)
3: (244,128, 36,196) #F48024C4 srgba(244,128,36,0.768627)
3: (244,128, 36, 21) #F4802415 srgba(244,128,36,0.0823529)
3: (244,128, 36, 26) #F480241A srgba(244,128,36,0.101961)
3: (244,128, 36,189) #F48024BD srgba(244,128,36,0.741176)
3: (244,128, 36,188) #F48024BC srgba(244,128,36,0.737255)
3: (244,128, 36, 31) #F480241F srgba(244,128,36,0.121569)
3: (244,128, 36, 32) #F4802420 srgba(244,128,36,0.12549)
3: (244,128, 36, 33) #F4802421 srgba(244,128,36,0.129412)
3: (244,128, 36,177) #F48024B1 srgba(244,128,36,0.694118)
3: (244,128, 36,175) #F48024AF srgba(244,128,36,0.686275)
3: (244,128, 36, 37) #F4802425 srgba(244,128,36,0.145098)
3: (244,128, 36,173) #F48024AD srgba(244,128,36,0.678431)
3: (244,128, 36, 45) #F480242D srgba(244,128,36,0.176471)
2: (244,128, 36,163) #F48024A3 srgba(244,128,36,0.639216)
2: (244,128, 36,251) #F48024FB srgba(244,128,36,0.984314)
2: (244,128, 36,246) #F48024F6 srgba(244,128,36,0.964706)
2: (244,128, 36,244) #F48024F4 srgba(244,128,36,0.956863)
2: (244,128, 36,245) #F48024F5 srgba(244,128,36,0.960784)
2: (244,128, 36,240) #F48024F0 srgba(244,128,36,0.941176)
2: (244,128, 36,239) #F48024EF srgba(244,128,36,0.937255)
2: (244,128, 36,237) #F48024ED srgba(244,128,36,0.929412)
2: (244,128, 36,229) #F48024E5 srgba(244,128,36,0.898039)
2: (244,128, 36,223) #F48024DF srgba(244,128,36,0.87451)
2: (244,128, 36,221) #F48024DD srgba(244,128,36,0.866667)
2: (244,128, 36,219) #F48024DB srgba(244,128,36,0.858824)
2: (244,128, 36,217) #F48024D9 srgba(244,128,36,0.85098)
2: (244,128, 36,214) #F48024D6 srgba(244,128,36,0.839216)
2: (244,128, 36,213) #F48024D5 srgba(244,128,36,0.835294)
2: (244,128, 36,209) #F48024D1 srgba(244,128,36,0.819608)
2: (244,128, 36,201) #F48024C9 srgba(244,128,36,0.788235)
2: (244,128, 36,198) #F48024C6 srgba(244,128,36,0.776471)
2: (244,128, 36,192) #F48024C0 srgba(244,128,36,0.752941)
2: (244,128, 36,186) #F48024BA srgba(244,128,36,0.729412)
2: (244,128, 36,181) #F48024B5 srgba(244,128,36,0.709804)
2: (244,128, 36,179) #F48024B3 srgba(244,128,36,0.701961)
2: (244,128, 36,176) #F48024B0 srgba(244,128,36,0.690196)
2: (244,128, 36,172) #F48024AC srgba(244,128,36,0.67451)
2: (244,128, 36,168) #F48024A8 srgba(244,128,36,0.658824)
2: (244,128, 36,166) #F48024A6 srgba(244,128,36,0.65098)
2: (244,128, 36,156) #F480249C srgba(244,128,36,0.611765)
2: (244,128, 36,152) #F4802498 srgba(244,128,36,0.596078)
2: (244,128, 36,147) #F4802493 srgba(244,128,36,0.576471)
2: (244,128, 36,144) #F4802490 srgba(244,128,36,0.564706)
2: (244,128, 36,135) #F4802487 srgba(244,128,36,0.529412)
2: (244,128, 36,132) #F4802484 srgba(244,128,36,0.517647)
2: (244,128, 36,128) #F4802480 srgba(244,128,36,0.501961)
2: (244,128, 36,124) #F480247C srgba(244,128,36,0.486275)
2: (244,128, 36,120) #F4802478 srgba(244,128,36,0.470588)
2: (244,128, 36,114) #F4802472 srgba(244,128,36,0.447059)
2: (244,128, 36,106) #F480246A srgba(244,128,36,0.415686)
2: (244,128, 36,100) #F4802464 srgba(244,128,36,0.392157)
2: (244,128, 36, 99) #F4802463 srgba(244,128,36,0.388235)
2: (244,128, 36, 94) #F480245E srgba(244,128,36,0.368627)
2: (244,128, 36, 86) #F4802456 srgba(244,128,36,0.337255)
2: (244,128, 36, 82) #F4802452 srgba(244,128,36,0.321569)
2: (244,128, 36, 70) #F4802446 srgba(244,128,36,0.27451)
2: (244,128, 36, 67) #F4802443 srgba(244,128,36,0.262745)
2: (244,128, 36, 63) #F480243F srgba(244,128,36,0.247059)
2: (244,128, 36, 62) #F480243E srgba(244,128,36,0.243137)
2: (244,128, 36, 60) #F480243C srgba(244,128,36,0.235294)
2: (244,128, 36, 59) #F480243B srgba(244,128,36,0.231373)
2: (244,128, 36, 53) #F4802435 srgba(244,128,36,0.207843)
2: (244,128, 36, 51) #F4802433 srgba(244,128,36,0.2)
2: (244,128, 36, 50) #F4802432 srgba(244,128,36,0.196078)
2: (244,128, 36, 47) #F480242F srgba(244,128,36,0.184314)
2: (244,128, 36, 36) #F4802424 srgba(244,128,36,0.141176)
2: (244,128, 36, 35) #F4802423 srgba(244,128,36,0.137255)
2: (244,128, 36, 27) #F480241B srgba(244,128,36,0.105882)
2: (244,128, 36, 18) #F4802412 srgba(244,128,36,0.0705882)
2: (244,128, 36, 17) #F4802411 srgba(244,128,36,0.0666667)
2: (244,128, 36, 16) #F4802410 srgba(244,128,36,0.0627451)
2: (244,128, 36, 7) #F4802407 srgba(244,128,36,0.027451)
2: (244,128, 36, 5) #F4802405 srgba(244,128,36,0.0196078)
1: (244,128, 36, 87) #F4802457 srgba(244,128,36,0.341176)
1: (244,128, 36, 84) #F4802454 srgba(244,128,36,0.329412)
1: (244,128, 36, 85) #F4802455 srgba(244,128,36,0.333333)
1: (244,128, 36, 19) #F4802413 srgba(244,128,36,0.0745098)
1: (244,128, 36, 83) #F4802453 srgba(244,128,36,0.32549)
1: (244,128, 36, 81) #F4802451 srgba(244,128,36,0.317647)
1: (244,128, 36, 78) #F480244E srgba(244,128,36,0.305882)
1: (244,128, 36,145) #F4802491 srgba(244,128,36,0.568627)
1: (244,128, 36, 76) #F480244C srgba(244,128,36,0.298039)
1: (244,128, 36, 75) #F480244B srgba(244,128,36,0.294118)
1: (244,128, 36, 73) #F4802449 srgba(244,128,36,0.286275)
1: (244,128, 36, 72) #F4802448 srgba(244,128,36,0.282353)
1: (244,128, 36, 71) #F4802447 srgba(244,128,36,0.278431)
1: (244,128, 36,241) #F48024F1 srgba(244,128,36,0.945098)
1: (244,128, 36, 68) #F4802444 srgba(244,128,36,0.266667)
1: (244,128, 36,146) #F4802492 srgba(244,128,36,0.572549)
1: (244,128, 36,243) #F48024F3 srgba(244,128,36,0.952941)
1: (244,128, 36, 66) #F4802442 srgba(244,128,36,0.258824)
1: (244,128, 36, 64) #F4802440 srgba(244,128,36,0.25098)
1: (244,128, 36, 65) #F4802441 srgba(244,128,36,0.254902)
1: (244,128, 36,200) #F48024C8 srgba(244,128,36,0.784314)
1: (244,128, 36,203) #F48024CB srgba(244,128,36,0.796078)
1: (244,128, 36, 61) #F480243D srgba(244,128,36,0.239216)
1: (244,128, 36,202) #F48024CA srgba(244,128,36,0.792157)
1: (244,128, 36,204) #F48024CC srgba(244,128,36,0.8)
1: (244,128, 36,150) #F4802496 srgba(244,128,36,0.588235)
1: (244,128, 36, 57) #F4802439 srgba(244,128,36,0.223529)
1: (244,128, 36,153) #F4802499 srgba(244,128,36,0.6)
1: (244,128, 36,154) #F480249A srgba(244,128,36,0.603922)
1: (244,128, 36, 55) #F4802437 srgba(244,128,36,0.215686)
1: (244,128, 36,165) #F48024A5 srgba(244,128,36,0.647059)
1: (244,128, 36,210) #F48024D2 srgba(244,128,36,0.823529)
1: (244,128, 36,212) #F48024D4 srgba(244,128,36,0.831373)
1: (244,128, 36, 8) #F4802408 srgba(244,128,36,0.0313725)
1: (244,128, 36, 48) #F4802430 srgba(244,128,36,0.188235)
1: (244,128, 36, 46) #F480242E srgba(244,128,36,0.180392)
1: (244,128, 36,215) #F48024D7 srgba(244,128,36,0.843137)
1: (244,128, 36,169) #F48024A9 srgba(244,128,36,0.662745)
1: (244,128, 36, 42) #F480242A srgba(244,128,36,0.164706)
1: (244,128, 36, 43) #F480242B srgba(244,128,36,0.168627)
1: (244,128, 36,171) #F48024AB srgba(244,128,36,0.670588)
1: (244,128, 36, 39) #F4802427 srgba(244,128,36,0.152941)
1: (244,128, 36,242) #F48024F2 srgba(244,128,36,0.94902)
1: (244,128, 36,174) #F48024AE srgba(244,128,36,0.682353)
1: (244,128, 36,227) #F48024E3 srgba(244,128,36,0.890196)
1: (244,128, 36, 34) #F4802422 srgba(244,128,36,0.133333)
1: (244,128, 36,178) #F48024B2 srgba(244,128,36,0.698039)
1: (244,128, 36,182) #F48024B6 srgba(244,128,36,0.713725)
1: (244,128, 36,185) #F48024B9 srgba(244,128,36,0.72549)
1: (244,128, 36,184) #F48024B8 srgba(244,128,36,0.721569)
1: (244,128, 36,187) #F48024BB srgba(244,128,36,0.733333)
1: (244,128, 36,190) #F48024BE srgba(244,128,36,0.745098)
1: (244,128, 36,123) #F480247B srgba(244,128,36,0.482353)
1: (244,128, 36,228) #F48024E4 srgba(244,128,36,0.894118)
1: (244,128, 36,118) #F4802476 srgba(244,128,36,0.462745)
1: (244,128, 36,126) #F480247E srgba(244,128,36,0.494118)
1: (244,128, 36,193) #F48024C1 srgba(244,128,36,0.756863)
1: (244,128, 36,112) #F4802470 srgba(244,128,36,0.439216)
1: (244,128, 36,113) #F4802471 srgba(244,128,36,0.443137)
1: (244,128, 36,111) #F480246F srgba(244,128,36,0.435294)
1: (244,128, 36,108) #F480246C srgba(244,128,36,0.423529)
1: (244,128, 36,109) #F480246D srgba(244,128,36,0.427451)
1: (244,128, 36, 25) #F4802419 srgba(244,128,36,0.0980392)
1: (244,128, 36,107) #F480246B srgba(244,128,36,0.419608)
1: (244,128, 36,129) #F4802481 srgba(244,128,36,0.505882)
1: (244,128, 36,105) #F4802469 srgba(244,128,36,0.411765)
1: (244,128, 36,102) #F4802466 srgba(244,128,36,0.4)
1: (244,128, 36, 22) #F4802416 srgba(244,128,36,0.0862745)
1: (244,128, 36,101) #F4802465 srgba(244,128,36,0.396078)
1: (244,128, 36,195) #F48024C3 srgba(244,128,36,0.764706)
1: (244,128, 36,130) #F4802482 srgba(244,128,36,0.509804)
1: (244,128, 36,199) #F48024C7 srgba(244,128,36,0.780392)
1: (244,128, 36,133) #F4802485 srgba(244,128,36,0.521569)
1: (244,128, 36,139) #F480248B srgba(244,128,36,0.545098)
1: (244,128, 36, 90) #F480245A srgba(244,128,36,0.352941)
1: (244,128, 36,138) #F480248A srgba(244,128,36,0.541176)
1: (244,128, 36,143) #F480248F srgba(244,128,36,0.560784)
17069: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 158x158+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2019-04-22T14:37:05+02:00
date:modify: 2019-04-22T14:37:05+02:00
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 158, 158
png:sRGB: intent=0 (Perceptual Intent)
png:text: 1 tEXt/zTXt/iTXt chunks were found
signature: 2e2661f544cee80a0286496a55de16c10bbf412cbeca3c22eb7396e1c549bada
Software: Adobe ImageReady
Artifacts:
filename: -
verbose: true
Tainted: False
Filesize: 3445B
Number pixels: 24964
Pixels per second: 8.32133MB
User time: 0.000u
Elapsed time: 0:01.002
Version: ImageMagick 6.9.10-11 Q16 x86_64 2018-09-08 https://www.imagemagick.org
but i want to read that programmatically, how am i supposed to parse this? it looks human-friendly, but it doesn't look very computer-parsing-friendly

You can use the -format option of identify to print this in your own format:
wget -q -O- 'your://url' | magick identify -format '%[compression]\n%[colorspace]\n' -
Zip
sRGB
You can find the whole list of all available options here: https://imagemagick.org/script/escape.php.
Or you could decide to use json as the output format:
wget -q -O- 'your://url' | magick convert - json:-
[{
"image": {
"name": "-",
"format": "PNG",
"formatDescription": "PNG",
"mimeType": "image/png",
"class": "DirectClass",
"geometry": {
"width": 158,
"height": 158,
"x": 0,
"y": 0
},
"units": "Undefined",
"type": "PaletteAlpha",
"baseType": "Undefined",
"endianess": "Undefined",
"colorspace": "sRGB",
"depth": 8,
"baseDepth": 8,
"channelDepth": {
"alpha": 8,
"red": 8,
"green": 8,
"blue": 8
},
"pixels": 99856,
"imageStatistics": {
"Overall": {
"min": 0,
"max": 255,
"mean": 153.969,
"standardDeviation": 24853.7,
"kurtosis": -1.75376,
"skewness": -0.433616,
"entropy": 0.526398
}
},
"channelStatistics": {
"Alpha": {
"min": 0,
"max": 255,
"mean": 31.3143,
"standardDeviation": 21235.8,
"kurtosis": 3.32656,
"skewness": 2.29819,
"entropy": 0.103191
},
"Red": {
"min": 0,
"max": 255,
"mean": 204.299,
"standardDeviation": 25106.4,
"kurtosis": 0.551289,
"skewness": -1.57203,
"entropy": 0.667467
},
"Green": {
"min": 0,
"max": 255,
"mean": 194.141,
"standardDeviation": 25457,
"kurtosis": -0.185686,
"skewness": -1.24476,
"entropy": 0.667467
},
"Blue": {
"min": 0,
"max": 255,
"mean": 186.122,
"standardDeviation": 27615.4,
"kurtosis": -0.905696,
"skewness": -1.00834,
"entropy": 0.667467
}
},
"alpha": "#FFFFFF00",
"renderingIntent": "Perceptual",
"gamma": 0.454545,
"chromaticity": {
"redPrimary": {
"x": 0.64,
"y": 0.33
},
"greenPrimary": {
"x": 0.3,
"y": 0.6
},
"bluePrimary": {
"x": 0.15,
"y": 0.06
},
"whitePrimary": {
"x": 0.3127,
"y": 0.329
}
},
"matteColor": "#BDBDBD",
"backgroundColor": "#FFFFFF",
"borderColor": "#DFDFDF",
"transparentColor": "#00000000",
"interlace": "None",
"intensity": "Undefined",
"compose": "Over",
"pageGeometry": {
"width": 158,
"height": 158,
"x": 0,
"y": 0
},
"dispose": "Undefined",
"iterations": 0,
"compression": "Zip",
"orientation": "Undefined",
"properties": {
"date:create": "2019-04-22T14:57:00+00:00",
"date:modify": "2019-04-22T14:57:00+00:00",
"png:IHDR.bit-depth-orig": "8",
"png:IHDR.bit_depth": "8",
"png:IHDR.color-type-orig": "6",
"png:IHDR.color_type": "6 (RGBA)",
"png:IHDR.interlace_method": "0 (Not interlaced)",
"png:IHDR.width,height": "158, 158",
"png:sRGB": "intent=0 (Perceptual Intent)",
"png:text": "1 tEXt/zTXt/iTXt chunks were found",
"signature": "656627774777ffa31c094f674683ff3fe8555efa39e17bedbc7bce587af3c28a",
"Software": "Adobe ImageReady"
},
"tainted": false,
"filesize": "3445B",
"numberPixels": "24964",
"pixelsPerSecond": "3.97541MB",
"userTime": "0.010u",
"elapsedTime": "0:01.006",
"version": "/usr/share/doc/ImageMagick-7//index.html"
}
}
]

Related

Delphi Request.ContentFields.Values['something'] is not showing values on MIME data

In TWebModule1.WebModule1WebActionItem1Action(), using Request.ContentFields.Values['content'] or any name, I cannot get any values from the POST, but if I use Request.ContentFields.DelimitedText, I will get the values. Where did I go wrong?
This is the values DelimitedText returned:
------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""name""",NEWTEST,------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""content""","{""resolution""",D,",""symbol_type""",stock,",""exchange""",IDX,",""listed_exchange""",IDX,",""symbol""",BBCA,",""short_name""",BBCA,",""legs""",[{\,"symbol\"":\""","BCA\"",\""","ro_symbol\"":\""","BCA\""}]""",id,":2,""name""",NEWTEST,",""description""",,",""charts_symbols""",{\,"1\"":{\""","ymbol\"":\""","BCA\""}}""",is_realtime,":""1""",content,":""{\""","ame\"":\""","EWTEST\"",\""","ayout\"":\""","\"",\""","harts\"":[{\""","anes\"":[{\""","ources\"":[{\""","ype\"":\""","ainSeries\"",\""","d\"":\""","NUxsv\"",\""","tate\"":{\""","tyle\"":8,\""","sdShowDividends\"":true,\""","sdShowSplits\"":true,\""","sdShowEarnings\"":true,\""","sdShowBreaks\"":false,\""","sdFlagSize\"":2,\""","howCountdown\"":false,\""","idAsk\"":{\""","isible\"":false,\""","ineStyle\"":1,\""","ineWidth\"":1,\""","idLineColor\"":\""","2962FF\"",\""","skLineColor\"":\""","F7525F\""},\""","rePostMarket\"":{\""","isible\"":true,\""","ineStyle\"":1,\""","ineWidth\"":1,\""","reMarketColor\"":\""","fb8c00\"",\""","ostMarketColor\"":\""","2962FF\""},\""","ighLowAvgPrice\"":{\""","ighLowPriceLinesVisible\"":false,\""","ighLowPriceLabelsVisible\"":false,\""","verageClosePriceLineVisible\"":false,\""","verageClosePriceLabelVisible\"":false},\""","howInDataWindow\"":true,\""","isible\"":true,\""","howPriceLine\"":true,\""","riceLineWidth\"":1,\""","riceLineColor\"":\""",",\","baseLineColor\"":\""","B2B5BE\"",\""","howPrevClosePriceLine\"":false,\""","revClosePriceLineWidth\"":1,\""","revClosePriceLineColor\"":\""","gba( 85, 85, 85, 1)\"",\""","inTick\"":\""","efault\"",\""","ividendsAdjustment\"":{},\""","ackAdjustment\"":false,\""","ettlementAsClose\"":true,\""","essionId\"":\""","egular\"",\""","essVis\"":false,\""","tatusViewStyle\"":{\""","ontSize\"":17,\""","howExchange\"":true,\""","howInterval\"":true,\""","ymbolTextSource\"":\""","escription\"",\""","howSymbolAsDescription\"":false},\""","andleStyle\"":{\""","pColor\"":\""","53b987\"",\""","ownColor\"":\""","eb4d5c\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","378658\"",\""","orderUpColor\"":\""","53b987\"",\""","orderDownColor\"":\""","eb4d5c\"",\""","ickColor\"":\""","737375\"",\""","ickUpColor\"":\""","a9cdd3\"",\""","ickDownColor\"":\""","f5a6ae\"",\""","arColorsOnPrevClose\"":false,\""","rawBody\"":true},\""","ollowCandleStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","gba( 55, 134, 88, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","ickColor\"":\""","gba( 115, 115, 117, 1)\"",\""","ickUpColor\"":\""","gba( 169, 220, 195, 1)\"",\""","ickDownColor\"":\""","gba( 245, 166, 174, 1)\"",\""","rawBody\"":true},\""","aStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","gba( 55, 134, 88, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","ickColor\"":\""","gba( 115, 115, 117, 1)\"",\""","ickUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ickDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","howRealLastPrice\"":false,\""","arColorsOnPrevClose\"":false,\""","nputs\"":{},\""","nputInfo\"":{},\""","rawBody\"":true},\""","arStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","arColorsOnPrevClose\"":false,\""","ontDrawOpen\"":false,\""","hinBars\"":true},\""","iloStyle\"":{\""","olor\"":\""","2962FF\"",\""","howBorders\"":true,\""","orderColor\"":\""","2962FF\"",\""","howLabels\"":true,\""","abelColor\"":\""","2962FF\"",\""","ontSize\"":7,\""","rawBody\"":true},\""","ineStyle\"":{\""","olor\"":\""","gba( 60, 120, 216, 1)\"",\""","inestyle\"":0,\""","inewidth\"":1,\""","riceSource\"":\""","lose\"",\""","tyleType\"":2},\""","reaStyle\"":{\""","olor1\"":\""","gba( 96, 96, 144, 0.5)\"",\""","olor2\"":\""","gba( 1, 246, 245, 0.5)\"",\""","inecolor\"":\""","gba( 0, 148, 255, 1)\"",\""","inestyle\"":0,\""","inewidth\"":1,\""","riceSource\"":\""","lose\"",\""","ransparency\"":50},\""","enkoStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","orderUpColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","orderDownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","ickUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ickDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","ources\"":\""","lose\"",\""","oxSize\"":3,\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","icks\"":true},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","ources\"":{\""","ame\"":\""","ource\""},\""","oxSize\"":{\""","ame\"":\""","ox size\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","icks\"":{\""","ame\"":\""","icks\""}}},\""","bStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","orderUpColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","orderDownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","b\"":3},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","b\"":{\""","ame\"":\""","umber of line\""}}},\""","agiStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","eversalAmount\"":1},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","eversalAmount\"":{\""","ame\"":\""","eversal amount\""}}},\""","nfStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ources\"":\""","lose\"",\""","eversalAmount\"":3,\""","oxSize\"":1,\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","neStepBackBuilding\"":false},\""","nputInfo\"":{\""","ources\"":{\""","ame\"":\""","ource\""},\""","oxSize\"":{\""","ame\"":\""","ox size\""},\""","eversalAmount\"":{\""","ame\"":\""","eversal amount\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","neStepBackBuilding\"":{\""","ame\"":\""","ne step back building\""}}},\""","aselineStyle\"":{\""","aselineColor\"":\""","gba( 117, 134, 150, 1)\"",\""","opFillColor1\"":\""","gba( 83, 185, 135, 0.1)\"",\""","opFillColor2\"":\""","gba( 83, 185, 135, 0.1)\"",\""","ottomFillColor1\"":\""","gba( 235, 77, 92, 0.1)\"",\""","ottomFillColor2\"":\""","gba( 235, 77, 92, 0.1)\"",\""","opLineColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ottomLineColor\"":\""","gba( 235, 77, 92, 1)\"",\""","opLineWidth\"":1,\""","ottomLineWidth\"":1,\""","riceSource\"":\""","lose\"",\""","ransparency\"":50,\""","aseLevelPercentage\"":50},\""","angeStyle\"":{\""","pColor\"":\""","22AB94\"",\""","ownColor\"":\""","F7525F\"",\""","hinBars\"":true,\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ange\"":10,\""","hantomBars\"":false},\""","nputInfo\"":{\""","ange\"":{\""","ame\"":\""","ange\""},\""","hantomBars\"":{\""","ame\"":\""","hantom bars\""}}},\""","ilentIntervalChange\"":false,\""","ymbol\"":\""","BCA\"",\""","hortName\"":\""","BCA\"",\""","imeframe\"":\""",",\","onWidget\"":false,\""","nterval\"":\""","\"",\""","nitId\"":null,\""","urrencyId\"":\""","DR\"",\""","howSessions\"":false,\""","riceAxisProperties\"":{\""","utoScale\"":true,\""","utoScaleDisabled\"":false,\""","ockScale\"":false,\""","ercentage\"":false,\""","ercentageDisabled\"":false,\""","og\"":false,\""","ogDisabled\"":false,\""","lignLabels\"":true,\""","sInverted\"":false,\""","ndexedTo100\"":false}},\""","order\"":0,\""","aStyle\"":{\""","tudyId\"":\""","arSetHeikenAshi#tv-basicstudies-60\""},\""","enkoStyle\"":{\""","tudyId\"":\""","arSetRenko#tv-prostudies-40\""},\""","bStyle\"":{\""","tudyId\"":\""","arSetPriceBreak#tv-prostudies-34\""},\""","agiStyle\"":{\""","tudyId\"":\""","arSetKagi#tv-prostudies-34\""},\""","nfStyle\"":{\""","tudyId\"":\""","arSetPnF#tv-prostudies-34\""},\""","angeStyle\"":{\""","tudyId\"":\""","arSetRange#tv-basicstudies-72\""}},{\""","ype\"":\""","tudy_Volume\"",\""","d\"":\""","InSIU\"",\""","tate\"":{\""","tyles\"":{\""","ol\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":5,\""","rackPrice\"":false,\""","ransparency\"":50,\""","isible\"":true,\""","olor\"":\""","000080\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","olume\""},\""","ol_ma\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":0,\""","rackPrice\"":false,\""","ransparency\"":0,\""","isible\"":false,\""","olor\"":\""","2196f3\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","olume MA\""},\""","moothedMA\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":0,\""","rackPrice\"":false,\""","ransparency\"":0,\""","isible\"":false,\""","olor\"":\""","2196f3\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","moothed MA\""}},\""","alettes\"":{\""","olumePalette\"":{\""","olors\"":{\""","\"":{\""","olor\"":\""","F7525F\"",\""","idth\"":1,\""","tyle\"":0,\""","ame\"":\""","alling\""},\""","\"":{\""","olor\"":\""","22AB94\"",\""","idth\"":1,\""","tyle\"":0,\""","ame\"":\""","rowing\""}}}},\""","nputs\"":{\""","howMA\"":false,\""","ength\"":20,\""","ol_prev_close\"":false,\""","ymbol\"":\""",",\","smoothingLine\"":\""","MA\"",\""","moothingLength\"":9},\""","recision\"":\""","efault\"",\""","ands\"":{},\""","rea\"":{},\""","raphics\"":{},\""","howInDataWindow\"":true,\""","isible\"":true,\""","howLegendValues\"":true,\""","howLabelsOnPriceScale\"":true,\""","lots\"":{\""","\"":{\""","d\"":\""","ol\"",\""","ype\"":\""","ine\""},\""","\"":{\""","d\"":\""","olumePalette\"",\""","alette\"":\""","olumePalette\"",\""","arget\"":\""","ol\"",\""","ype\"":\""","olorer\""},\""","\"":{\""","isible\"":true,\""","utureOnly\"":true,\""","reaks\"":{\""","olor\"":\""","gba(85, 85, 85, 1)\"",\""","isible\"":false,\""","tyle\"":2,\""","idth\"":1}},\""","radingProperties\"":{\""","howPositions\"":true,\""","ositionPL\"":{\""","isibility\"":true,\""","isplay\"":0},\""","howOrders\"":true,\""","howExecutions\"":true,\""","howReverse\"":true,\""","orizontalAlignment\"":2,\""","xtendLeft\"":true,\""","ineLength\"":5,\""","ineWidth\"":1,\""","ineStyle\"":2},\""","riceScaleSelectionStrategyName\"":\""","uto\""},\""","ineToolsGroups\"":{\""","roups\"":[]},\""","ersion\"":3,\""","imezone\"":\""","tc/UTC\"",\""","essions\"":{\""","roperties\"":{\""","raphics\"":{\""","ackgrounds\"":{\""","utOfSession\"":{\""","olor\"":\""","2962FF\"",\""","ransparency\"":92,\""","isible\"":false},\""","reMarket\"":{\""","olor\"":\""","FF9800\"",\""","ransparency\"":92,\""","isible\"":false},\""","ostMarket\"":{\""","olor\"":\""","2962FF\"",\""","ransparency\"":92,\""","isible\"":false}},\""","ertlines\"":{\""","essBreaks\"":{\""","olor\"":\""","4985e7\"",\""","tyle\"":2,\""","isible\"":false,\""","idth\"":1}}}}},\""","houldBeSavedEvenIfHidden\"":true,\""","hartId\"":\""","\""}]}""",------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""symbol""",BBCA,------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""resolution""",D,------WebKitFormBoundaryHkgxkABfO4DL8g8Q--
I have been googling the whole web, mostly outdated answer from years ago and I don't find any proper easy way to parse it, but I found my own manual way, please anyone, have a better way to parse please share. thanks.
LBoundary := ExtractHeaderSubItem(Request.ContentType, 'boundary', QuoteHTTP);
tmpstring := Request.Content;
tmpstring := trim(tmpstring);
i := Pos('Content-Disposition: form-data; name="name"', tmpstring);
j := Pos('Content-Disposition: form-data; name="content"', tmpstring);
k := j - i;
tmpstring := (Copy(tmpstring, i, k));
tmpstring := StringReplace(tmpstring, 'Content-Disposition: form-data; name="name"', '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, 'Content-Disposition: form-data; name="content"', '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, '--'+LBoundary, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #13#10, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #32, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #9, '', [rfReplaceAll]);
name:= tmpstring;

how to convert 8-bit unsigned int data to signed?

I am getting List of 8-bit unsigned int from a mic source for each sample rate which looks like this
[61, 251, 199, 251, 56, 252, 138, 252, 211, 252, 18, 253, 91, 253, 194, 253, 25, 254, 54, 254, 19, 254, 190, 253, 80, 253, 249, 252, 233, 252, 46, 253, 180, 253, 54, 254, 136, 254, 157, 254, 110, 254, 38, 254, 208, 253, 117, 253, 68, 253, 57, 253, 83, 253, 163, 253, 20, 254, 151, 254, 51, 255, 215, 255, 105, 0, 207, 0, 246, 0, 249, 0, 10, 1, 64, 1, 162, 1, 4, 2, 64, 2, 97, 2, 111, 2, 110, 2, 89, 2, 40, 2, 241, 1, 199, 1, 178, 1, 192, 1, 241, 1, 45, 2, 77, 2, 70, 2, 45, 2, 36, 2, 83, 2, 176, 2, 21, 3, 121, 3, 229, 3, 87, 4, 185, 4, 225, 4, 197, 4, 129, 4, 26, 4, 150, 3, 7, 3, 128, 2, 55, 2, 65, 2, 134, 2, 223, 2, 25, 3, 41, 3, 28, 3, 255, 2, 234, 2, 240, 2, 25, 3, 62, 3, 92, 3, 146, 3, 219, 3, 65, 4, 149, 4, 164, 4, 130, 4, 51, 4, 195, 3, 69, 3, 164, 2, 244, 1, 75, 1, 187, 0, 81, 0, 240, 255, 135, 255, 19, 255, 155, 254, 64, 254, 22, 254, 58, 254, 146, 254, 217, 254, 248, 254, 215, 254, 144, 254, 92, 254, 84, 254, 141, 254, 229, 254, 39, 255, 96, 255, 170, 255, 248, 255, 69, 0, 117, 0, 128, 0, 137, 0, 131, 0,
so how can I convert this into signed decimal value or someone can guide me to the right path
That depends on what the bytes mean.
Looking at the bytes, every other byte is either very low or very high. That suggests to me that the bytes are really little-endian signed 16-bit values.
In that case, you just need to view them as such. If we assume that the platform is little-endian (most are), you can just do:
List<int> list = ...;
Uint8List bytes = Uint8List.fromList(list); //
Int16List words = Int16List.sublistView(bytes);
Then the words list contains signed 16-bit numbers.
(If the list is already a Uint8List, you can skip the first step.)
If that's not what the bytes mean, you'll have to figure out what they do mean.
Dart int type provide a method to convert from signed to unsigned and from unsigned to signed.
For example:
int a = 16;
int b = 239;
print(a.toSigned(5).toString()); // Print -16
print(b.toSigned(5).toString()); // Print 15
the toSigned method parameter indicate the bit order of the sign bit.
You can get more information here: https://api.flutter.dev/flutter/dart-core/int/toSigned.html
A toUnsigned method exixts too: https://api.flutter.dev/flutter/dart-core/int/toUnsigned.html

how convert function byte to dart

i have a function like this in java
public static final byte[] f1504a = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70};
public static final byte[] bArr = {96, 50, (byte) 152, 96, (byte) 147, 80, (byte) 147, 18, 36, 17, 1, 32, (byte) 145, 17, 4, 84, 0, (byte) 145, 3, 1, 6, 0, 0, 0, 0, 0, 3, 116, 87, (byte) 175, 116, 7, (byte) 174, (byte) 206, (byte) 244, 15, (byte) 227, (byte) 162, 68, 9, (byte) 244, (byte) 236, 73, 59, 3, 84, 120, (byte) 132, (byte) 182, (byte) 174, (byte) 176, 80, (byte) 195, 0, 17, 1, 32, 3, (byte) 246, 61, 13, (byte) 255, (byte) 255, (byte) 144, 0};
public static String b(byte[] bArr, int i) {
byte[] bArr2 = new byte[(i * 2)];
int i2 = 0;
int i3 = 0;
for (byte b2 : bArr) {
if (i2 >= i) {
break;
}
i2++;
int i4 = b2 & 255;
int i5 = i3 + 1;
byte[] bArr3 = f1504a;
bArr2[i3] = bArr3[i4 >>> 4];
i3 = i5 + 1;
bArr2[i5] = bArr3[i4 & 15];
}
return new String(bArr2);
}
b(bArr, 8);
RESULT IS : 6032986093509312
how to convert to dart or flutter.
thanks for answering i'm very appreciate
The answer from julemand101 is a perfect translation of the Java code.
A more idiomatic Dart version could be something like:
import 'dart:typed_data';
final byteTable = Uint8List.fromList([
96, 50, 152, 96, 147, 80, 147, 18, 36, 17, 1, 32, 145, 17, 4, 84, 0, 145, //
3, 1, 6, 0, 0, 0, 0, 0, 3, 116, 87, 175, 116, 7, 174, 206, 244, 15, 227, //
162, 68, 9, 244, 236, 73, 59, 3, 84, 120, 132, 182, 174, 176, 80, 195, 0, //
17, 1, 32, 3, 246, 61, 13, 255, 255, 144, 0
]);
// The hex representation of the first [length] bytes of [bytes].
String toHex(Uint8List bytes, int length) {
const hexDigits = "0123456789ABCDEF";
final resultBytes = Uint8List(length * 2);
if (length > bytes.length) length = bytes.length;
for (var i = 0, j = 0; i < length; i++) {
var byte = bytes[i];
resultBytes[j++] = hexDigits.codeUnitAt(byte >> 4);
resultBytes[j++] = hexDigits.codeUnitAt(byte & 15);
}
return String.fromCharCodes(resultBytes);
}
void main() {
print(toHex(byteTable, 8)); // 6032986093509312
}
Please read the comments you got on your question. You should not expect Stackoverflow to just be a service where you can get other people to do your work.
When that said, I got some spare time and ended up writing a solution in Dart for your code as some kind of puzzle. Not entirely sure if it works the same as your Java code but it works for that one example you have provided:
import 'dart:typed_data';
Uint8List f1504a = Uint8List.fromList(
[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70]);
Uint8List bArr = Uint8List.fromList([
96, 50, 152, 96, 147, 80, 147, 18, 36, 17, 1, 32, 145, 17, 4, 84, 0, 145, //
3, 1, 6, 0, 0, 0, 0, 0, 3, 116, 87, 175, 116, 7, 174, 206, 244, 15, 227, //
162, 68, 9, 244, 236, 73, 59, 3, 84, 120, 132, 182, 174, 176, 80, 195, 0, //
17, 1, 32, 3, 246, 61, 13, 255, 255, 144, 0
]);
String b(Uint8List bArr, int i) {
final bArr2 = Uint8List(i * 2);
var i2 = 0, i3 = 0;
for (final b2 in bArr) {
if (i2 >= i) {
break;
}
i2++;
final i4 = b2 & 255;
final i5 = i3 + 1;
final bArr3 = f1504a;
bArr2[i3] = bArr3[i4 >> 4];
i3 = i5 + 1;
bArr2[i5] = bArr3[i4 & 15];
}
return String.fromCharCodes(bArr2);
}
void main() {
print(b(bArr, 8)); // 6032986093509312
}

Upgrade to OTP 18 breaks usage of public_key library

Building a pem file in Elixir requires several steps, including building an entity. In OTP 17, the following works:
{public, private} = :crypto.generate_key(:ecdh, :secp256k1)
ec_entity = {:ECPrivateKey,
1,
:binary.bin_to_list(private),
{:namedCurve, {1, 3, 132, 0, 10}},
{0, public}}
der_encoded = :public_key.der_encode(:ECPrivateKey, ec_entity)
pem = public_key.pem_encode([{:ECPrivateKey, der_encoded, :not_encrypted}])
But using OTP 18, the following error occurs:
{public, private} = :crypto.generate_key(:ecdh, :secp256k1)
ec_entity = {:ECPrivateKey,
1,
:binary.bin_to_list(private),
{:namedCurve, {1, 3, 132, 0, 10}},
{0, public}}
der_encoded = :public_key.der_encode(:ECPrivateKey, ec_entity)
** (MatchError) no match of right hand side value: {:error, {:asn1, :badarg}}
public_key.erl:253: :public_key.der_encode/2
What is the source of this error?
The source of the error is a change in the way that the public_key entity is constructed between OTP 17 and OTP 18. If we reverse the process, starting with a pem file, we can see the difference.
OTP 17:
iex(6)> pem = "-----BEGIN EC PRIVATE KEY-----\nMHQCAQEEIJniJF4vtTqE4wS5AkhmMZsHIbil0l3XfRButkw5IJYFoAcGBSuBBAAK\noUQDQgAEtxm+jijBB0JxZTceHnCHE0HpMXJp1ScVUZ5McvDUVsS/Dek8IdAsMOPz\nnnVALflZzXtH/wU9p2LrFdJeuXwL8g==\n-----END EC PRIVATE KEY-----\n\n"
"-----BEGIN EC PRIVATE KEY-----\nMHQCAQEEIJniJF4vtTqE4wS5AkhmMZsHIbil0l3XfRButkw5IJYFoAcGBSuBBAAK\noUQDQgAEtxm+jijBB0JxZTceHnCHE0HpMXJp1ScVUZ5McvDUVsS/Dek8IdAsMOPz\nnnVALflZzXtH/wU9p2LrFdJeuXwL8g==\n-----END EC PRIVATE KEY-----\n\n"
iex(7)> [{type, decoded, _}] = :public_key.pem_decode(pem)
[{:ECPrivateKey,
<<48, 116, 2, 1, 1, 4, 32, 153, 226, 36, 94, 47, 181, 58, 132, 227, 4, 185, 2, 72, 102, 49, 155, 7, 33, 184, 165, 210, 93, 215, 125, 16, 110, 182, 76, 57, 32, 150, 5, 160, 7, 6, 5, 43, 129, 4, 0, 10, ...>>,
:not_encrypted}]
iex(8)> :public_key.der_decode(type, decoded)
{:ECPrivateKey, 1,
[153, 226, 36, 94, 47, 181, 58, 132, 227, 4, 185, 2, 72, 102, 49, 155, 7, 33,
184, 165, 210, 93, 215, 125, 16, 110, 182, 76, 57, 32, 150, 5],
{:namedCurve, {1, 3, 132, 0, 10}},
{0,
<<4, 183, 25, 190, 142, 40, 193, 7, 66, 113, 101, 55, 30, 30, 112, 135, 19, 65, 233, 49, 114, 105, 213, 39, 21, 81, 158, 76, 114, 240, 212, 86, 196, 191, 13, 233, 60, 33, 208, 44, 48, 227, 243, 158, 117, ...>>}}
OTP 18:
iex(5)> [{type, decoded, _}] = :public_key.pem_decode(pem)
[{:ECPrivateKey,
<<48, 116, 2, 1, 1, 4, 32, 153, 226, 36, 94, 47, 181, 58, 132, 227, 4, 185, 2, 72, 102, 49, 155, 7, 33, 184, 165, 210, 93, 215, 125, 16, 110, 182, 76, 57, 32, 150, 5, 160, 7, 6, 5, 43, 129, 4, 0, 10, ...>>,
:not_encrypted}]
iex(6)> entity = :public_key.der_decode(type, decoded)
{:ECPrivateKey, 1,
<<153, 226, 36, 94, 47, 181, 58, 132, 227, 4, 185, 2, 72, 102, 49, 155, 7, 33, 184, 165, 210, 93, 215, 125, 16, 110, 182, 76, 57, 32, 150, 5>>,
{:namedCurve, {1, 3, 132, 0, 10}},
<<4, 183, 25, 190, 142, 40, 193, 7, 66, 113, 101, 55, 30, 30, 112, 135, 19, 65, 233, 49, 114, 105, 213, 39, 21, 81, 158, 76, 114, 240, 212, 86, 196, 191, 13, 233, 60, 33, 208, 44, 48, 227, 243, 158, 117, 64, ...>>}
The difference is in how the public and private keys are represented.
The signature of an ECPrivateKey Record is:
ECPrivateKey'{ version, privateKey, parameters, publicKey}
In Erlang 18, both values are represented at plain binaries, in 17, the private key is a list and the public key is part of a tuple, {0, binary}.
So in order to build the pem file correctly, the entity representation has to change.
{public, private} = :crypto.generate_key(:ecdh, :secp256k1)
entity = {:ECPrivateKey,
1,
private,
{:namedCurve, {1, 3, 132, 0, 10}},
public}
Using the new representation of the record will solve the problem.
I didn't really check why your version works on some versions, but I've got some code that works on all these erlang versions: 19.0, 18.2.1, 18.1, 18.0, 17.5, R16B03 (running on travis).
-include_lib("public_key/include/public_key.hrl").
genPEMKey() ->
CurveId = secp256k1,
{PubKey, PrivKey} = crypto:generate_key(ecdh, CurveId),
Key = #'ECPrivateKey'{version = 1,
privateKey = PrivKey,
parameters = {
namedCurve,
pubkey_cert_records:namedCurves(CurveId)},
publicKey = PubKey},
DERKey = public_key:der_encode('ECPrivateKey', Key),
public_key:pem_encode([{'ECPrivateKey', DERKey, not_encrypted}]).
This piece of code was based on the examples found in the OTP codebase:
https://github.com/erlang/otp/blob/master/lib/public_key/test/erl_make_certs.erl#L407

rect.contain() does not show correct results

in the below code i am trying to test if a point is inside a rectangle. i created "Rect rect = new Rect(2, 2, 3, 3);" and as far as i know, the this rectangle is starts from point 2,2 to 4,4 which means it should
contain 9 elements. actually i got 9 elements but why i am not geeting the elements starting from 2,2 upto 4,4
i expected the output to be:
27, 37, 37
49, 58, 58
75, 79, 79
code:
Rect rect = new Rect(2, 2, 3, 3);
for (int i = 0; i < gsMat.height(); i++) {
for (int j = 0; j < gsMat.width(); j++) {
Point pnt = new Point(j, i);
if (pnt.inside(rect)) {
Log.D(TAG, "main", "outside : " + pnt);
Log.D(TAG, "main", "outside : " + gsMat.get(pnt.y, pnt.x)[0] );
}
}
}
5: Info: MainClass -> MainClass: image.Size(): 7x7
6: Info: MainClass -> MainClass: image.dump():
[23, 23, 23, 26, 26, 26, 33, 33, 33, 49, 49, 49, 74, 74, 74, 80, 80, 80, 70, 70, 70;
22, 22, 22, 28, 28, 28, 45, 45, 45, 69, 69, 69, 82, 82, 82, 70, 70, 70, 61, 61, 61;
27, 27, 27, 37, 37, 37, 65, 65, 65, 96, 96, 96, 97, 97, 97, 68, 68, 68, 62, 62, 62;
49, 49, 49, 58, 58, 58, 79, 79, 79, 102, 102, 102, 100, 100, 100, 75, 75, 75, 77, 77, 77;
75, 75, 75, 79, 79, 79, 83, 83, 83, 91, 91, 91, 97, 97, 97, 95, 95, 95, 105, 105, 105;
81, 81, 81, 89, 89, 89, 89, 89, 89, 95, 95, 95, 114, 114, 114, 130, 130, 130, 140, 140, 140;
77, 77, 77, 89, 89, 89, 95, 95, 95, 105, 105, 105, 131, 131, 131, 153, 153, 153, 161, 161, 161]
7: Debug: MainClass -> main: outside : {2.0, 2.0}
8: Debug: MainClass -> main: outside : 65.0
9: Debug: MainClass -> main: outside : {3.0, 2.0}
10: Debug: MainClass -> main: outside : 96.0
11: Debug: MainClass -> main: outside : {4.0, 2.0}
12: Debug: MainClass -> main: outside : 97.0
13: Debug: MainClass -> main: outside : {2.0, 3.0}
14: Debug: MainClass -> main: outside : 79.0
15: Debug: MainClass -> main: outside : {3.0, 3.0}
16: Debug: MainClass -> main: outside : 102.0
17: Debug: MainClass -> main: outside : {4.0, 3.0}
18: Debug: MainClass -> main: outside : 100.0
19: Debug: MainClass -> main: outside : {2.0, 4.0}
20: Debug: MainClass -> main: outside : 83.0
21: Debug: MainClass -> main: outside : {3.0, 4.0}
22: Debug: MainClass -> main: outside : 91.0
23: Debug: MainClass -> main: outside : {4.0, 4.0}
24: Debug: MainClass -> main: outside : 97.0
according to your printed image size (7x7) but your dumped matrix data of 21 elements per row, you probably have a 3 channel data type which means your matrix in the first channel (.get(y,x)[0] )looks like
[23, 26, 33, 49, 74, 80, 70;
22, 28, 45, 69, 82; 70, 61;
27, 37, 65, 96, 97, 68, 62;
49, 58, 79, 102, 100, 75, 77
75, 79, 83, 91, 97, 95, 105;
81, 89, 89, 95, 114, 130, 140;
77, 89, 95, 105, 131, 153, 161]
where your printed elements in the rect (x=2, y=2, width=3, height=3) are exactly what is expected.
[65, 96, 97;
79, 102, 100;
83, 91, 97]
so regarding your 3 channel mat, you dont have covered 3*3 values but 3*3*3 = 27 values! which is 3*3 elements with 3 channels/values (e.g. RGB values) each.

Resources