Merge 3 images in a single convert command mantaining size ImageMagick
With these 3 separates codes I create the following 3 images with desired size for each one. I'm failing in merging in a single command.
This code produces P1.png
convert ( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png ) null:
P1.png (854x37)
This code produces P2.png
convert ( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png ) null:
P2.png (1180x441)
This code produces P3.png
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png ) null:
P3.png (1104x89)
If I join the 3 images in an image editor visually (like Paint.net) the resulting image is of 1180x606 and the resolution is 96 pixels per inch.
How can I join these 3 commands in a single "convert" command in order the final image be of 1180x606 in size?
I've tried with this code, but I don't know how to construct the command correctly
convert
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
-write mpr:numbers
(
( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
-resize 1180x441! +smush +6 mpr:numbers +swap -gravity center -smush +15 +gravity
-write mpr:boxes
-delete 0
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
mpr:boxes +swap -gravity center -smush +24 +gravity +write POut.png ) null:
The desired output is like this:
Thanks for any help.
UPDATE
When I see it in an image editor (Paint.net in my case) I can see and change resolution withot change pixel dimentions. Only dimentions of inches change.
Result.png original with Resolution=120 pixel/inch and size 1180x606
Result.png changed to Resolution=96 pixel/inch and size still is 1180x606 but inches dimentions changed
UPDATE 2
fmw42's code works fine creating from scratch 3 images and then merging them. My problem is if I use the same fmw42's script but instead to create
the yellow and green boxes I crop them from another image (source.png) the result.png is not the same. What is the issue when I add the cropped images?
I'm using this code:
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24
(
( mpr:img -crop 881x488+71+376 )
( mpr:img -crop 881x488+992+376 )
+smush +6 -resize 1180x441!
)
-smush +15
resultX.png
This is source.png
And this is the output that is not correct
image-processing imagemagick imagemagick-convert
add a comment |
With these 3 separates codes I create the following 3 images with desired size for each one. I'm failing in merging in a single command.
This code produces P1.png
convert ( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png ) null:
P1.png (854x37)
This code produces P2.png
convert ( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png ) null:
P2.png (1180x441)
This code produces P3.png
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png ) null:
P3.png (1104x89)
If I join the 3 images in an image editor visually (like Paint.net) the resulting image is of 1180x606 and the resolution is 96 pixels per inch.
How can I join these 3 commands in a single "convert" command in order the final image be of 1180x606 in size?
I've tried with this code, but I don't know how to construct the command correctly
convert
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
-write mpr:numbers
(
( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
-resize 1180x441! +smush +6 mpr:numbers +swap -gravity center -smush +15 +gravity
-write mpr:boxes
-delete 0
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
mpr:boxes +swap -gravity center -smush +24 +gravity +write POut.png ) null:
The desired output is like this:
Thanks for any help.
UPDATE
When I see it in an image editor (Paint.net in my case) I can see and change resolution withot change pixel dimentions. Only dimentions of inches change.
Result.png original with Resolution=120 pixel/inch and size 1180x606
Result.png changed to Resolution=96 pixel/inch and size still is 1180x606 but inches dimentions changed
UPDATE 2
fmw42's code works fine creating from scratch 3 images and then merging them. My problem is if I use the same fmw42's script but instead to create
the yellow and green boxes I crop them from another image (source.png) the result.png is not the same. What is the issue when I add the cropped images?
I'm using this code:
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24
(
( mpr:img -crop 881x488+71+376 )
( mpr:img -crop 881x488+992+376 )
+smush +6 -resize 1180x441!
)
-smush +15
resultX.png
This is source.png
And this is the output that is not correct
image-processing imagemagick imagemagick-convert
add a comment |
With these 3 separates codes I create the following 3 images with desired size for each one. I'm failing in merging in a single command.
This code produces P1.png
convert ( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png ) null:
P1.png (854x37)
This code produces P2.png
convert ( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png ) null:
P2.png (1180x441)
This code produces P3.png
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png ) null:
P3.png (1104x89)
If I join the 3 images in an image editor visually (like Paint.net) the resulting image is of 1180x606 and the resolution is 96 pixels per inch.
How can I join these 3 commands in a single "convert" command in order the final image be of 1180x606 in size?
I've tried with this code, but I don't know how to construct the command correctly
convert
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
-write mpr:numbers
(
( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
-resize 1180x441! +smush +6 mpr:numbers +swap -gravity center -smush +15 +gravity
-write mpr:boxes
-delete 0
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
mpr:boxes +swap -gravity center -smush +24 +gravity +write POut.png ) null:
The desired output is like this:
Thanks for any help.
UPDATE
When I see it in an image editor (Paint.net in my case) I can see and change resolution withot change pixel dimentions. Only dimentions of inches change.
Result.png original with Resolution=120 pixel/inch and size 1180x606
Result.png changed to Resolution=96 pixel/inch and size still is 1180x606 but inches dimentions changed
UPDATE 2
fmw42's code works fine creating from scratch 3 images and then merging them. My problem is if I use the same fmw42's script but instead to create
the yellow and green boxes I crop them from another image (source.png) the result.png is not the same. What is the issue when I add the cropped images?
I'm using this code:
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24
(
( mpr:img -crop 881x488+71+376 )
( mpr:img -crop 881x488+992+376 )
+smush +6 -resize 1180x441!
)
-smush +15
resultX.png
This is source.png
And this is the output that is not correct
image-processing imagemagick imagemagick-convert
With these 3 separates codes I create the following 3 images with desired size for each one. I'm failing in merging in a single command.
This code produces P1.png
convert ( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png ) null:
P1.png (854x37)
This code produces P2.png
convert ( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png ) null:
P2.png (1180x441)
This code produces P3.png
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png ) null:
P3.png (1104x89)
If I join the 3 images in an image editor visually (like Paint.net) the resulting image is of 1180x606 and the resolution is 96 pixels per inch.
How can I join these 3 commands in a single "convert" command in order the final image be of 1180x606 in size?
I've tried with this code, but I don't know how to construct the command correctly
convert
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
-write mpr:numbers
(
( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
-resize 1180x441! +smush +6 mpr:numbers +swap -gravity center -smush +15 +gravity
-write mpr:boxes
-delete 0
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
mpr:boxes +swap -gravity center -smush +24 +gravity +write POut.png ) null:
The desired output is like this:
Thanks for any help.
UPDATE
When I see it in an image editor (Paint.net in my case) I can see and change resolution withot change pixel dimentions. Only dimentions of inches change.
Result.png original with Resolution=120 pixel/inch and size 1180x606
Result.png changed to Resolution=96 pixel/inch and size still is 1180x606 but inches dimentions changed
UPDATE 2
fmw42's code works fine creating from scratch 3 images and then merging them. My problem is if I use the same fmw42's script but instead to create
the yellow and green boxes I crop them from another image (source.png) the result.png is not the same. What is the issue when I add the cropped images?
I'm using this code:
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24
(
( mpr:img -crop 881x488+71+376 )
( mpr:img -crop 881x488+992+376 )
+smush +6 -resize 1180x441!
)
-smush +15
resultX.png
This is source.png
And this is the output that is not correct
image-processing imagemagick imagemagick-convert
image-processing imagemagick imagemagick-convert
edited Nov 16 '18 at 18:50
Ger Cas
asked Nov 16 '18 at 0:29
Ger CasGer Cas
436213
436213
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Does this do what you want? ImageMagick 6 command could be like the following as one way to do it:
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png )
( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png )
-smush +24
( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png )
-smush +15
result.png
Note that I may not have used the same font as you.
Please review:
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#smush
https://imagemagick.org/Usage/files/#write
To answer your Update2 question: You need to resent the gravity with +gravity after you have used it with -gravity center. Also you need to add +repage after your crops.
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24 +gravity
(
( mpr:img -crop 881x488+71+376 +repage )
( mpr:img -crop 881x488+992+376 +repage )
+smush +6 -resize 1180x441!
)
-gravity center -smush +15
resultX.png
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,-density 96 result.png
Maybe you could know how to do it. Thanks
– Ger Cas
Nov 16 '18 at 15:50
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
|
show 7 more comments
With well considered use of ImageMagick's memory registers, like "mpr:something", you can simplify the construction of your entire image to something like this...
convert -gravity center -background white -font helvetica
-size 1104x89 xc:"#00137F" -fill white -pointsize 48
-annotate +0+0 "Different boxes" -write mpr:diffbox +delete
-size 426x37 xc:"#4FA7FF" xc:"#4FA7FF" -fill black -pointsize 32
-annotate +0+0 "Number %[fx:t+1]" +smush 2 -write mpr:numbox +delete
-size 588x441 xc:"#FFE97F" xc:"#00FF90" +smush 4
mpr:numbox +insert -smush 15 mpr:diffbox +insert -smush 24 result.png
That works for me on Windows Ubuntu bash shell running ImageMagick 6.8.9-9. You'll have to specify your own font, and if you're using the same font for everything you only have to specify it once.
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.
– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
|
show 2 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329754%2fmerge-3-images-in-a-single-convert-command-mantaining-size-imagemagick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Does this do what you want? ImageMagick 6 command could be like the following as one way to do it:
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png )
( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png )
-smush +24
( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png )
-smush +15
result.png
Note that I may not have used the same font as you.
Please review:
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#smush
https://imagemagick.org/Usage/files/#write
To answer your Update2 question: You need to resent the gravity with +gravity after you have used it with -gravity center. Also you need to add +repage after your crops.
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24 +gravity
(
( mpr:img -crop 881x488+71+376 +repage )
( mpr:img -crop 881x488+992+376 +repage )
+smush +6 -resize 1180x441!
)
-gravity center -smush +15
resultX.png
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,-density 96 result.png
Maybe you could know how to do it. Thanks
– Ger Cas
Nov 16 '18 at 15:50
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
|
show 7 more comments
Does this do what you want? ImageMagick 6 command could be like the following as one way to do it:
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png )
( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png )
-smush +24
( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png )
-smush +15
result.png
Note that I may not have used the same font as you.
Please review:
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#smush
https://imagemagick.org/Usage/files/#write
To answer your Update2 question: You need to resent the gravity with +gravity after you have used it with -gravity center. Also you need to add +repage after your crops.
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24 +gravity
(
( mpr:img -crop 881x488+71+376 +repage )
( mpr:img -crop 881x488+992+376 +repage )
+smush +6 -resize 1180x441!
)
-gravity center -smush +15
resultX.png
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,-density 96 result.png
Maybe you could know how to do it. Thanks
– Ger Cas
Nov 16 '18 at 15:50
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
|
show 7 more comments
Does this do what you want? ImageMagick 6 command could be like the following as one way to do it:
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png )
( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png )
-smush +24
( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png )
-smush +15
result.png
Note that I may not have used the same font as you.
Please review:
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#smush
https://imagemagick.org/Usage/files/#write
To answer your Update2 question: You need to resent the gravity with +gravity after you have used it with -gravity center. Also you need to add +repage after your crops.
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24 +gravity
(
( mpr:img -crop 881x488+71+376 +repage )
( mpr:img -crop 881x488+992+376 +repage )
+smush +6 -resize 1180x441!
)
-gravity center -smush +15
resultX.png
Does this do what you want? ImageMagick 6 command could be like the following as one way to do it:
convert ( ( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
-write P3.png )
( ( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2 -write P1.png )
-smush +24
( ( -size 881x488 xc:"#FFE97F" )
( -size 881x488 xc:"#00FF90" )
+smush +6 -resize 1180x441! -write P2.png )
-smush +15
result.png
Note that I may not have used the same font as you.
Please review:
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#smush
https://imagemagick.org/Usage/files/#write
To answer your Update2 question: You need to resent the gravity with +gravity after you have used it with -gravity center. Also you need to add +repage after your crops.
convert
source.png +repage -write mpr:img -delete 0--1
(
( -size 1104x89! xc:"#00137F" -fill white -font Calibri-Bold -pointsize 48 -gravity center -annotate +0+0 "Different boxes" )
)
(
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 1" )
( -size 426x37 xc:"#4FA7FF" -fill black -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Number 2" )
+smush +2
)
-smush +24 +gravity
(
( mpr:img -crop 881x488+71+376 +repage )
( mpr:img -crop 881x488+992+376 +repage )
+smush +6 -resize 1180x441!
)
-gravity center -smush +15
resultX.png
edited Nov 19 '18 at 6:46
answered Nov 16 '18 at 1:04
fmw42fmw42
8,42441831
8,42441831
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,-density 96 result.png
Maybe you could know how to do it. Thanks
– Ger Cas
Nov 16 '18 at 15:50
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
|
show 7 more comments
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,-density 96 result.png
Maybe you could know how to do it. Thanks
– Ger Cas
Nov 16 '18 at 15:50
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Hi fmw42, thanks for your answer. That seems to work, but sorry, I wasn't precise in my original post since I would like to create the final image without the need to create temporal files (P1, P2,P3), because of that I've been trying without success with mpr. Is possible to do it saving on memory p1, p2 and p3 with mpr?
– Ger Cas
Nov 16 '18 at 3:15
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
Those were there because you created them in your command. Just remove the -write P1.jpg etc. and it should work without them.
– fmw42
Nov 16 '18 at 3:39
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
You're right. Removing -write px it works. The size is correct, the only thing is how to add the resulting image have a resolution of 96 pixels/inch?
– Ger Cas
Nov 16 '18 at 4:26
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,
-density 96 result.png
Maybe you could know how to do it. Thanks– Ger Cas
Nov 16 '18 at 15:50
Hi fmw42, I added "-density 96" at the end bu doesn't change the resolution to final image,
-density 96 result.png
Maybe you could know how to do it. Thanks– Ger Cas
Nov 16 '18 at 15:50
1
1
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
I have edited my last answer to correct for the centering by adding -gravity center near the end before the last -smush 15 so that the bottom image is center aligned with the previous top two images.
– fmw42
Nov 19 '18 at 6:47
|
show 7 more comments
With well considered use of ImageMagick's memory registers, like "mpr:something", you can simplify the construction of your entire image to something like this...
convert -gravity center -background white -font helvetica
-size 1104x89 xc:"#00137F" -fill white -pointsize 48
-annotate +0+0 "Different boxes" -write mpr:diffbox +delete
-size 426x37 xc:"#4FA7FF" xc:"#4FA7FF" -fill black -pointsize 32
-annotate +0+0 "Number %[fx:t+1]" +smush 2 -write mpr:numbox +delete
-size 588x441 xc:"#FFE97F" xc:"#00FF90" +smush 4
mpr:numbox +insert -smush 15 mpr:diffbox +insert -smush 24 result.png
That works for me on Windows Ubuntu bash shell running ImageMagick 6.8.9-9. You'll have to specify your own font, and if you're using the same font for everything you only have to specify it once.
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.
– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
|
show 2 more comments
With well considered use of ImageMagick's memory registers, like "mpr:something", you can simplify the construction of your entire image to something like this...
convert -gravity center -background white -font helvetica
-size 1104x89 xc:"#00137F" -fill white -pointsize 48
-annotate +0+0 "Different boxes" -write mpr:diffbox +delete
-size 426x37 xc:"#4FA7FF" xc:"#4FA7FF" -fill black -pointsize 32
-annotate +0+0 "Number %[fx:t+1]" +smush 2 -write mpr:numbox +delete
-size 588x441 xc:"#FFE97F" xc:"#00FF90" +smush 4
mpr:numbox +insert -smush 15 mpr:diffbox +insert -smush 24 result.png
That works for me on Windows Ubuntu bash shell running ImageMagick 6.8.9-9. You'll have to specify your own font, and if you're using the same font for everything you only have to specify it once.
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.
– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
|
show 2 more comments
With well considered use of ImageMagick's memory registers, like "mpr:something", you can simplify the construction of your entire image to something like this...
convert -gravity center -background white -font helvetica
-size 1104x89 xc:"#00137F" -fill white -pointsize 48
-annotate +0+0 "Different boxes" -write mpr:diffbox +delete
-size 426x37 xc:"#4FA7FF" xc:"#4FA7FF" -fill black -pointsize 32
-annotate +0+0 "Number %[fx:t+1]" +smush 2 -write mpr:numbox +delete
-size 588x441 xc:"#FFE97F" xc:"#00FF90" +smush 4
mpr:numbox +insert -smush 15 mpr:diffbox +insert -smush 24 result.png
That works for me on Windows Ubuntu bash shell running ImageMagick 6.8.9-9. You'll have to specify your own font, and if you're using the same font for everything you only have to specify it once.
With well considered use of ImageMagick's memory registers, like "mpr:something", you can simplify the construction of your entire image to something like this...
convert -gravity center -background white -font helvetica
-size 1104x89 xc:"#00137F" -fill white -pointsize 48
-annotate +0+0 "Different boxes" -write mpr:diffbox +delete
-size 426x37 xc:"#4FA7FF" xc:"#4FA7FF" -fill black -pointsize 32
-annotate +0+0 "Number %[fx:t+1]" +smush 2 -write mpr:numbox +delete
-size 588x441 xc:"#FFE97F" xc:"#00FF90" +smush 4
mpr:numbox +insert -smush 15 mpr:diffbox +insert -smush 24 result.png
That works for me on Windows Ubuntu bash shell running ImageMagick 6.8.9-9. You'll have to specify your own font, and if you're using the same font for everything you only have to specify it once.
answered Nov 16 '18 at 3:56
GeeMackGeeMack
1,186125
1,186125
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.
– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
|
show 2 more comments
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.
– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
Hi GeeMack. Thanks for your solution either. It works pretty fine too in a completely different way to do it. I see I need to learn a lot about it. How to add a resolution of 96 pixel/inch without change the size?
– Ger Cas
Nov 16 '18 at 4:40
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
You can add "-density 96" to the command without affecting the dimensions in pixels. But remember, if you set the density before the "-annotate" operations you may have to specify different pointsizes to get the results you want.
– GeeMack
Nov 16 '18 at 4:51
Hi GeeMack. I added "-density 96" at the beginning and
-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.– Ger Cas
Nov 16 '18 at 15:47
Hi GeeMack. I added "-density 96" at the beginning and
-smush 24 -density 96 result.png
and in other places and doesn't seem to make any change in resolution.– Ger Cas
Nov 16 '18 at 15:47
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Setting the resolution with "-density" won't change the appearance of the image. It's mostly only relevant when the image is printed or when reading in vector images, etc. You may be looking to do something like "-resample" which will adjust the dimensions. Find out more about using "-resample" at this link – imagemagick.org/Usage/resize/#resample
– GeeMack
Nov 16 '18 at 16:01
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
Hi GeeMack. I think is not resampling nor resize, but actually resolution. May you see my update in original post where I show about the resolution. Thanks.
– Ger Cas
Nov 16 '18 at 17:18
|
show 2 more comments
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329754%2fmerge-3-images-in-a-single-convert-command-mantaining-size-imagemagick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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