ImageMagick Colorize GIF and Preserve Transparency - imagemagick

I have a small icon GIF that I would like to change the color. All opaque GIF pixels should be replaced by this new color, but preserve transparency for the gif. Then I need to place that new colored GIF over a background map, all in one command line. Here is what I have, but it's not changing all gif opaque pixels. Attached is the GIF icon. (Edit: I know im only targeting the white here, but just can't figure out how to target ALL opaque pixels in the GIF)
exec("{$convert} {$map_image} \( {$map_icon} -fill orange -opaque white -geometry +1700+600 \) -composite map2.jpg ");

Use +opaque none to fill all non-transparent colors in ImageMagick. The +opaque means everything "but" that color.
convert grid.gif -fill orange +opaque none x.png

Related

Imagemagick - Inverse

I've a png image containing transparent pixels and colored pixels (mainly white).
I'd like to transform all transparent pixels to white pixels and all white pixels to transparent pixels within a given rectangle.
My idea would be to
convert the white pixels to red
the transparent colors to white
and the red colors to transparent
. Here' s my code:
1) convert ldl_0.png -fuzz 10% -fill red -opaque white lx.png
2) convert lx.png -background white -alpha remove -alpha off lx2.png
However I can' t figure out how do I transform red colors to transparent. How do I do that?
Also how can I force to do this only within a given rectangle?
Thank You.
-----
Try this in ImageMagick. Negate the alpha channel and turn the whole RGB channels to white.
convert in.png -channel a -negate +channel -fill white -colorize 100 out.png

Imagemagick replace all colors in image with white

I have a bunch of PNG images (logos) that I want to convert to an all-white color pallet; basically I want to replace all non-transparent pixels with white pixels. Is there an easy way to do this in imagemagick?
You can do that in ImageMagick using -colorize.
convert input.png -fill white -colorize 100 output.png
It will preserve the transparent pixels and make everything else white.

remove white background with ImageMagick but not the white inside picture?

im trying to delete the background with a batch process in pictures of products for an e-commerce site.
The problem is that the script also remove the white color in the inside of the product, leaving the product transparent in some areas..
For example:
Command:
convert *.jpg -set filename: %t -fuzz 5% -transparent white %[filename:].png
this is the best I can get..im ok with this result around the product, but I need that the white inside the product remains white and not transparent.
The problem with your current approach is that it doesn't respect boundaries, it is just applied globally, making all white pixels transparent regardless of their connectivity to the background.
Instead, you will get on better using a "floodfill" that only floods into areas that are within the fuzz distance of the top-left corner pixel.
So, I chose an unused colour of magenta so you can see what is happening:
convert product.jpg -fuzz 5% -fill magenta -draw 'color 0,0 floodfill' result.png
You would then follow that with the command to make magenta transparent like this:
convert product.jpg -fuzz 5% -fill magenta -draw 'color 0,0 floodfill' -transparent magenta result.png

How to create transparent image for rubber stamp in ImageMagick

I have to create an image, which is an overlay texture made up of a white image with some transparency to give it the appearance of a rubber stamp.
For reference see the image "stamp_overlay.png" in the video http://railscasts.com/episodes/374-image-manipulation .
This is what i did:
convert -size 70x70 canvas:white stamp_overlay1.png
and then
convert stamp_overlay1.png -transparent white stamp_overlay1.png
But how do I make it like the image?
I am pretty much new to ImageMagick. Any help is highly solicited.
Updated Answer
Ok, I got that wrong! You want to create a stamp overlay, not overlay a stamp overlay. You can do that like this:
# Create white square, draw a black rectangle, then make black pixels transparent
convert -size 300x300 xc:white \
-fill black -draw "rectangle 20,100 200,280" \
-transparent black out.png
Original Answer
I find your question very hard to understand, but I think I know what you want. First, let's create a solid red image
convert -size 70x70 xc:red red.png
then let's composite the stamp_overlay.png image on top
convert red.png stamp_overlay.png -composite out.png
which gives this
but now you want to make the white areas transparent, so you need to do this:
convert red.png stamp_overlay.png -composite -transparent white out.png
and that still looks the same on this white background, but it isn't :-)

How to create transparent icon using ImageMagick?

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

Resources