cmpt 165 cmpt 165
play

CMPT 165 CMPT 165 INTRODUCTION TO THE INTERNET INTRODUCTION TO THE - PowerPoint PPT Presentation

CMPT 165 CMPT 165 INTRODUCTION TO THE INTERNET INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB AND THE WORLD WIDE WEB By Hassan S. Shavarani UNIT5: GRAPHICS UNIT5: GRAPHICS 1 TOPICS TOPICS 1. Using Images on Web Pages 2. Image


  1. CMPT 165 CMPT 165 INTRODUCTION TO THE INTERNET INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB AND THE WORLD WIDE WEB By Hassan S. Shavarani UNIT5: GRAPHICS UNIT5: GRAPHICS 1

  2. TOPICS TOPICS 1. Using Images on Web Pages 2. Image Formats 3. Bitmap Image Formats 2

  3. THE THE <img> <img> TAG EXAMPLE AGAIN TAG EXAMPLE AGAIN <p> <img src="http://example.com/vacation.jpg" alt="My vacation" /> </p> <br/> <p> <img src="pics/vacation.jpg" alt="My vacation" /> </p> * the HTML reference for <img> Tag 3

  4. "alt" , , "width" "width" , AND , AND "height" "height" ATTRIBUTES ATTRIBUTES "alt" "alt" is a necessity if the image actually conveys any content so if the image actually has some meaning then alt should be a text-equivalent of that meaning "width" and "height" used to give the browser a hint about how big the image is; how much space it will take up on the page this way the browser will quickly fill the page with an empty rectangle where the image goes both values are given in pixels 4

  5. IMPORTANT HINT ABOUT IMPORTANT HINT ABOUT "width" "width" AND AND "height" "height" you should not use width and height to change the size of an image if you want the image to be a different size, then it should be scaled in an image editor 5

  6. when adding images to your web pages it can be very easy to create pages that take an annoying amount of time to load for a page containing 5 images of size 2MB each ~ 2-4 seconds on computer >8 seconds on mobile (with a descent connection) 6

  7. THE PROBLEM THE PROBLEM if the total amount of data that must be downloaded is too large (e.g. 5 images of size 2MB each) the page will take much longer to be loaded 7

  8. THE SOLUTION THE SOLUTION scale-down the images! 8

  9. when creating pages, keep the total size of files (HTML + CSS + images + JavaScript + …) less than 1MB 9

  10. IMAGE FORMATS IMAGE FORMATS different ways to represent images in a computer (and on web pages) 10

  11. BITMAP AND VECTOR IMAGES BITMAP AND VECTOR IMAGES Vector Image represented as a collection of shapes: lines, curves, circles, squares, etc. (left red circle) Bitmap Image represented as a grid of pixels each of which is given a particular colour (right red circle) 11

  12. BITMAP AND VECTOR IMAGES (ZOOMED EXAMPLE) BITMAP AND VECTOR IMAGES (ZOOMED EXAMPLE) vector description of the left image: a circle with a black outline and red fill, with centre at (...px, ...px) and radius of ...px bitmap description of the right image: a collection of coloured square pixels 12

  13. VECTOR IMAGE FORMAT ADVANTAGES VECTOR IMAGE FORMAT ADVANTAGES Shorter download time Vector Image Example ~ 2KB Bitmap Image Example ~ 11KB More smooth scaling when being printed, or on high-resolution displays * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/phone-icon.svg 13

  14. VECTOR IMAGE FORMAT DISADVANTAGES VECTOR IMAGE FORMAT DISADVANTAGES not all images make sense as a vector image! * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/phone-pic.jpg 14

  15. IMAGE VECTORIZATION IMAGE VECTORIZATION an automatic attempt to turn the image into vector shapes not all the images can be easily converted to the vector format In such cases the image size drastically increases! (here 12KBs to 54KBs) * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/phone-pic-traced.svg 15

  16. SCALABLE VECTOR GRAPHICS (.SVG) FORMAT SCALABLE VECTOR GRAPHICS (.SVG) FORMAT the only vector image format that is relevant to the web; we will work more with SVG later in the course 16

  17. BITMAP IMAGE EXAMPLE BITMAP IMAGE EXAMPLE as mentioned before a bitmap image is made up of a grid of pixels * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/compression2.png 17

  18. BITMAP IMAGE CONTENTS - BASIC IDEA BITMAP IMAGE CONTENTS - BASIC IDEA row 1: white pixel, white pixel, white pixel, ... row 2: dark grey pixel, black pixel, black pixel, ... ... * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/compression1.png 18

  19. WINDOWS BITMAP (.BMP) FORMAT WINDOWS BITMAP (.BMP) FORMAT simply record the color of each pixel with no compression! the BMP format is not used on the web because it produces very large (uncompressed) files 19

  20. PORTABLE NETWORK GRAPHICS (.PNG) FORMAT PORTABLE NETWORK GRAPHICS (.PNG) FORMAT same idea as windows bitmap but with image compression! produces smaller files with no loss in quality therefore is common on the web the image taking 526KBs using .BMP can take around 36KBs using .PNG (24-bit palette) without loss of information 20

  21. BITMAP IMAGE FORMAT BITMAP IMAGE FORMAT DIFFERENT PALETTES (COLOR DEPTHS) DIFFERENT PALETTES (COLOR DEPTHS) we can use different palettes for storing the color of each square in a bitmap image; the palette is stored along with the pixel data in the file itself 24-bit color (true colour) palette: 16,777,216 different colors 8-bit color palette: 256 different colors generally, n-bit color palette: 2n different colors 21

  22. COLOR DEPTH CHOICE EXAMPLE [8-BIT VS. 3-BIT] COLOR DEPTH CHOICE EXAMPLE [8-BIT VS. 3-BIT] * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/depth.png 22

  23. COLOR DEPTH CHOICE EXAMPLE [8-BIT VS. 3-BIT] COLOR DEPTH CHOICE EXAMPLE [8-BIT VS. 3-BIT] * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/phone-pic-[8/3].png 23

  24. IMAGE COMPRESSION TYPES IMAGE COMPRESSION TYPES lossless compression: e.g. PNG format lossy compression: e.g. JPEG format 24

  25. JPEG IMAGE FORMAT JPEG IMAGE FORMAT designed specifically for photographs, so excellent for storing photographs, but not good at other types of images has a quality parameter (1–100) which can be used to trade off file size and image quality * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/vancouver-docks.jpg (equal PNG file size 670KB) 25

  26. JPEG IMAGE FORMAT JPEG IMAGE FORMAT DIFFERENT QUALITY PARAMETER VALUES DIFFERENT QUALITY PARAMETER VALUES Original Image JPEG quality: 90 File size: 510 KB JPEG quality: 70 File size: 174 KB JPEG quality: 50 File size: 122 KB JPEG quality: 30 File size: 85 KB JPEG quality: 10 File size: 37 KB * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/jpeg.svg 26

  27. JPEG IMAGE FORMAT - TEXT EXAMPLE JPEG IMAGE FORMAT - TEXT EXAMPLE * image from http://www.cs.sfu.ca/CourseCentral/165/common/study-guide/figures/compression4.png 27

  28. Any Questions? 28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend