Imagemagick is the best for effecting images or creating filters.
I am testing new filter functions using Image Magic.
Change the color RGB image to GrayScale and change the Pixel Point value of the GrayScaled image to the Opacity value.
And finally, I want to change all the colors to black while maintaining the Opacity value.
In short
1. Convert RGB -> GrayScale
2. Convert GrayScale Image Pixel Value to Opacity Value
3. Convert GrayScale Color to Black Color (Keep Transparency)
I'd like to create custom filter
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: I'd like to create custom filter
What is your IM version and platform/OS? Please always provide that since syntax differs. Here is the command line code if you want the output to be grayscale with transparency.
The output cannot be jpg because it does not support transparency. GIF only provides binary (on/off) transparency. So for 8-bit transparency, you should use either PNG or TIFF. You can start with any color image format, even jpg. So I did not put the suffix on the input, but you need to add whatever format suffix corresponds to your actual image.
If you want to keep the image as color and put the grayscale version in the alpha channel, then do the following (unix syntax)
See
http://www.imagemagick.org/Usage/masking/
Sorry, I do not know how to do this in any API such as Magickwand.
Code: Select all
convert rgbimage -colorspace gray -alpha copy -background black -alpha background transparentgrayimage.png
If you want to keep the image as color and put the grayscale version in the alpha channel, then do the following (unix syntax)
Code: Select all
convert rgbimage \( -clone 0 -colorspace gray \) -alpha off -compose copy_opacity -composite -background black -alpha background transparentcolorimage.png
http://www.imagemagick.org/Usage/masking/
Sorry, I do not know how to do this in any API such as Magickwand.
Re: I'd like to create custom filter
Thank you for quick response.
The current operating system is Windows-based, and the -clone command of the current command does not work
not.
When you run the command
Error Message
C:\work>convert rgbimage.png -colorspace Gray -alpha off -compose copy_opacity -
composite -background black -alpha background mask_1.png
convert.exe: no images defined `mask_1.png' @ error/convert.c/ConvertImageComman
d/3241.
-----------------------------------------------------
And to help you get a better understanding
There is no Alpha value in the original file
I want to implement Opacity using color value.
If the K value is 20 then Opacity 20, K value is 100 then Opacity 100, and K value is 5 then Opacity 5 should be treated as GrayScale.
Please check and answer.
The current operating system is Windows-based, and the -clone command of the current command does not work
not.
When you run the command
Error Message
C:\work>convert rgbimage.png -colorspace Gray -alpha off -compose copy_opacity -
composite -background black -alpha background mask_1.png
convert.exe: no images defined `mask_1.png' @ error/convert.c/ConvertImageComman
d/3241.
-----------------------------------------------------
And to help you get a better understanding
There is no Alpha value in the original file
I want to implement Opacity using color value.
If the K value is 20 then Opacity 20, K value is 100 then Opacity 100, and K value is 5 then Opacity 5 should be treated as GrayScale.
Please check and answer.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: I'd like to create custom filter
What version of IM are you using? Are you running IM convert.exe or Windows convert.exe? If you IM version is too old, then -alpha may not have been defined. That is why I keep asking what your IM verison is.
I do not see any clone command in the command line you ran and provided above with the mask_1.png error.
In windows \( ... \) become ( ... ) (remove the \). That is why I asked what your OS was, since syntax is different. See http://www.imagemagick.org/Usage/windows/
I do not see any clone command in the command line you ran and provided above with the mask_1.png error.
In windows \( ... \) become ( ... ) (remove the \). That is why I asked what your OS was, since syntax is different. See http://www.imagemagick.org/Usage/windows/
Re: I'd like to create custom filter
First, we processed the instruction as given, and we confirmed that the instruction was working.
Command Execution
C:\work>convert rgbimage.png -clone 0 -colorspace Gray -alpha off -compose copy_
opacity -composite -background black -alpha background mask_1.png
===============================================
What I want is to reflect the transparency using the color values of the original file.
For example, if K is 30 then Opacity is 70 and if K is 100 then Opacity is 0.
Since the original file does not have transparency, I want to create transparency using the K value.
Please check one more time.
And I am grateful for this interest.
Command Execution
C:\work>convert rgbimage.png -clone 0 -colorspace Gray -alpha off -compose copy_
opacity -composite -background black -alpha background mask_1.png
===============================================
What I want is to reflect the transparency using the color values of the original file.
For example, if K is 30 then Opacity is 70 and if K is 100 then Opacity is 0.
Since the original file does not have transparency, I want to create transparency using the K value.
Please check one more time.
And I am grateful for this interest.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: I'd like to create custom filter
You cannot have clones without parentheses. Window syntax makes the grayscale image as the alpha channel with reverse values and puts it into the color image as its alpha channel. Be sure convert.exe is the IM convert.exe and not the Windows convert.exe.convert rgbimage.png -clone 0 -colorspace Gray -alpha off -compose copy_opacity -composite -background black -alpha background mask_1.png
Code: Select all
convert.exe rgbimage.png ( -clone 0 -colorspace Gray -negate ) -alpha off -compose copy_opacity -composite -background black -alpha background result.png
If this is what you want, then1. Convert RGB -> GrayScale
2. Convert GrayScale Image Pixel Value to Opacity Value
3. Convert GrayScale Color to Black Color (Keep Transparency)
Code: Select all
convert.exe ( rgbimage.png -colorspace Gray ) ( -clone 0 -negate ) -alpha off -compose copy_opacity -composite -background black -alpha background result.png
Please clarify what you want and provide your IM version.
Re: I'd like to create custom filter
Hello fmw42~
I was able to solve the problem I was trying to solve with the command you gave me.
Thank you again.
I was able to solve the problem I was trying to solve with the command you gave me.
Thank you again.