Page 1 of 1
Remove grey background and turn it transparent
Posted: 2019-01-13T20:39:32-07:00
by jestarray
ImageMagick does not replace '#c0c0c0' with a transparent background
I have tried magick convert img.png -fuzz 50% -transparent '#c0c0c0' 0.png
and a convert option without "magick" running version windows 10 x64 v7.0.8-14Q16 .
A problem for later: using a bash script to convert 200 of these and it seems imagemagick also doesn't overwrite if output name is the same
here is the image:
https://i.imgur.com/JnNBtpX.png
No change...
Re: Remove grey background and turn it transparent
Posted: 2019-01-13T20:51:24-07:00
by snibgo
It works fine for me, with IM 7.0.7-28 on Windows 8.1:
Code: Select all
magick jnnbtpx.png -fuzz 50% -transparent #c0c0c0 x2.png
If you are using Windows, use double quotes not single quotes. If you use Windows BAT, double the percent sign: %%
I suggest you use "magick", not "magick convert".
Re: Remove grey background and turn it transparent
Posted: 2019-01-13T21:01:37-07:00
by jestarray
not working for me at all. I tried all the variations: of magick convert, magick, convert, running gitbash, running cmd...
strangely getting...
Code: Select all
getting magick.exe: unable to open image 'image.png': No such file or directory @ error/blob.c/OpenBlob/3490
then the file is right there, quadrupledcheck if I was still sane.. Tried double quoting the hex color, it outputs but does not remove the transparency.
on that note, -fuzz 50% ,not sure what that does, this is pixel art so i dont really want anything modified but removing the background.
Re: Remove grey background and turn it transparent
Posted: 2019-01-13T21:13:35-07:00
by jestarray
running it on linux and it works fine...
Re: Remove grey background and turn it transparent
Posted: 2019-01-14T08:07:23-07:00
by snibgo
jestarray wrote:getting
Where is that message coming from? Are you typing the command at the Windows command prompt in a Windows command window, or what? Are you in the correct directory?
Re: Remove grey background and turn it transparent
Posted: 2019-01-14T14:14:34-07:00
by GeeMack
Using IM 7.0.8-23 Q16 x64 HDRI on Windows 10 and the sample PNG image linked in the OP, and using these commands...
Code: Select all
magick convert JnNBtpX.png -fuzz 50% -transparent "#c0c0c0" 0.png
Code: Select all
magick JnNBtpX.png -fuzz 50% -transparent #c0c0c0 x2.png
... the results appear completely black when viewed with IrfanView, and unchanged from the input when viewed with Photoshop. In neither case does it result in changing the gray to transparent. I've tried to add "-background none" with no change in result.
I can make it change the gray to transparent if I add "-bordercolor none -border 0", but that surely isn't a workaround.
If I create the image from scratch using ImageMagick, the commands to change the gray to transparent work as expected. I haven't looked into the specs of the provided sample image, but it might be some kind of unconventional PNG file.
Re: Remove grey background and turn it transparent
Posted: 2019-01-14T14:38:51-07:00
by snibgo
The input is grayscale, with an offset, but those shouldn't create problems. Perhaps there is a recent bug in IM, possibly as part of "grayscale is a single channel" changes. Try "-colorspace sRGB" before "-transparent".