How to know the image's transparent space?
Re: How to know the image's transparent space?
I want to see if this image is fully transparent, if not I will trim this image as I mentioned above, so I cannot tell if it is transparent from detect transparency command right?
is there a way I can just know if this is a fully transparent image or not? I don't want to know some transparency
what is easiest and fastest way to do it? for we have a lot of image to processing, so want to reduce some time
is there a way I can just know if this is a fully transparent image or not? I don't want to know some transparency
what is easiest and fastest way to do it? for we have a lot of image to processing, so want to reduce some time
Re: How to know the image's transparent space?
in the other answer I saw you are using this command, is this the only way to do it?
convert transparent_image.png -channel a -separate -scale 1x1! -format "%[fx:mean]\n" info:
convert transparent_image.png -channel a -separate -scale 1x1! -format "%[fx:mean]\n" info:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to know the image's transparent space?
I do not fully understand your question. Please clarify. Do you care if opaque around the edges of the image, but transparent inside the image?
If you want to know if the image is fully transparent everywhere, then the result would be 0 from my command. You can also tell if the image is fully opaque (no transparency) by using
If returns true, it is fully opaque. If returns false, it has some (partial) transparency somewhere in the image.
See https://imagemagick.org/script/escape.php
If you want to know if the image is fully transparent everywhere, then the result would be 0 from my command. You can also tell if the image is fully opaque (no transparency) by using
Code: Select all
convert image -format "%[opaque]" info:
See https://imagemagick.org/script/escape.php
That works also. It just averages the image to 1 pixel first. I am not sure which is faster. You would have to test both ways.convert transparent_image.png -channel a -separate -scale 1x1! -format "%[fx:mean]\n" info:
Re: How to know the image's transparent space?
thanks for you answer, in this case, I only care the image is fully transparent or not fully transparent, I think I would go with this command, if there is other shorter one, since I use java code, so shorter one might be clearer, but if not, it is fine
convert transparent_image.png -channel a -separate -scale 1x1! -format "%[fx:mean]\n" info:
convert transparent_image.png -channel a -separate -scale 1x1! -format "%[fx:mean]\n" info:
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to know the image's transparent space?
You don't need "-channel a -separate -scale 1x1" . Just use "%[fx:mean.a]", the mean of the alpha channel.
snibgo's IM pages: im.snibgo.com
Re: How to know the image's transparent space?
thanks, it works
I have another question, so currently I am running two commands in my java application. one is scale image, the other is remove transparent space and get image offset, what I mentioned in this post, but it running is too slow, is there a way to increase the processing speed?
I have another question, so currently I am running two commands in my java application. one is scale image, the other is remove transparent space and get image offset, what I mentioned in this post, but it running is too slow, is there a way to increase the processing speed?
Re: How to know the image's transparent space?
one interesting thing is it is much slower because I used 7.X version in my java application, but if I switched to 6.9 version, it is much faster, but one compare command is starts fail
Re: How to know the image's transparent space?
one compare image are same command starts fail and detect transparent image command did not work also
image magick version: 6.9.4_1
image magick version: 6.9.4_1
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to know the image's transparent space?
This is an old post and the topics have changed since it was first posted. Please start a new question with your issue. It is not explained here very well.
ImageMagick 7 is slower than ImageMagick 6, because the default for ImageMagick 7 is HDRI enabled, which is not the case for ImageMagick 6. Also IM 6.9.4.1 is ancient.
ImageMagick 7 is slower than ImageMagick 6, because the default for ImageMagick 7 is HDRI enabled, which is not the case for ImageMagick 6. Also IM 6.9.4.1 is ancient.
Re: How to know the image's transparent space?
got it, start a new post, thank you!
Re: How to know the image's transparent space?
Hi,
when I used this command to trim the white space, if get output like 0x0+4500+5400, can I assume it is a fully transparent image when I use IM6? for the other method to take care of this is a bit slow, I want to combine to see if I can tell from this command
convert SHIRT_ART_IMAGE1.png -format "%@" +write info: -trim +repage -bordercolor none -border 5 SHIRT_ART_IMAGE1_trim.png
when I used this command to trim the white space, if get output like 0x0+4500+5400, can I assume it is a fully transparent image when I use IM6? for the other method to take care of this is a bit slow, I want to combine to see if I can tell from this command
convert SHIRT_ART_IMAGE1.png -format "%@" +write info: -trim +repage -bordercolor none -border 5 SHIRT_ART_IMAGE1_trim.png
Re: How to know the image's transparent space?
basically if output coordinates is 0x0 I mean, can I assume it is a fully transparent image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to know the image's transparent space?
Probably. But to test if an image is fully transparent, the best command would be
convert image.png -channel a -format "%[fx:mean]" info:
If 0, then fully transparent.
convert image.png -channel a -format "%[fx:mean]" info:
If 0, then fully transparent.
Re: How to know the image's transparent space?
Yeah, but it takes too much time looks like, after getting rid of this command, time is durable now
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to know the image's transparent space?
"-format %@" gives 0x0 when all the pixels are the same. They might all be transparent, or all be opaque Red, or opaque White, or anything else.niyanwen wrote:basically if output coordinates is 0x0 I mean, can I assume it is a fully transparent image?
snibgo's IM pages: im.snibgo.com