-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
%opaque not working for WMF with text with transparent background #7295
Comments
It seems the problem isn't in %[opaque], but a mis-reading of the file test.wmf. I test with the simple command:
When using IM v7.1.1-28 (pre-built binary) on Windows 11, the output is 32173x13547 pixels, entirely opaque white. When using IM v7.1.1-27 (Beta) built by me, without libwmf, the output is 912x384 pixels, entirely opaque, mostly either white or black. When viewing text.wmf with Windows Paint, the result is similar to IM v7.1.1-27, but black characters on a transparent background. |
The size problem (32173x13547 pixels) can be fixed by supplying a sensible density, eg:
The result is grayscale, black text on a white background. This suggests that the WMF contains a problematic density. We are getting the defaults background, which is white. We should be able to change this with
However, the result is entirely opaque black. We can try a different background:
The result is black text on an opaque blueish background. The background colour is correct, but there is no transparency. I don't know why not. Possibly a bug in IM or libwmf or something. |
Thank you for looking into this. Do you know if there's an easy way to tell
if a wmf file contains a bitmap or only vector graphics? (so I could assume
transparency from that) My only estimate now is to read the META header and
look at the size of the max record, number of objects and see if the dpi
value is inflated.
…On Tue, May 7, 2024, 15:05 snibgo ***@***.***> wrote:
The size problem (32173x13547 pixels) can be fixed by supplying a sensible
density, eg:
magick -density 100 text.wmf t.png
The result is grayscale, black text on a white background. This suggests
that the WMF contains a problematic density.
We are getting the defaults background, which is white. We should be able
to change this with -background None, eg:
magick -density 100 -background None text.wmf t.png
However, the result is entirely opaque black.
We can try a different background:
magick -verbose -background sRGB(50%,75%,95%,0.5) -density 100 text.wmf t4.png
The result is black text on an opaque blueish background. The background
*colour* is correct, but there is no transparency. I don't know why not.
Possibly a bug in IM or libwmf or something.
—
Reply to this email directly, view it on GitHub
<#7295 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BIKKOYOFKHC5IINWJU7KHITZBDGRDAVCNFSM6AAAAABHKISTROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJYGM3DCMBQGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I last used WMF in the 1990s, and can't remember any details. https://en.wikipedia.org/wiki/Windows_Metafile may be useful. We can rasterize the WMF twice, at the same density but with different backgrounds. Then (assuming no anti-alias) any pixels that are different must be background, so we can use that for opacity. Windows BAT syntax:
|
Yes it's some files from old powerpoint presentations. Thanks for the
suggestion!
…On Tue, May 7, 2024, 19:49 snibgo ***@***.***> wrote:
I last used WMF in the 1990s, and can't remember any details.
https://en.wikipedia.org/wiki/Windows_Metafile may be useful.
We can rasterize the WMF twice, at the same density but with different
backgrounds. Then any pixels that are different must be background, so we
can use that for opacity. Windows BAT syntax:
magick ^
( -density 100 -background Red text.wmf +write mpr:REDBK ) ^
( -density 100 -background Lime text.wmf ) ^
-compose Difference -composite ^
-negate ^
mpr:REDBK ^
+swap ^
-alpha off -compose CopyOpacity -composite ^
out.png
—
Reply to this email directly, view it on GitHub
<#7295 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BIKKOYNRV66T5QK5AMWWEYLZBEHZVAVCNFSM6AAAAABHKISTROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJYHE4DQNRYGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
ImageMagick version
7.1.1-27 Q16-HDRI x64 0225ac4:20240121
Operating system
Windows
Operating system, version and so on
11
Description
magick identify -format "%[opaque]" .\text.wmf
True
text.zip
Steps to Reproduce
magick identify -format "%[opaque]" .\text.wmf
Images
The text was updated successfully, but these errors were encountered: