Hello Ben,
> I think you can, just about, do it with zenity. The key is to use a
> text-info dialog with HTML as the text format:
>
> zenity --text-info --html --filename=...
--html is not in the man page, so I would never have found that out.
> (you can add a "this is the right image" checkbox if you like).
>
> However, there are two catches: (1) you must use a file name, and (2)
> you don't seem to be able to use local file references in the image tag
> (i.e. <img src="file:///home/ben/pic.jpg"> does not work).
>
> If you want to avoid creating a temporary file you can get round (1)
> using a trick like /dev/stdin provided your system supports it. To get
> round (2) you can use an inline data URL. These look like this:
Nice trick with stdin, I would have tried something with --filename=<(...)
> src="data:image/jpg;base64,...".
I was vaguely aware of the possibility to inline binary code in html, but
I'd never used it.
> Here's an example:
>
> (echo "<h1>Is this the right image?</h1><img src=\"data:"
> mimetype -b "$1"
> echo -n ";base64,"
> base64 "$1"
> echo "\">") | zenity --text-info --html --filename=/dev/stdin
Thanks a lot, your example is spot on and it's great because with the html I
don't need to perform image processing beforehand to adjust the sizes.
I modified it to do what I wanted, a simple image compare popup:
# Call this with two file names
Size=300
Style=" STYLE=\"max-width:$Size; max-height:$Size\""
function Identical() {
(echo "<TABLE><TR><TD STYLE=\"width:100%; margin:0px auto;\"><IMG$Style
SRC=\"data:"
mimetype -b "$1"
echo -n ";base64,"
base64 "$1"
echo "\"></TD><TD><IMG$Style SRC=\"data:"
mimetype -b "$2"
echo -n ";base64,"
base64 "$2"
echo "\"></TD></TR></TABLE>"
) |
zenity --ok-label=Identical --cancel-label=Different --width=$(($Size*2+50))
--height=$(($Size+100)) --title="Are those two images identical?" --text-
info --html --filename=/dev/stdin;