Is there any way to save multiple images in one html file?
I am using figure’s image_url to display the images.
I’ve kept all the instances of figure to display each image, and saved them, but
However, the last image is only saved in the html, and the other images are not displayed.
For the record, here is the source code I wrote.
from bokeh.plotting import figure, show, output_file
from bokeh.io import output_notebook, save
from skimage import io
from bokeh.models import LinearAxis, Range1d
from bokeh.layouts import column
import numpy as np
import glob
output_notebook()
lst_imgs = glob.glob(r".\imgs\*.png")
plts = []
for img_path in lst_imgs:
image = io.imread(img_path)
h, w, c = image.shape
x_min = 0; x_max = w
y_min = 0; y_max = h
PLOT_SIZE_OPTIONS = \
dict(
x_axis_location='above',
x_range=(x_min, x_max),
y_range=(y_max, y_min),
plot_width=x_max,
plot_height=y_max
)
PLOT_OPTIONS = dict(sizing_mode='scale_width', id="plt_fig")
ASPECT_OPTIONS = dict(match_aspect=True, aspect_scale=1.0)
plt = figure(**PLOT_OPTIONS, **ASPECT_OPTIONS, **PLOT_SIZE_OPTIONS)
print(img_path)
plt.image_url(url=[img_path], x=x_min, y=y_min, w=x_max, h=y_max)
plts.append(plt)
# show(plt)
output_file("sample.html")
save(plts)
# show(column(*plts))
Please let me know if there is a better way.
Thank you in advance.