HTML insert image

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

HTML insert image

JAMES,
              gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST)
Dear ImageJ community,

I have spent enough time struggling so now it's time to ask the community...

With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.

Thanks,

Greg.

===================================================================
// This macro demonstrates how a macro can
// display a dialog box with a "Help" button
// that displays HTML formatted text.

  html = "<html>"
     +"<h2>HTML formatted help</h2>"
     +"<font size=+1>
     +"In ImageJ 1.46b or later, dialog boxes<br>"
     +"can have a <b>Help</b> button that displays<br>"
     +"<font color=red>HTML</font> formatted text.<br>"
     +"</font>";
  Dialog.create("Help");
  Dialog.addHelp(html);
  Dialog.show
===================================================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

Jan Eglinger
Dear Greg,

using script parameters [1], you can add an html label containing an
<img> tag. For example, these lines in a script:

     #@ String (label=" ", value="<html><img
src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\"></html>",
visibility=MESSAGE, persist=false) message1
     #@ String (label=" ", value="<html>Some <b>formatted</b>
message</html>", visibility=MESSAGE, persist=false) message2
     #@ String (label="Some input parameter") input_text

will create a dialog with image (screenshot attached).

Cheers
Jan

[1]: https://imagej.net/Script_Parameters


On 08.08.2018 15:29, Gregory James wrote:

> Dear ImageJ community,
>
> I have spent enough time struggling so now it's time to ask the community...
>
> With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.
>
> Thanks,
>
> Greg.
>
> ===================================================================
> // This macro demonstrates how a macro can
> // display a dialog box with a "Help" button
> // that displays HTML formatted text.
>
>    html = "<html>"
>       +"<h2>HTML formatted help</h2>"
>       +"<font size=+1>
>       +"In ImageJ 1.46b or later, dialog boxes<br>"
>       +"can have a <b>Help</b> button that displays<br>"
>       +"<font color=red>HTML</font> formatted text.<br>"
>       +"</font>";
>    Dialog.create("Help");
>    Dialog.addHelp(html);
>    Dialog.show
> ===================================================================
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Dialog_with_image.png (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

JAMES,
              gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST)
Hi Jan,

Thank you for the helpful reply but i was hoping you could dumb it down a bit for me. Is it possible for you to use the provided example code (below) as a template because I can follow this and it works when you copy and paste it into an ImageJ macro editor window. The code is from the ImageJ macro function page:

https://imagej.nih.gov/ij/macros/examples/DialogWithHelp.txt

I was hoping it would be a simple one-liner to add an image. Also, does the image have to be a url? I would preferably like to insert an image that has a file path location on the local computer. Is that possible?

As you can probably tell, I'm not familiar with HTML scripting.

Thanks for the help,

Greg.


=============================================================
// This macro demonstrates how a macro can
// display a dialog box with a "Help" button
// that displays HTML formatted text.

  html = "<html>"
     +"<h2>HTML formatted help</h2>"
     +"<font size=+1>
     +"In ImageJ 1.46b or later, dialog boxes<br>"
     +"can have a <b>Help</b> button that displays<br>"
     +"<font color=red>HTML</font> formatted text.<br>"
     +"</font>";
  Dialog.create("Help");
  Dialog.addHelp(html);
  Dialog.show
=============================================================



__________________________________________
Gregory James
Clinical Scientist (Nuclear Medicine)
Department of Physics and Nuclear Medicine
City Hospital
Dudley Road
Birmingham
B18 7QH

0121 507 4043
________________________________________
From: Jan Eglinger <[hidden email]>
Sent: 09 August 2018 09:20
To: [hidden email]
Subject: Re: HTML insert image

Dear Greg,

using script parameters [1], you can add an html label containing an
<img> tag. For example, these lines in a script:

     #@ String (label=" ", value="<html><img
src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\"></html>",
visibility=MESSAGE, persist=false) message1
     #@ String (label=" ", value="<html>Some <b>formatted</b>
message</html>", visibility=MESSAGE, persist=false) message2
     #@ String (label="Some input parameter") input_text

will create a dialog with image (screenshot attached).

Cheers
Jan

[1]: https://imagej.net/Script_Parameters


On 08.08.2018 15:29, Gregory James wrote:

> Dear ImageJ community,
>
> I have spent enough time struggling so now it's time to ask the community...
>
> With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.
>
> Thanks,
>
> Greg.
>
> ===================================================================
> // This macro demonstrates how a macro can
> // display a dialog box with a "Help" button
> // that displays HTML formatted text.
>
>    html = "<html>"
>       +"<h2>HTML formatted help</h2>"
>       +"<font size=+1>
>       +"In ImageJ 1.46b or later, dialog boxes<br>"
>       +"can have a <b>Help</b> button that displays<br>"
>       +"<font color=red>HTML</font> formatted text.<br>"
>       +"</font>";
>    Dialog.create("Help");
>    Dialog.addHelp(html);
>    Dialog.show
> ===================================================================
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html


********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

Jan Eglinger
Hi Greg,

sorry, I thought you'd want to have the image in the main dialog. For
the help button dialog, you can just add a line with an <img> tag to
your html like this:

   html = "<html>"
      +"<h2>HTML formatted help</h2>"
      +"<img
src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\">"
      +"<font size=+1>
      +"In ImageJ 1.46b or later, dialog boxes<br>"
      +"can have a <b>Help</b> button that displays<br>"
      +"<font color=red>HTML</font> formatted text.<br>"
      +"</font>";
   Dialog.create("Help");
   Dialog.addHelp(html);
   Dialog.show

I tried with a local path as well, but it didn't work for me, so you
might be limited to URLs indeed.

Regarding my previous example with script parameters, it is a complete
runnable example, you can paste it in the script editor [1] and run it.
But it won't work with plain ImageJ1, as script parameters are an IJ2
feature.

Cheers
Jan

[1]: https://imagej.net/Using_the_Script_Editor


On 09.08.2018 10:52, JAMES, gregory (SANDWELL AND WEST BIRMINGHAM
HOSPITALS NHS TRUST) wrote:

> Hi Jan,
>
> Thank you for the helpful reply but i was hoping you could dumb it down a bit for me. Is it possible for you to use the provided example code (below) as a template because I can follow this and it works when you copy and paste it into an ImageJ macro editor window. The code is from the ImageJ macro function page:
>
> https://imagej.nih.gov/ij/macros/examples/DialogWithHelp.txt
>
> I was hoping it would be a simple one-liner to add an image. Also, does the image have to be a url? I would preferably like to insert an image that has a file path location on the local computer. Is that possible?
>
> As you can probably tell, I'm not familiar with HTML scripting.
>
> Thanks for the help,
>
> Greg.
>
>
> =============================================================
> // This macro demonstrates how a macro can
> // display a dialog box with a "Help" button
> // that displays HTML formatted text.
>
>    html = "<html>"
>       +"<h2>HTML formatted help</h2>"
>       +"<font size=+1>
>       +"In ImageJ 1.46b or later, dialog boxes<br>"
>       +"can have a <b>Help</b> button that displays<br>"
>       +"<font color=red>HTML</font> formatted text.<br>"
>       +"</font>";
>    Dialog.create("Help");
>    Dialog.addHelp(html);
>    Dialog.show
> =============================================================
>
>
>
> __________________________________________
> Gregory James
> Clinical Scientist (Nuclear Medicine)
> Department of Physics and Nuclear Medicine
> City Hospital
> Dudley Road
> Birmingham
> B18 7QH
>
> 0121 507 4043
> ________________________________________
> From: Jan Eglinger <[hidden email]>
> Sent: 09 August 2018 09:20
> To: [hidden email]
> Subject: Re: HTML insert image
>
> Dear Greg,
>
> using script parameters [1], you can add an html label containing an
> <img> tag. For example, these lines in a script:
>
>       #@ String (label=" ", value="<html><img
> src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\"></html>",
> visibility=MESSAGE, persist=false) message1
>       #@ String (label=" ", value="<html>Some <b>formatted</b>
> message</html>", visibility=MESSAGE, persist=false) message2
>       #@ String (label="Some input parameter") input_text
>
> will create a dialog with image (screenshot attached).
>
> Cheers
> Jan
>
> [1]: https://imagej.net/Script_Parameters
>
>
> On 08.08.2018 15:29, Gregory James wrote:
>> Dear ImageJ community,
>>
>> I have spent enough time struggling so now it's time to ask the community...
>>
>> With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.
>>
>> Thanks,
>>
>> Greg.
>>
>> ===================================================================
>> // This macro demonstrates how a macro can
>> // display a dialog box with a "Help" button
>> // that displays HTML formatted text.
>>
>>     html = "<html>"
>>        +"<h2>HTML formatted help</h2>"
>>        +"<font size=+1>
>>        +"In ImageJ 1.46b or later, dialog boxes<br>"
>>        +"can have a <b>Help</b> button that displays<br>"
>>        +"<font color=red>HTML</font> formatted text.<br>"
>>        +"</font>";
>>     Dialog.create("Help");
>>     Dialog.addHelp(html);
>>     Dialog.show
>> ===================================================================
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
> ********************************************************************************************************************
>
> This message may contain confidential information. If you are not the intended recipient please inform the
> sender that you have received the message in error before deleting it.
> Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.
>
> NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.
>
> For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

Herbie
Good day Greg and Jan,

if you need a local path, then use e.g. a html-code line like

