📜  org-mode embedd image (1)

📅  最后修改于: 2023-12-03 15:03:25.305000             🧑  作者: Mango

Org-mode Embed Image

Org-mode is a powerful markup language used in Emacs that can be used for writing notes, keeping a to-do list, and authoring documents. One useful feature in Org-mode is the ability to embed images directly into your documents.

To embed an image in Org-mode, you simply need to insert an image link to the file path of the image on your computer. Here is an example:

[[file:/path/to/image.jpg]]

You can also change the size of the image by adding attributes to the image link. For example, to make the image 50% of its original size, you can use the following:

[[file:/path/to/image.jpg][width=50%]]

In addition to embedding images from your computer, you can also embed images from the internet using a URL link. Here is an example:

[[https://example.com/image.jpg]]

To resize an internet image, you can use the same method by adding attributes to the image link.

Org-mode also allows you to preview images directly in the document. To do this, you can use the image-preview package. Here is an example:

#+ATTR_ORG: :width 200
[[file:/path/to/image.jpg]]

#+BEGIN_SRC emacs-lisp
(setq image-preview-max-height 400)
#+END_SRC

This code block will set the width of the image to 200 pixels and the maximum height of the preview to 400 pixels. To enable the image preview, you can use the following command:

M-x org-toggle-inline-images

This will show the image preview directly in the document.

Overall, Org-mode provides a convenient way to embed images directly in your documents without the need for external image viewers or editors.

Sample code in markdown:

# Org-mode Embed Image

Org-mode is a powerful markup language used in Emacs that can be used for writing notes, keeping a to-do list, and authoring documents. One useful feature in Org-mode is the ability to embed images directly into your documents.

To embed an image in Org-mode, you simply need to insert an image link to the file path of the image on your computer. Here is an example:

[[file:/path/to/image.jpg]]


You can also change the size of the image by adding attributes to the image link. For example, to make the image 50% of its original size, you can use the following:

[[file:/path/to/image.jpg][width=50%]]


In addition to embedding images from your computer, you can also embed images from the internet using a URL link. Here is an example:

[[https://example.com/image.jpg]]


To resize an internet image, you can use the same method by adding attributes to the image link.

Org-mode also allows you to preview images directly in the document. To do this, you can use the `image-preview` package. Here is an example:

#+ATTR_ORG: :width 200 [[file:/path/to/image.jpg]]

#+BEGIN_SRC emacs-lisp (setq image-preview-max-height 400) #+END_SRC


This code block will set the width of the image to 200 pixels and the maximum height of the preview to 400 pixels. To enable the image preview, you can use the following command:

M-x org-toggle-inline-images


This will show the image preview directly in the document.

Overall, Org-mode provides a convenient way to embed images directly in your documents without the need for external image viewers or editors.