I overlay the PNG image on background, also in PNG, but at the output I get that the color of the overlay image turned to gray.
How to make sure that the color does not change, but the image just overlays on the background?
convert.exe -composite -gravity center -geometry +0+120 -quality 100 "background.png" "3.png" "4.png"
3.png - Image overlay
4.png - Output image
Background.png - where to put 3.png
all images this
Related
I have around 2500 images. Some of them contains border while others arent. What I want to accomplish is to add border to the ones that doesn't have any.
Images with border are 64x64 and images without border are 56x56
I prepared a border image file with size of 64x64 in PNG format and I want to merge all files without border within this image to get them borders and output them as PNG format aswell.
I have tried several ways using ImageMagic but no luck so far.
If you make a 64x64 lime-magenta gradient as background.png and a solid blue 56x56 image as foreground.png like this:
magick -size 64x64 gradient:lime-magenta background.png
magick -size 56x56 xc:blue foreground.png
Your command to paste the foreground into the centre of the background is as simple as:
magick -gravity center background.png foreground.png -composite result.png
I figured out it's pretty doable with convert tool from the ImageMagick package.
First I extracted all images with size of 56x56 to different location, then I did the following;
I added 4 pixels on each side since my border is 64x64
for image in ICO_*.png; do
convert -page +0+0 border.png \
-page +4+4 $image \
-background none -layers merge +repage $image-withBorder.png
done
I have 3 png image: a red square with a transparent background (1.png), a map (PLAN.png) and a color gradient with a transparent background (LEGEND.png). I want to first put the red square atop the map and then put the color gradient atop of it, while keeping the original filename of the red square for multiple files in multiple folders
Here's what I came up with in the windows cmd:
cd [location of the folder]
magick convert ../PLAN.png 1.png -compose multiply -composite 1.png && magick composite ../LEGEND.png 1.png 1.png
The problem is that for each file, I need to manually change 1.png to for example 1 2 3.png . I had used this command:
magick mogrify -gravity center -draw "image Over 0,0 0,0 '../PLAN2.png'" *.png
While with it I don't have to manually manually change the 1.png, it doesn't work with the map since it put it atop of the red square
In ImageMagick 7, do the following. Note, use magick, not magick convert.
magick PLAN.png 1.png -compose over -composite LEGEND.png -compose over -composite 1.png
or
magick PLAN.png 1.png LEGEND.png -background none -flatten 1.png
Do either of those do what you want?
As the title suggests I have a PNG image that has some transparency. I'd like to fill that transparency with a second image (which is currently a JPEG, but it's not a problem to convert it to a PNG).
Every post I have found searching on the Internet was about the "inverse" problem (from an image with a background to an image with transparency), so obviously it did not work out for my situation; for example, I tried
convert -flatten myimg.png myimg.png
(taken from here) and
convert myimg1.png -transparent white myimg.png
(taken from here).
In ImageMagick 6, if the two images are the same size, then you can just flatten the transparent image over the background image.
Background (lena.jpg):
Transparent (logo_crop_trans.png):
convert lena.jpg logo_crop_trans.png -flatten lena_logo.jpg
If using ImageMagick 7, then change convert to magick.
If you want to anti-alias the transparent image so that it is not so jagged, then use some blur to smooth the outline (Unix syntax):
convert lena.jpg \( logo_crop_trans.png -channel a -blur 0x1 -level 50x100% +channel \) -compose over -composite lena_logo2.jpg
If on Windows remove the \ before the parentheses.
So here is my original image (note the transparent border) src.png:
Here's the mask I want to use to crop. White means keep, black means crop mask.png: (Note that it isn't necessarily going to be a square. It could be a heart or a star or anything)
I also have transparent.png, which is a fully transparent image. All three images have the same dimensions.
So, running this command generates the following image:
convert transparent.png src.png mask.png -composite out.png
Which is masking perfectly, but now I want it cropped to the size of the white mask area. Using -trim is sort of close, but it gets rid of the transparent areas that are inside the mask.
How can I resize the masked image to the size of the white area in the mask?
I am not sure I understand what you want for the result. Why do you need the fully transparent image? Do either of these do what you want?
Full sized transparent image with masked area showing:
convert src.png mask.png -alpha off -compose copy_opacity -composite result1.png
Trimmed to just the part you want:
convert src.png mask.png -alpha off -compose copy_opacity -composite -trim +repage result2.png
Not sure I understand what you are trying to do, not least why you need a full size transparent canvas. Your command does not give the same results on my ImageMagick version 7.
This command may be what you are looking for:
convert src.png mask.png -compose darken -composite -trim out.png
It gives this - I have artificially added a red border so you can see the full extent on StackOverflow's white background:
Or maybe you want the trim box from your mask and to use that to crop your source:
convert mask.png -format %# info:
113x113+570+33
convert src.png -crop 113x113+570+33 result.png
If you want to crop a square from picture, you no needs using mask, just crop it:
magick Uq328.png -crop -crop 111x111+570+331 +repage cropped.png
according to https://legacy.imagemagick.org/Usage/crop/
I'm trying to create icons (.ico format) with ImageMagick with only partial success. I can't get the resulting icon to have any transparency. I've tried many things like -alpha Background, -quantize transparent, -transparent-color, but I just can't get it working.
I can get it working if I don't reduce the colors -colors 256. It's with that reduction where I lose the transparency.
How do you produce a transparent icon with image magick (convert)?
I generate transparent PNGs with the -alpha transparent option. For example:
convert -size 100x100 -alpha transparent \
-stroke black -strokewidth 5 -fill blue \
-draw "rectangle 20,20,80,80" \
xc:#990000 test.png
This creates test.png with a floating blue box with a black border, inside an image with a transparent background. It uses a block colour as the "input" image , but the red is obliterated by the full transparency of its channel.
If you remove the alpha, you'll see the red source image.
Had the same problem when trying to generate a transparent favicon from transparent PNGs. Here's what worked for me:
convert transparent-img1.png transparent-img2.png transparent-img3.png -channel Alpha favicon.ico