html = "<html>"
+ "<img src='file:///Users/myName/imagej_icon.png' alt='ImageJ Icon'
height='64' width='30'>";

I'm on Mac and the image "imagej_icon.png" is in the user directory
called "myName"

HTH

Herbie

::::::::::::::::::::::::::::::::::::::::::
Am 09.08.18 um 11:21 schrieb Jan Eglinger:

> Hi Greg,
>
> sorry, I thought you'd want to have the image in the main dialog. For
> the help button dialog, you can just add a line with an <img> tag to
> your html like this:
>
>    html = "<html>"
>       +"<h2>HTML formatted help</h2>"
>       +"<img
> src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\">"
>
>       +"<font size=+1>
>       +"In ImageJ 1.46b or later, dialog boxes<br>"
>       +"can have a <b>Help</b> button that displays<br>"
>       +"<font color=red>HTML</font> formatted text.<br>"
>       +"</font>";
>    Dialog.create("Help");
>    Dialog.addHelp(html);
>    Dialog.show
>
> I tried with a local path as well, but it didn't work for me, so you
> might be limited to URLs indeed.
>
> Regarding my previous example with script parameters, it is a complete
> runnable example, you can paste it in the script editor [1] and run it.
> But it won't work with plain ImageJ1, as script parameters are an IJ2
> feature.
>
> Cheers
> Jan
>
> [1]: https://imagej.net/Using_the_Script_Editor
>
>
> On 09.08.2018 10:52, JAMES, gregory (SANDWELL AND WEST BIRMINGHAM
> HOSPITALS NHS TRUST) wrote:
>> Hi Jan,
>>
>> Thank you for the helpful reply but i was hoping you could dumb it
>> down a bit for me. Is it possible for you to use the provided example
>> code (below) as a template because I can follow this and it works when
>> you copy and paste it into an ImageJ macro editor window. The code is
>> from the ImageJ macro function page:
>>
>> https://imagej.nih.gov/ij/macros/examples/DialogWithHelp.txt
>>
>> I was hoping it would be a simple one-liner to add an image. Also,
>> does the image have to be a url? I would preferably like to insert an
>> image that has a file path location on the local computer. Is that
>> possible?
>>
>> As you can probably tell, I'm not familiar with HTML scripting.
>>
>> Thanks for the help,
>>
>> Greg.
>>
>>
>> =============================================================
>> // This macro demonstrates how a macro can
>> // display a dialog box with a "Help" button
>> // that displays HTML formatted text.
>>
>>    html = "<html>"
>>       +"<h2>HTML formatted help</h2>"
>>       +"<font size=+1>
>>       +"In ImageJ 1.46b or later, dialog boxes<br>"
>>       +"can have a <b>Help</b> button that displays<br>"
>>       +"<font color=red>HTML</font> formatted text.<br>"
>>       +"</font>";
>>    Dialog.create("Help");
>>    Dialog.addHelp(html);
>>    Dialog.show
>> =============================================================
>>
>>
>>
>> __________________________________________
>> Gregory James
>> Clinical Scientist (Nuclear Medicine)
>> Department of Physics and Nuclear Medicine
>> City Hospital
>> Dudley Road
>> Birmingham
>> B18 7QH
>>
>> 0121 507 4043
>> ________________________________________
>> From: Jan Eglinger <[hidden email]>
>> Sent: 09 August 2018 09:20
>> To: [hidden email]
>> Subject: Re: HTML insert image
>>
>> Dear Greg,
>>
>> using script parameters [1], you can add an html label containing an
>> <img> tag. For example, these lines in a script:
>>
>>       #@ String (label=" ", value="<html><img
>> src=\"http://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/IA_Images/Fiji_logo_100x100.png\"></html>",
>>
>> visibility=MESSAGE, persist=false) message1
>>       #@ String (label=" ", value="<html>Some <b>formatted</b>
>> message</html>", visibility=MESSAGE, persist=false) message2
>>       #@ String (label="Some input parameter") input_text
>>
>> will create a dialog with image (screenshot attached).
>>
>> Cheers
>> Jan
>>
>> [1]: https://imagej.net/Script_Parameters
>>
>>
>> On 08.08.2018 15:29, Gregory James wrote:
>>> Dear ImageJ community,
>>>
>>> I have spent enough time struggling so now it's time to ask the
>>> community...
>>>
>>> With reference to the Dialog.addHelp(url) macro language command,
>>> does anyone know how to an image? The example code given (below) does
>>> not demonstrate this.
>>>
>>> Thanks,
>>>
>>> Greg.
>>>
>>> ===================================================================
>>> // This macro demonstrates how a macro can
>>> // display a dialog box with a "Help" button
>>> // that displays HTML formatted text.
>>>
>>>     html = "<html>"
>>>        +"<h2>HTML formatted help</h2>"
>>>        +"<font size=+1>
>>>        +"In ImageJ 1.46b or later, dialog boxes<br>"
>>>        +"can have a <b>Help</b> button that displays<br>"
>>>        +"<font color=red>HTML</font> formatted text.<br>"
>>>        +"</font>";
>>>     Dialog.create("Help");
>>>     Dialog.addHelp(html);
>>>     Dialog.show
>>> ===================================================================
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> ********************************************************************************************************************
>>
>>
>> This message may contain confidential information. If you are not the
>> intended recipient please inform the
>> sender that you have received the message in error before deleting it.
>> Please do not disclose, copy or distribute information in this e-mail
>> or take any action in relation to its contents. To do so is strictly
>> prohibited and may be unlawful. Thank you for your co-operation.
>>
>> NHSmail is the secure email and directory service available for all
>> NHS staff in England and Scotland. NHSmail is approved for exchanging
>> patient data and other sensitive information with NHSmail and other
>> accredited email services.
>>
>> For more information and to find out how you can switch,
>> https://portal.nhs.net/help/joiningnhsmail
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

