This is the initial image:
I wanted to severely round the corners of an image without having jagged edges but i can't remove the black around them.
convert image.jpg '(' +clone -crop 64x64+0+0 -fill white -colorize 100% -draw 'fill black circle 60,60 60,0' -background transparent -alpha shape '(' +clone -flip ')' '(' +clone -flop ')' '(' +clone -flip ')' ')' -flatten image.png;
Anyone has an ideea? I tried -background transparent and other stuff and it's not working.
The result i want is the image to have severely rounded corners without the black around them.
I managed to fix it.
Used:
convert image.jpg '(' +clone -alpha extract '(' -size 100x100 xc:black -draw 'fill white circle 100,100 100,0' -write mpr:arc +delete ')' '(' mpr:arc ')' -gravity northwest -composite '(' mpr:arc -flip ')' -gravity southwest -composite '(' mpr:arc -flop ')' -gravity northeast -composite '(' mpr:arc -rotate 180 ')' -gravity southeast -composite ')' -alpha off -compose CopyOpacity -composite -compose over '(' +clone -background black -shadow 80x3+5+5 ')' +swap -background none -layers merge -rotate 1 image.png;
Now it looks like this
Related
Hey all I have this code below that takes 2 images and merges them together with it fading in the center:
convert testingl.jpg -gravity West ^
testingr.jpg -gravity East ^
blend_mask.png -extent 1080x440 -gravity center -composite bothBlended.jpg
The above produces this:
Using this mask:
Taken from these 2 images (lowered res to fit on here):
testingl.jpg (original size 1224 x 1632)
testingr.jpg (original size 828 x 1792)
This code works great as-is. Does what I need it to do but with one exception - I am wanting to get more of each image into it. Like resize the image, crop from the center the image then take that and blend it. I need to keep the same 1080 x 440 overall size.
Do that with both would look something like this:
UPDATE 1
When running #fmw42's code:
convert ^
( testingl.jpg -resize 1080x440^ -gravity West -extent 1080x440 ) ^
( testingr.jpg -resize 1080x440^ -gravity East -extent 1080x440 ) ^
blend_mask.png -composite abc.jpg
I get this:
Your ImageMagick command does not generate your proposed output image. I think it is missing a resize and parentheses.
In Unix syntax, I need the following to get your output.
convert \
\( testingl.png -resize 1080x440^ -gravity West -extent 1080x440 \) \
\( testingr.png -resize 1080x440^ -gravity East -extent 1080x440 \) \
blend_mask.png -composite bothBlended1.jpg
or perhaps you want
convert \
\( testingl.png -resize 1080x440^ -gravity West -extent 1080x440 \) \
\( testingr.png -resize 1080x440! -gravity East -extent 1080x440 \) \
blend_mask.png -composite bothBlended2.jpg
I have the following image:
I would like to use ImageMagick to split it horizontally into two unequal parts of 40-60% (L-R). How do I do this?
You can do that as follows in ImageMagick 6. Read the image into MPR memory and delete the original. Then use the MPR copy to crop 40% once with gravity west and crop 60% again with gravity east (that is 40% from the left side and then 60% from the right side). Write those images and then exit with no output, i.e., null:
Unix Syntax:
convert red_rect.png +repage -write mpr:img +delete \
\( mpr:img -gravity west -crop 40x100%+0+0 +repage +write left.png \) \
\( mpr:img -gravity east -crop 60x100%+0+0 +repage +write right.png \) \
null:
For Windows,
convert red_rect.png +repage -write mpr:img +delete ^
( mpr:img -gravity west -crop 40x100%+0+0 +repage +write left.png ) ^
( mpr:img -gravity east -crop 60x100%+0+0 +repage +write right.png ) ^
null:
(In .bat file, double the % to %%)
(For ImageMagick 7, change convert to magick)
Left:
Right:
Just for fun, a slightly different version:
load image
make clone, crop left side and save, delete clone
revert to original, crop right side and save
magick GhLiu.png +repage \( +clone -crop 40x100%+0+0 +repage +write left.png +delete \) -gravity east -crop 60x100%+0+0 +repage right.png
I am trying to composite two images with gravity, and then position them within a larger image at a geometry.
When I try
magick -size 1045x837 xc:blue \( -size 345x437 xc:red \( -size 275x417 xc:white -resize 345x437 -gravity center \) -composite \) -geometry +26+53 -composite test-y.png
I get
and when I do
magick -size 1045x837 xc:blue \( -size 345x437 xc:red \( -size 275x417 xc:white -resize 345x437 \) -composite \) -geometry +26+53 -composite test-x.png
I get
I think this involves clone and related, maybe similar to this answer, but I just can't find the combo.
What do I need to do, to get the white centered within the red, and geometrically placed in the upper-left corner?
It's not clear exactly what you want, but I think you are falling foul of the fact that -gravity is a "setting". As such, it remains set until changed, so you probably want this, where I reset the gravity to NorthWest before the final composite:
magick -size 1045x837 xc:blue \( -size 345x437 xc:red \( -size 275x417 xc:white -resize 345x437 -gravity center \) -composite \) -gravity northwest -geometry +26+53 -composite result.png
You might find -extent a simpler way to fill out the white to a given size using a red background:
magick -size 1045x837 xc:blue \( -size 275x417 xc:white -resize 345x437 -background red -gravity center -extent 345x437 \) -gravity northwest -geometry +26+53 -composite result.png
I'm using the following command to create a caption. But I want to control the interline spacing as well. When I set the value to negative (to get the lines closer to eachother), the first line gets it's capital letters cut off. I tried added a "border", but that just adds a border - doesn't add "padding". Is there a way to add "padding"?
convert templates/input.pdf -font test.ttf
-size 1245x283! -background red -fill white -gravity northwest
-interline-spacing -25
caption:"Interline-Spacing NOT WORKING\r\nwith Captions"
-geometry +129+129 -composite output/temp.png
In ImageMagick, you can set the -gravity center, then use -trim +repage, if you want to remove excess around the text and then add any amount of border back using -border or -extent if you know the desired output size.
Try this using unix syntax:
convert \( -size 2115x560 xc:skyblue \) \( -size 1245x283! -background red -fill white -gravity center -font arial -interline-spacing -25 caption:"Interline-Spacing NOT WORKING\r\nwith Captions" -trim +repage -background red -extent 1245x283! \) -gravity northwest -geometry +129+129 -composite temp.png
or this in Windows:
convert ( -size 2115x560 xc:skyblue ) ( -size 1245x283! -background red -fill white -gravity center -font arial -interline-spacing -25 caption:"Interline-Spacing NOT WORKING\r\nwith Captions" -trim +repage -background red -extent 1245x283! ) -gravity northwest -geometry +129+129 -composite temp.png
If you want the white text left justified, then use -gravity west before -extent and -gravity west before the caption:
convert \( -size 2115x560 xc:skyblue \) \( -size 1245x283! -background red -fill white -gravity west -font arial -interline-spacing -25 caption:"Interline-Spacing NOT WORKING\r\nwith Captions" -trim +repage -background red -gravity west -extent 1245x283! \) -gravity northwest -geometry +129+129 -composite temp2.png
Replace your input image in place of my -size 2115x560 xc:skyblue and your font for mine.
I would guess the interline spacing is from the base line of the text up. Lower letters will protrude below the base line. I suppose it is more of a "line height"
The obvious solution is to either increase the spacing to allow for capital letters or do not use capital letters.
A setting of -15 seems to work for what you are doing.
Hi I would like to create a mask image with "special corners" I am calling them special because I don't really know how to call them in english here is what I would like to achieve:
what I am using now is
convert xc:black -size 300x300 -fill white -draw "roundrectangle 3,3,296,296,5,5"
but this gives me rounded corners. Thank you in advance for any suggestions.
Here's one way of doing it.
convert -size 300x300 xc:none \
-shave 10 -bordercolor black -border 10 \
-fill black -draw "polyline 0,0 30,0 0,30" \
\( +clone -flip \) -gravity north -composite \
\( +clone -flop \) -gravity south -composite -background white -flatten result.png
That says... "Draw a rectangle your full size and transparent, shave 10 pixels off all round and add a 10 pixel black border (easier than doing the maths and making a 280x280 and adding 10 on each side). Draw a triangle in the top-left. Copy the whole shape and flip it and draw it on top of the original. Copy the whole shape and flop it and draw it again on the original. Now make all the transparent areas white."
Here is another way - maybe a little easier. Draw the original square, then copy it, enlarge it by square-root(2) (i.e. 141%), thicken the borders, rotate 45 degrees and composite it onto itself. Kinda depends how your brain works!
magick -size 300x300 xc:none -shave 10 -bordercolor black -border 10 \
\( +clone -scale 142% -shave 30 -border 30 -rotate 45 \) \
-gravity center -composite -background white -flatten result.png
Here is a link to a page showing how to do what you want along with other effects https://www.imagemagick.org/Usage/thumbnails/#rounded
This is the code from the page:
convert thumbnail.gif -alpha set -compose DstOut \
\( -size 20x15 xc:none -draw "polygon 0,0 0,14 19,0" \
-write mpr:triangle +delete \) \
\( mpr:triangle \) -gravity northwest -composite \
\( mpr:triangle -flip \) -gravity southwest -composite \
\( mpr:triangle -flop \) -gravity northeast -composite \
\( mpr:triangle -rotate 180 \) -gravity southeast -composite \
corner_cutoff.png
You should check out the examples as there is another method you could use for smaller images.