Skip to the content.

imgies adn vase64

pluh

📌 Popcorn Hack

Question:
Which format would you use for an image with a transparent background that needs to stay sharp on any screen?

Answer:
You would use PNG format because it supports transparent backgrounds and keeps images sharp without losing quality.

🍿 Popcorn Hack

Question:
Turn to a partner and discuss: What do you think could be one downside of Base64 in the real world?

Answer:
Base64 encoding increases the size of files by about 33%, which can lead to slower load times and higher bandwidth usage.

💻 Homework Hack

Instructions:
In your notebook, explain the following, along with one application to your work:


1. What is a hex color code? What are some examples?

Answer:
A hex color code is a 6-digit combination of numbers and letters used in HTML, CSS, and design tools to represent colors.
Each pair of digits represents red, green, and blue values in hexadecimal (base 16).

Examples:

  • #FF0000 → Red
  • #00FF00 → Green
  • #0000FF → Blue

2. What is Base64 and how is it used with images?

Answer:
Base64 is a way to encode binary data (like images) into a text format using ASCII characters.
It allows embedding images directly into HTML or CSS files using a data: URL instead of linking to an external file.


3. Why might you use Base64 instead of a regular image file?

Answer:
Base64 is useful when you want to reduce HTTP requests, such as in emails or small websites.
It helps avoid broken links by keeping the image embedded directly in the code.


4. Insert an image into your Jupyter notebook and explain how it’s stored and displayed.

from IPython.display import Image
# Use a relative path to the image or an absolute path that exists on your system
Image(filename='../../../images/notebooks/Screenshot 2024-08-07 150835.png')

png

Explanation:

  • This code uses the Image function from the IPython.display module to show an image inside a Jupyter notebook.
  • The image is loaded from a local file path, which means the notebook is displaying the image by referencing the file directly.
  • It is not embedded in the notebook itself, and the image will only appear if the file exists in the specified location.
  • This method is efficient and keeps the notebook file size smaller than using Base64.