Wayne Rasband-2
In reply to this post by JAMES, gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST)
> On Aug 8, 2018, at 9:29 AM, Gregory James <[hidden email]> wrote:
>
> Dear ImageJ community,
>
> I have spent enough time struggling so now it's time to ask the community...
>
> With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.

Here is an updated version of the HTML formatted help example that displays an image located in the ImageJ/images directory.

-wayne

  path = "file://"+getDirectory("imagej")+"images/clown.jpg";
  print(path);
  html = "<html>"
     +"<img src="+path+" alt=Icon width=160 height=100 >"
     +"<h2>HTML formatted help</h2>"
     +"<font size=+1>
     +"Dialog boxes can have a <b>Help</b> button<br>"
     +"that displays<font color=red>HTML</font> "
     +"formatted text.<br>"
     +"</font>";
  Dialog.create("Help");
  Dialog.addHelp(html);
  Dialog.show


>
> Thanks,
>
> Greg.
>
> ===================================================================
> // This macro demonstrates how a macro can
> // display a dialog box with a "Help" button
> // that displays HTML formatted text.
>
>  html = "<html>"
>     +"<h2>HTML formatted help</h2>"
>     +"<font size=+1>
>     +"In ImageJ 1.46b or later, dialog boxes<br>"
>     +"can have a <b>Help</b> button that displays<br>"
>     +"<font color=red>HTML</font> formatted text.<br>"
>     +"</font>";
>  Dialog.create("Help");
>  Dialog.addHelp(html);
>  Dialog.show
> ===================================================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: HTML insert image

JAMES,
              gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST)
Thank you Wayne, Herbie and Jan.

That works wonderfully!

Hopefully, people will find this thread useful in the future when searching the mailing list archives.

Thanks again,

I'm very pleased,

Greg.

__________________________________________
Gregory James
Clinical Scientist (Nuclear Medicine)
Department of Physics and Nuclear Medicine
City Hospital
Dudley Road
Birmingham
B18 7QH

0121 507 4043
________________________________________
From: Wayne Rasband <[hidden email]>
Sent: 09 August 2018 14:00
To: [hidden email]
Subject: Re: HTML insert image

> On Aug 8, 2018, at 9:29 AM, Gregory James <[hidden email]> wrote:
>
> Dear ImageJ community,
>
> I have spent enough time struggling so now it's time to ask the community...
>
> With reference to the Dialog.addHelp(url) macro language command, does anyone know how to an image? The example code given (below) does not demonstrate this.

Here is an updated version of the HTML formatted help example that displays an image located in the ImageJ/images directory.

-wayne

  path = "file://"+getDirectory("imagej")+"images/clown.jpg";
  print(path);
  html = "<html>"
     +"<img src="+path+" alt=Icon width=160 height=100 >"
     +"<h2>HTML formatted help</h2>"
     +"<font size=+1>
     +"Dialog boxes can have a <b>Help</b> button<br>"
     +"that displays<font color=red>HTML</font> "
     +"formatted text.<br>"
     +"</font>";
  Dialog.create("Help");
  Dialog.addHelp(html);
  Dialog.show


>
> Thanks,
>
> Greg.
>
> ===================================================================
> // This macro demonstrates how a macro can
> // display a dialog box with a "Help" button
> // that displays HTML formatted text.
>
>  html = "<html>"
>     +"<h2>HTML formatted help</h2>"
>     +"<font size=+1>
>     +"In ImageJ 1.46b or later, dialog boxes<br>"
>     +"can have a <b>Help</b> button that displays<br>"
>     +"<font color=red>HTML</font> formatted text.<br>"
>     +"</font>";
>  Dialog.create("Help");
>  Dialog.addHelp(html);
>  Dialog.show
> ===================================================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html


********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html