![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| The gallery.html is an html page generated using JES. -poof #10 |
| The latter. Hardcoded image paths will result in a 0. -Blake O'Hare |
| No, don't use an absolute URL. Just use the filename by itself because this HTML file will be written to the same folder as your images. -Blake O'Hare |
| getWidth(pic), getHeight(pic) -Blake O'Hare |
| In the end, in your HTML file, you can just say the name of the image, but when accessing your pictures in JES to use them and write them into your HTML... you will do something with the dir. Liz Helms |
| Remember, in your HTML file, you can only use just the image name (ie. src="pic.jpg") if the picture is in the same folder as the webpage.-poof #10 |
| Checking for only JPEG is ok. Include .png or .gif if you feel extra motivated. Ignore .bmp. Always. If you're generating smaller thumbnails for extra credit, then JES can only recognized JPEG and PNG formats. -Blake O'Hare |
| Any that will benefit you when writing your code. You make them and write them yourself. I'd suggest something that you'll either (a) use multiple times or (b) will clean up your code and help you to debug. Amanda Bennett |
| This particular HW is kind of hard to abstract out into separate functions, so if you want to be cheap (which is fine in my book since if you can figure out how to make your code optimally readable and efficient in one function, then why should you obfuscate it?) just make your main function have 1 line in it. A line that passes the directory to another function you write, which does all the work. -Blake O'Hare |
| Update: my above comment was a lame hack, so I slashed the 2-functions thing from the requirements. -Blake O'Hare |
| Yes. Just download the JES source and run it as a java app. -Blake O'Hare |
| getHeight(pic) gives you an int. Converting it to an int does nothing. I think what you're trying to do is turn it into a string which would be done with str. If the page.write line keeps giving you trouble, then put a return file right before that and see what your function spits out. If it's something that isn't in quotes, then that's the problem. -Blake O'Hare |
| You could define a variable and each time you go through the for loop add one to it.... Albert d'Heurle |
| The method .lower() makes a string all lower case. -Albert d'Heurle |
| Nope. Check the homework page to see how we will grade. -Albert d'Heurle |
| If we see a doctype, we'll be checking it for validation. -Blake O'Hare |
| That works too. -Blake O'Hare |
| HTML standards and interpretation is defined for 100% correct HTML. If you leave off a closing tag or quote somewhere where it doesn't expect, different browsers will handle it differently. Maybe Firefox will render the broken HTML while IE doesn't display anything or vice-versa. Double check the HTML code that was output by your program with notepad. -Blake O'Hare |
| Use at least the same one you used for Lab 3. -Blake O'Hare |
| You know how to find the length of a string. You also know how to open a file and extract its contents. -Blake O'Hare |
| The homework says to give size in MEGABYTES (that means you're looking for the number of bytes) Amanda Bennett |
| The only thing you need to turn in is your .py file. -poof #10 |
<table>opens the table tag <tr>opens a new row for the table <td>this opens a new column, and what you type in here is what will show up in the table </td>closes the column </tr>closes the row </table>closes the table...This should all be review from your table on your webpage...
<table border="1"><tr><td>This</td></tr><tr><td>is</td></tr><tr><td>an</td></tr><tr><td>example</td></tr></table>Liz Helms |
code = code + "<h3> Total .JPG Files: " + value + "</h3></body></html>"
| try str(value) and see how that works. Amanda Bennett |
| That worked! Thanks- |
| You do know the name of the directory. A function that we covered in class will give you a list of all the files in a directory, so you can use that and loop through the resulting list, knowing that each item of the list is the name of a file in the directory. Remember that you want to ignore those files whose extension indicates that they are not pictures. Colin Potts |
| Just the program. Your function should work with any folder of pictures. Liz Helms |
| Remember that really you are making one big string, so make sure you are adding things together correctly. Also try to remember the str() function and what it does, that should get rid of your getHeight and getWidth stuff... Liz Helms |
| Its hard to tell why its doing this without seeing your code. I would recommend visiting a TA at office hours Liz Helms |
| Yes, it makes sense. When using os.listdir(), JES does read spaces and returns that as a string. Why do you think that the file is just being called "camera" instead of "camera 001.jpg"? If you're trying to use a variable name with spaces, you can't, but since everything you're working with is strings (for the most part), spaces shouldn't be a problem. Amanda Bennett |
| In class today, we will be going over three examples of generating HTML from within a program. One of them creates thumbnails in a page. Although it doesn't put them in a table, like the homework, you should find this example useful. (It's in the slides, by the way, so you don't even need to wait until this afternoon to look at the example.) If your question about the cells adjusting themselves to the images refers to the size of the cells, don't worry. You'll find that the browser kindly scales the thumbnail image to the size you require. It doesn't matter what the sizes of the original images are. If you are asking instead about how many cells there should be (because there can be any number of image files in the directory), think about how you would generate cells from within a for loop.... Colin Potts |
| A clarification: In the above reply and in class today, I used the term 'thumbnail' in its Photoshop sense of a small depiction of a larger image. In that sense, any small scaled version of an image qualifies as a thumbnail. The extra credit part of the homework uses the term 'thumbnail' to refer to additional stored versions of the images that are used for the web page you are creating. If the user clicks on such a thumbnail version, then (and only then) the big image is loaded. The reason for needing true thumbnail (small) versions of big images is that you don't want to have to load lots of big images onto a page from a remote website, even though the big images would appear appropriately scaled by the browser: bigger images take longer to download than smaller ones. |
| You could upload it to your prism webspace (making sure not to overwrite your main page) but you don't have to upload to validate. validator.w3.org allows you to validate files on your computer. -Blake O'Hare |
| Opening in 'wt' creates a file if it does not exist. -Blake O'Hare |
| The function dir takes in a module name and returns all functions in it. Fun fact: if you call dir with no inputs, then it will list all imported locals. -Blake O'Hare |
| Does os.listdir(dir) look familiar? Liz Helms |
| Yes. And so does 'rt' and 'r'. -Blake O'Hare |
| Its hard to tell without looking at your code. Liz Helms |
| There is not a function that will do it for you. Unless you write one yourself. Think about how you'd count anything using a for loop...Amanda Bennett |
| That is quite odd. If all else fails, email it to your TA to prove it was done. -Blake O'Hare |
| It's because you're saying height="100" and the quotes in that are getting confused with the quotes delimiting the string. Always use single quotes when you're putting HTML in strings so that the actual double quotes within the HTML doesn't conflict. -Blake O'Hare |
In your img src tag, put height = "size" example: <img src="file.jpg" height="100"/>Liz Helms |
| You have to make sure to make your file into a picture in JES, otherwise getWidth and getHeight wont work on a non-picture object. Liz Helms |