Modify code to add top header ImageMagick










0















Please some help here. I´m using IM 6.9.10-11 Q16 x86_64



The following coordinates correlative are related with the box number in input image. The first 3 lines in convert command create a
header text "Left - Right" that goes over the img2.png and img3.png



coord1="98x35+234+16" 
coord2="178x59+29+65"
coord3="178x59+223+65"
coord4="178x59+417+65"
coord5="178x59+611+65"
coord6="239x147+35+179"
coord7="239x147+416+179"
coord8="239x147+73+349"
coord9="239x147+401+353"

convert
( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Left" )
( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Right" )
-background white +smush +2 -write mpr:leftright +delete +gravity

input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
( mpr:img -crop $coord2 )
( mpr:img -crop $coord3 )
( mpr:img -crop $coord4 )
( mpr:img -crop $coord5 )
-border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity -write Img1.png

( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
+smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img2.png ) -delete 0--1

( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
+smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img3.png ) null:


With this input.png



input.png



enter link description here



The code produces this 3 images.



Img1.png



enter link description here



Img2.png



enter link description here



Img3.png



enter link description here



What I´d like is to modify the current code to add a top header text to each one of these 3 images before they be created (before -write)
In order that the Img1, Img2 and Img3 be finally like this:



Desired Img1



enter link description here



Desired Img2



enter link description here



Desired Img3



enter link description here



I think I need to create the images first at the beginning of the convert command, something like this, but I don´t know how to adapt it and insert these lines within the current code.



( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Five boxes" ) 
( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Blue boxes" )
( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Green boxes" )


Thanks for any help.










share|improve this question


























    0















    Please some help here. I´m using IM 6.9.10-11 Q16 x86_64



    The following coordinates correlative are related with the box number in input image. The first 3 lines in convert command create a
    header text "Left - Right" that goes over the img2.png and img3.png



    coord1="98x35+234+16" 
    coord2="178x59+29+65"
    coord3="178x59+223+65"
    coord4="178x59+417+65"
    coord5="178x59+611+65"
    coord6="239x147+35+179"
    coord7="239x147+416+179"
    coord8="239x147+73+349"
    coord9="239x147+401+353"

    convert
    ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Left" )
    ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Right" )
    -background white +smush +2 -write mpr:leftright +delete +gravity

    input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
    ( mpr:img -crop $coord2 )
    ( mpr:img -crop $coord3 )
    ( mpr:img -crop $coord4 )
    ( mpr:img -crop $coord5 )
    -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
    ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity -write Img1.png

    ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
    +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img2.png ) -delete 0--1

    ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
    +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img3.png ) null:


    With this input.png



    input.png



    enter link description here



    The code produces this 3 images.



    Img1.png



    enter link description here



    Img2.png



    enter link description here



    Img3.png



    enter link description here



    What I´d like is to modify the current code to add a top header text to each one of these 3 images before they be created (before -write)
    In order that the Img1, Img2 and Img3 be finally like this:



    Desired Img1



    enter link description here



    Desired Img2



    enter link description here



    Desired Img3



    enter link description here



    I think I need to create the images first at the beginning of the convert command, something like this, but I don´t know how to adapt it and insert these lines within the current code.



    ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Five boxes" ) 
    ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Blue boxes" )
    ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Green boxes" )


    Thanks for any help.










    share|improve this question
























      0












      0








      0








      Please some help here. I´m using IM 6.9.10-11 Q16 x86_64



      The following coordinates correlative are related with the box number in input image. The first 3 lines in convert command create a
      header text "Left - Right" that goes over the img2.png and img3.png



      coord1="98x35+234+16" 
      coord2="178x59+29+65"
      coord3="178x59+223+65"
      coord4="178x59+417+65"
      coord5="178x59+611+65"
      coord6="239x147+35+179"
      coord7="239x147+416+179"
      coord8="239x147+73+349"
      coord9="239x147+401+353"

      convert
      ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Left" )
      ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Right" )
      -background white +smush +2 -write mpr:leftright +delete +gravity

      input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
      ( mpr:img -crop $coord2 )
      ( mpr:img -crop $coord3 )
      ( mpr:img -crop $coord4 )
      ( mpr:img -crop $coord5 )
      -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
      ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity -write Img1.png

      ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
      +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img2.png ) -delete 0--1

      ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
      +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img3.png ) null:


      With this input.png



      input.png



      enter link description here



      The code produces this 3 images.



      Img1.png



      enter link description here



      Img2.png



      enter link description here



      Img3.png



      enter link description here



      What I´d like is to modify the current code to add a top header text to each one of these 3 images before they be created (before -write)
      In order that the Img1, Img2 and Img3 be finally like this:



      Desired Img1



      enter link description here



      Desired Img2



      enter link description here



      Desired Img3



      enter link description here



      I think I need to create the images first at the beginning of the convert command, something like this, but I don´t know how to adapt it and insert these lines within the current code.



      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Five boxes" ) 
      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Blue boxes" )
      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Green boxes" )


      Thanks for any help.










      share|improve this question














      Please some help here. I´m using IM 6.9.10-11 Q16 x86_64



      The following coordinates correlative are related with the box number in input image. The first 3 lines in convert command create a
      header text "Left - Right" that goes over the img2.png and img3.png



      coord1="98x35+234+16" 
      coord2="178x59+29+65"
      coord3="178x59+223+65"
      coord4="178x59+417+65"
      coord5="178x59+611+65"
      coord6="239x147+35+179"
      coord7="239x147+416+179"
      coord8="239x147+73+349"
      coord9="239x147+401+353"

      convert
      ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Left" )
      ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Right" )
      -background white +smush +2 -write mpr:leftright +delete +gravity

      input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
      ( mpr:img -crop $coord2 )
      ( mpr:img -crop $coord3 )
      ( mpr:img -crop $coord4 )
      ( mpr:img -crop $coord5 )
      -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
      ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity -write Img1.png

      ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
      +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img2.png ) -delete 0--1

      ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
      +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity -write Img3.png ) null:


      With this input.png



      input.png



      enter link description here



      The code produces this 3 images.



      Img1.png



      enter link description here



      Img2.png



      enter link description here



      Img3.png



      enter link description here



      What I´d like is to modify the current code to add a top header text to each one of these 3 images before they be created (before -write)
      In order that the Img1, Img2 and Img3 be finally like this:



      Desired Img1



      enter link description here



      Desired Img2



      enter link description here



      Desired Img3



      enter link description here



      I think I need to create the images first at the beginning of the convert command, something like this, but I don´t know how to adapt it and insert these lines within the current code.



      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Five boxes" ) 
      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Blue boxes" )
      ( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Green boxes" )


      Thanks for any help.







      text header imagemagick-convert






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 20:45









      Ger CasGer Cas

      347111




      347111






















          1 Answer
          1






          active

          oldest

          votes


















          1














          In ImageMagick you can create images anywhere in parenthesis and reposition them with -swap ... (or +swap for the last two). So your command would become:



          coord1="98x35+234+16" 
          coord2="178x59+29+65"
          coord3="178x59+223+65"
          coord4="178x59+417+65"
          coord5="178x59+611+65"
          coord6="239x147+35+179"
          coord7="239x147+416+179"
          coord8="239x147+73+349"
          coord9="239x147+401+353"

          convert
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Left" )
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Right" )
          -background white +smush +2 -write mpr:leftright +delete +gravity

          input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
          ( mpr:img -crop $coord2 )
          ( mpr:img -crop $coord3 )
          ( mpr:img -crop $coord4 )
          ( mpr:img -crop $coord5 )
          -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
          ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Five Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img1.png

          ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Blue Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img2.png ) -delete 0--1

          ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Green Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img3.png ) null:




          And the results are:



          enter image description here



          enter image description here



          enter image description here



          Unfortunately, in IM 6 there is no way to know how wide your smushed colored images will be so as to make the title the same width unless you compute that ahead of time. In IM 7, it can be done in-line in your command line. So here I made it the same width as the two left right smushed images. You can change the width by changing the width value in -size 250x36.






          share|improve this answer























          • Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

            – Ger Cas
            Nov 14 '18 at 2:11











          • mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

            – fmw42
            Nov 14 '18 at 2:17











          • I see. Many thanks for help, explanation and info shared.

            – Ger Cas
            Nov 14 '18 at 2:54










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289232%2fmodify-code-to-add-top-header-imagemagick%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          In ImageMagick you can create images anywhere in parenthesis and reposition them with -swap ... (or +swap for the last two). So your command would become:



          coord1="98x35+234+16" 
          coord2="178x59+29+65"
          coord3="178x59+223+65"
          coord4="178x59+417+65"
          coord5="178x59+611+65"
          coord6="239x147+35+179"
          coord7="239x147+416+179"
          coord8="239x147+73+349"
          coord9="239x147+401+353"

          convert
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Left" )
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Right" )
          -background white +smush +2 -write mpr:leftright +delete +gravity

          input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
          ( mpr:img -crop $coord2 )
          ( mpr:img -crop $coord3 )
          ( mpr:img -crop $coord4 )
          ( mpr:img -crop $coord5 )
          -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
          ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Five Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img1.png

          ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Blue Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img2.png ) -delete 0--1

          ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Green Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img3.png ) null:




          And the results are:



          enter image description here



          enter image description here



          enter image description here



          Unfortunately, in IM 6 there is no way to know how wide your smushed colored images will be so as to make the title the same width unless you compute that ahead of time. In IM 7, it can be done in-line in your command line. So here I made it the same width as the two left right smushed images. You can change the width by changing the width value in -size 250x36.






          share|improve this answer























          • Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

            – Ger Cas
            Nov 14 '18 at 2:11











          • mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

            – fmw42
            Nov 14 '18 at 2:17











          • I see. Many thanks for help, explanation and info shared.

            – Ger Cas
            Nov 14 '18 at 2:54















          1














          In ImageMagick you can create images anywhere in parenthesis and reposition them with -swap ... (or +swap for the last two). So your command would become:



          coord1="98x35+234+16" 
          coord2="178x59+29+65"
          coord3="178x59+223+65"
          coord4="178x59+417+65"
          coord5="178x59+611+65"
          coord6="239x147+35+179"
          coord7="239x147+416+179"
          coord8="239x147+73+349"
          coord9="239x147+401+353"

          convert
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Left" )
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Right" )
          -background white +smush +2 -write mpr:leftright +delete +gravity

          input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
          ( mpr:img -crop $coord2 )
          ( mpr:img -crop $coord3 )
          ( mpr:img -crop $coord4 )
          ( mpr:img -crop $coord5 )
          -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
          ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Five Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img1.png

          ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Blue Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img2.png ) -delete 0--1

          ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Green Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img3.png ) null:




          And the results are:



          enter image description here



          enter image description here



          enter image description here



          Unfortunately, in IM 6 there is no way to know how wide your smushed colored images will be so as to make the title the same width unless you compute that ahead of time. In IM 7, it can be done in-line in your command line. So here I made it the same width as the two left right smushed images. You can change the width by changing the width value in -size 250x36.






          share|improve this answer























          • Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

            – Ger Cas
            Nov 14 '18 at 2:11











          • mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

            – fmw42
            Nov 14 '18 at 2:17











          • I see. Many thanks for help, explanation and info shared.

            – Ger Cas
            Nov 14 '18 at 2:54













          1












          1








          1







          In ImageMagick you can create images anywhere in parenthesis and reposition them with -swap ... (or +swap for the last two). So your command would become:



          coord1="98x35+234+16" 
          coord2="178x59+29+65"
          coord3="178x59+223+65"
          coord4="178x59+417+65"
          coord5="178x59+611+65"
          coord6="239x147+35+179"
          coord7="239x147+416+179"
          coord8="239x147+73+349"
          coord9="239x147+401+353"

          convert
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Left" )
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Right" )
          -background white +smush +2 -write mpr:leftright +delete +gravity

          input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
          ( mpr:img -crop $coord2 )
          ( mpr:img -crop $coord3 )
          ( mpr:img -crop $coord4 )
          ( mpr:img -crop $coord5 )
          -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
          ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Five Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img1.png

          ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Blue Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img2.png ) -delete 0--1

          ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Green Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img3.png ) null:




          And the results are:



          enter image description here



          enter image description here



          enter image description here



          Unfortunately, in IM 6 there is no way to know how wide your smushed colored images will be so as to make the title the same width unless you compute that ahead of time. In IM 7, it can be done in-line in your command line. So here I made it the same width as the two left right smushed images. You can change the width by changing the width value in -size 250x36.






          share|improve this answer













          In ImageMagick you can create images anywhere in parenthesis and reposition them with -swap ... (or +swap for the last two). So your command would become:



          coord1="98x35+234+16" 
          coord2="178x59+29+65"
          coord3="178x59+223+65"
          coord4="178x59+417+65"
          coord5="178x59+611+65"
          coord6="239x147+35+179"
          coord7="239x147+416+179"
          coord8="239x147+73+349"
          coord9="239x147+401+353"

          convert
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Left" )
          ( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Right" )
          -background white +smush +2 -write mpr:leftright +delete +gravity

          input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"
          ( mpr:img -crop $coord2 )
          ( mpr:img -crop $coord3 )
          ( mpr:img -crop $coord4 )
          ( mpr:img -crop $coord5 )
          -border 4 ( -clone 0,1 -smush -4 ) ( -clone 2,3 -smush -4 ) -delete 0-3 -gravity center +smush -4 +gravity
          ( mpr:img -crop $coord1 -border 4 ) +swap -gravity center -smush +12 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Five Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img1.png

          ( ( mpr:img -crop $coord6 +repage -border 4 ) ( mpr:img -crop $coord7 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Blue Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img2.png ) -delete 0--1

          ( ( mpr:img -crop $coord8 +repage -border 4 ) ( mpr:img -crop $coord9 +repage -border 4 )
          +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity
          ( -size 250x36 xc:gray -fill white -font Calibri-Bold.ttf -pointsize 32 -gravity center -annotate +0+0 "Green Boxes" )
          +swap -background none -gravity center -smush +20 +gravity -write Img3.png ) null:




          And the results are:



          enter image description here



          enter image description here



          enter image description here



          Unfortunately, in IM 6 there is no way to know how wide your smushed colored images will be so as to make the title the same width unless you compute that ahead of time. In IM 7, it can be done in-line in your command line. So here I made it the same width as the two left right smushed images. You can change the width by changing the width value in -size 250x36.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 22:45









          fmw42fmw42

          7,80341427




          7,80341427












          • Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

            – Ger Cas
            Nov 14 '18 at 2:11











          • mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

            – fmw42
            Nov 14 '18 at 2:17











          • I see. Many thanks for help, explanation and info shared.

            – Ger Cas
            Nov 14 '18 at 2:54

















          • Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

            – Ger Cas
            Nov 14 '18 at 2:11











          • mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

            – fmw42
            Nov 14 '18 at 2:17











          • I see. Many thanks for help, explanation and info shared.

            – Ger Cas
            Nov 14 '18 at 2:54
















          Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

          – Ger Cas
          Nov 14 '18 at 2:11





          Just great. Thanks so much one more time. I see that you didn't use "mpr" to create the top headers, then to create the Left-Right headers could be done in the same way? I mean without use mpr? Additionally what does mean -delete 0--1 and why sometimes use + or - gravity?

          – Ger Cas
          Nov 14 '18 at 2:11













          mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

          – fmw42
          Nov 14 '18 at 2:17





          mpr: was needed to avoid repeatedly reading your input image. -delete 0--1 means to delete all the previous image in the command sequence 0 is the first and -1 is the last. So 0--1 means from the first to the last. -gravity is needed when setting a gravity for use. +gravity is used to reset the gravity to its default value. See imagemagick.org/Usage/basics

          – fmw42
          Nov 14 '18 at 2:17













          I see. Many thanks for help, explanation and info shared.

          – Ger Cas
          Nov 14 '18 at 2:54





          I see. Many thanks for help, explanation and info shared.

          – Ger Cas
          Nov 14 '18 at 2:54

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289232%2fmodify-code-to-add-top-header-imagemagick%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto