Streamlit - How to show .tif images (possibly large size) in Streamlit using st.image? - tiff

I am trying to visualize high resolution *.tif images using streamlit. I tried using both a url to the image and the downloaded image. All I get is a "0" similar to a st.write("0").
What I tried to do:
import streamlit as st
st.image("http://www.bmsc.washington.edu/raster3d/examples/density.tiff")

You can use the pillow library.
import streamlit as st
from PIL import Image
fn = 'f:/downloads/density.tiff'
image = Image.open(fn)
st.image(image)
Output

Related

Getting Image through HTML and using Python Code

I am trying to make a website that gets the user image and uses
facelandmark code(python) to tell the user about user's face shape and etc.
How can I get the imange through html and use the image file in python code and show the result to the user again? Is using django the only way? I have tried to study django in many ways and most of the stuffs I found were not directly helping on my planning website. Thank you for reading
You can use this code to directly embed the image in your HTML: Python 3
import base64
data_uri = base64.b64encode(open('Graph.png', 'rb').read()).decode('utf-8')
img_tag = '<img src="data:image/png;base64,{0}">'.format(data_uri)
print(img_tag)

Importing Font Awesome icons that have a dash ("-") in their name

I am using React.js to make a portfolio website. I decided to go with Font Awesome icons since I love the look of them. However when I go to import any icon that has that dash in the name, I can't figure out how to import it. Here's my code so far (for importing):
import "font-awesome/css/font-awesome.min.css";
import { FontAwesomeIcon } from "#fortawesome/react-fontawesome";
// All these are single name icons
import {faPython} from "#fortawesome/free-brands-svg-icons/faPython";
import {faJs} from "#fortawesome/free-brands-svg-icons/faJs";
import {faReact} from "#fortawesome/free-brands-svg-icons/faReact";
import {faCuttlefish} from "#fortawesome/free-brands-svg-icons/faCuttlefish";
// This one is named "rectangle-code"
import {faRectangleCode} from "#fortawesome/free-solid-svg-icons/faRectangleCode";
I get this error:
I can't import it using dashes in the name, so how do I import this icon without any errors?
EDIT: Click here to view the icon on Font Awesome's website
Here's the problem!
You're attempting to use a pro icon - it doesn't exist in the free icon packs.
(Edit: for future reference, a good way to debug import problems like this is to cd inside the #fortawesome directory in your terminal, and then use something like https://github.com/junegunn/fzf to look for the file you're looking for. That's what I did before realizing the icon doesn't exist in the free version.)

Python3 Download Image from an Webpage

how can I download the image from this URL: https://thispersondoesnotexist.com/
I know it hasn't some image-url but I hope to get some images from there.
My idea is to write a code to get more images from this URL.
Duplicate: Loop through webpages and download all images
Python 2
Using urllib.urlretrieve
import urllib
urllib.urlretrieve("http://www.gunnerkrigg.com//comics/00000001.jpg", "00000001.jpg")
Python 3
Using urllib.request.urlretrieve (part of Python 3's legacy interface, works exactly the same)
import urllib.request
urllib.request.urlretrieve("http://www.gunnerkrigg.com//comics/00000001.jpg", "00000001.jpg")

Trying to get the html on an open page

I am trying to make a bot that can play Cookie Clicker. I have successfully opened the website using the webbrowser module. When I use the developer tool to see the html I can see the information I want to obtain, such as how much money I have, how expensive items are ect. But when I try to get that information using the requests and beautifulsoup it instead gets the html of a new window. How can I make it so that I get the html of the already opened tab?
import webbrowser
webbrowser.open('https://orteil.dashnet.org/cookieclicker/')
from bs4 import BeautifulSoup
import requests
def scrape():
html = requests.get('https://orteil.dashnet.org/cookieclicker/')
print(html)
scrape()
You can try to do this:
body_element = html.find_element_by_xpath("//body")
body_content = body_element.get_attribute("innerHTML")
print(body_content)

missing HTML information when using requests.get

I am trying to scrape surfline.com using python3 with beautiful soup and requests. I am using this bit of code. Additionally I am using spyder 3.7. Also I am fairly new to webscraping.
import requests
from bs4 import BeautifulSoup
url = 'https://www.surfline.com/surf-report/salt-creek/5842041f4e65fad6a770882e'
r = requests.get(url)
html_soup = BeautifulSoup(r.text,'html.parser')
print(html_soup.prettify())
The goal is to scrape the surf height for each day. Using inspect I found the HTML section that contains the wave height. screen shot of surfline website & HTML . I run the code and it prints out the HMTL of the website. When I do ctrl find to look for the section I want to scrape it is not there. My question is why is it not being printed out and how do I fix it. I am aware that some website use java to load data onto website, is that the case here.
Thank you for any help you can provide.