{"id":433,"date":"2020-09-21T01:15:00","date_gmt":"2020-09-21T05:15:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=433"},"modified":"2020-12-27T01:21:09","modified_gmt":"2020-12-27T06:21:09","slug":"bash-how-to-display-image-properties","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/bash-how-to-display-image-properties\/","title":{"rendered":"bash: How to display image properties"},"content":{"rendered":"\n<p>The following bash script shows how to capture image properties from ImageMagick:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\na=`identify xa.jpg`\nstrarray=($a)\necho 'format: ' ${strarray&#91;1]}\necho 'dimensions: ' ${strarray&#91;2]}\necho 'filesize: ' ${strarray&#91;6]}<\/code><\/pre>\n\n\n\n<p>xa.jpg is an image which is stored in the same directory as this script.<\/p>\n\n\n\n<p>identify is an ImageMagick utility. The output of identify xa.jpg is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>xa.jpg JPEG 469x264 469x264+0+0 8-bit DirectClass 24.4KB 0.010u 0:00.000<\/code><\/pre>\n\n\n\n<p>This output is stored in the variable a. The variable is then converted into an array with strarray=($a) command. Each substring (separated by spaces) is now an element of the array strarray. The last three lines extract elements from this array.<\/p>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>format:  JPEG\ndimensions:  469x264\nfilesize:  24.4KB<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following bash script shows how to capture image properties from ImageMagick: xa.jpg is an image which is stored in the same directory as this script. identify is an ImageMagick utility. The output of identify xa.jpg is: This output is stored in the variable a. The variable is then converted into an array with strarray=($a) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":435,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,34],"tags":[94,35],"class_list":["post-433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","category-linux","tag-bash","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=433"}],"version-history":[{"count":2,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":437,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/433\/revisions\/437"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/435"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}