![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Remember that you should not post code on this page! |
| Is JES closing itself when it runs your program? It could be because you are trying to create a really big picture. For example, makeEmptyPicture(10000000, 10000000) tries to create a picture 10 million pixels wide and high. Your computer can't handle a picture that size, so JES panics and quits. So check your code to make sure your math is right and you're not trying to create a super-big picture by mistake. |
| Ok, corrected. Thanks for the input. Angela Liang |
| It's similiar but not quite. In hw4, you set the height tag to make the picture smaller but the browser still downloads the large picture in order to scale it. In this assignment, you need to actually scale the picture so the browser spends less time downloading the picture (since it's smaller). Therefore, you do not set the height tag in this assignment. Angela Liang |
| The take home exams are graded just like any other assignment. You get credit for what you do. Like, in general, there will be some credit for creating an html file, and some more for generating images, and still more for adding the images, and links to the page, etc. The only difference, however, is that if you do not provide the "I did not give or receive help on this asignment" statement, you get an automatic 0. Kelly Lyons |
| There shouldn't be anything wrong with the function. If there was, it would/should give you an error. If it's crashing JES, then that's odd, and could be a problem with your computer, or your JES just as easily as with the program. You should IM a TA or professor to get more specific help with this problem. Kelly Lyons |
| int() is a form of rounding, so long as it is used properly. Kelly Lyons |
| Yes Kelly Lyons |
| index.html Kelly Lyons |
| Since pixels are only counted in ingegers, a ratio which is off by something that rounds to 0 is effectively correct in appearance, so yes this should be fine. Kelly Lyons |
| Generally off by one errors are caused in for loops where the increment goes one too many or one too few. But there could be other reasons. I suggest you trace the code on paper. It should help you find the error. Kelly Lyons |
| Remember when you make an empty picture, it is created as a black canvas. Could it be that you are making a picture larger than picture you are copying into it, thus leaving black on some edges? Kelly Lyons |
| The reduced images is created by your scaling function. So if it doesn't look right, then I would check your scaling function to see if it is working properly. Kelly Lyons |
| Reread the assignment – we always tell you what inputs there are. Mark Guzdial |
| Page 54 in the book. Mark Guzdial |
| Not advice – we can only answer questions about topics in the class (not about your exam or your assignment) and clarifications about the assignment. Mark Guzdial |
| Look on the syllabus Angela Liang |
| Open up the zipped file and then look under the "File" menu. There should be an option to "Extract all files". Or, you can just cut certain files out of the zipped folder and paste them elsewhere on your computer if you want. As for the program only working for barbara, make sure that you haven't hardcoded a certain picture anywhere, or that your other files are also ".jpg" files. Summer McWilliams |
| Yes. In general, files don't have a height. Pictures do. Mark Guzdial |
| pre means before, so tn_filename.jpg would be correct Kelly Lyons |
| To run it you can enter ANY directory, not just mediasources, and yes any number (bearing in mind that the number is representative of a max edge pixel size, so things like -1 wouldn't make sense) Kelly Lyons |
| Yes, but I don't know where off the top of my head. It turned up on the midterm 1 review, so I'd look previous to midterm 1 material. Also, the sample function given on the exam is worth looking at seeing as it does exactly what you need it to do Kelly Lyons |
| If 200 is the maxedge, then the picture should not end up being 201. There is some error in your scaling function I would assume. You should check your code and see where it does this, and fix it. Off by one errors are generally easy to fix and are generally created in for loops. Kelly Lyons |
| You can't extract zip files with JES. You need Winzip to do this. If you find the zip folder on your computer (and you have winzip on your computer) you can right click on the folder and find an "extract all files" option in the menu. You would want to click that. If you are still confused, try going to office hours or IMing a TA Kelly Lyons |
| The directory is inputted, so you should use that, and not need a getMediaPath command. Kelly Lyons |
| 100 is also just an example. If your maxedge input was, say, 200, then you wouldn't need to create a thumbnail for pictures who's largest dimension was less than 200. Kelly Lyons |
If the largest dimension is less than or equal to 100 then no thumbnail needs to be created but a copy of the original image can be made and named as per above (i.e. tn_originalname.jpg). This means you can either copy the original (small) file to tn_orginalname.jpg or you can reference the original filename directly from your thumbnails page. Missing Page |
| 100 is also just an example. If your maxedge input was, say, 200, then you wouldn't need to create a thumbnail for pictures who's largest dimension was less than 200. Kelly Lyons |
| I find that JES closes itself if you ask it to do something that requires GOBS more memory than the computer has. Maybe you need to run one of the lomem versions of JES, or try it on a computer with more memory, or close some of your other applications. Mark Guzdial |
| Just two inputs. Directory and Maxedge Greg Leo |
| JES will do that if you try to make a really, really big picture. It runs out of memory and java fails | Bill Leahy |
| The supplied code only scales an image by a input factor. You will have to figure out how to modify the code to scale to a maxedge, and then apply it. Greg Leo |
| Remember that for loops take a long time to run. Check and see if you've got a lot of those running inside eachother. Also, what size directory are you running it on? If it is very large, then it might take a long time to run. Try using a directory of one picture or two to see if that is the problem. Kelly Lyons |
| That's okay...it's a JES thing | Bill Leahy |
| Try printing out the size of the picture that JES is trying to create | Bill Leahy |
| max edge can be any number >=1. Make sure it works for any input!! Kelly Lyons |
| Save it on a disk, or email it to yourself are the easiest ways to do that. Kelly Lyons |
| I'm a little confused by what you are asking. You don't want decimal places becuase pixels are all integers. Kelly Lyons |
| You can try running it in expert mode. That sometimes gives you a more specific error. Also, if the syntax error gives you a line number, check the line above. Also check that all your parentheses are matched correctly, colons are at the end of all def, for and if statements, and things are indented correctly. Those are the most common syntax errors. Kelly Lyons |
| When we grade your assignment, if it doesn't run, then the most points you will get is a 60. We'll go through and run parts of the code to see what does work, add up all the points you got and multiply it by .6 This of course means that if you can turn in code that runs, even if it doesn't do everything, you will almost always get a better grade than if you turn in code that does not run. Kelly Lyons |
| Just 200 Remember that maxedge represents the number of pixels in the edge, and pixels are always integers. Kelly Lyons |
| Ask your TA to get a copy of your homework 4 for you. If you have a syntax error that you can't figure out, start commenting-out lines or cutting them out (paste them into Word, then paste them back later) to figure out where the error is (see page 226). If your program doesn't run, you can't get more than half the credit – you're best off turning in something that runs, even if incomplete. Mark Guzdial |
| YES! Kelly Lyons |
| Apparently this is a JES error, and so it is ok if your picture is off by 1 pixel like this. Kelly Lyons |
| You must save the picture in order to show it. The media instance means that your function returns something that you do not save. You should try running picture = function() and then do the show(picture) Kelly Lyons |
| To save something to a directory, remember that there is a writePictureTo function in JES Kelly Lyons |
| You are correct that there is an error in copying the pixels. Check the code where you do the pixel copying, and see what's wrong with it. Kelly Lyons |
| Try multiplying by 1. (notice the decimal point) in all of your calculations Kelly Lyons |
| That is fine, but remember that 100 is just an example. maxedge could be any number and you have to account for this. Kelly Lyons |
| No idea. You should be able to define a variable in terms of another variable provided the other variable exists in the function. You probably have an error somewhere. Kelly Lyons |
| The function float takes in any number, and returns the floating point version of that number. float(100) gives you 100.0. Mark Guzdial |
| In HW4, how did you link a picture to another picture? Check the HTML, and see what the picture.jpg really means. Kelly Lyons |
| Review your home work 4 code Greg Leo |
| The 1/3 will return 0, and 1.0*0 is 0.1 How about 1.0/3.0 and then try it. Kelly Lyons |
| Many things could cause this. Trace your code. Kelly Lyons |
| It depends. What is it that it returns? Are you treating it as the same thing in your other function? i.e. you can't return a picture and then treat it as a file. See what the error is. It should be helpful in this instance. Kelly Lyons |
| It's probably got something to do with the formatting of firefox. If it works in IE, then you should be fine. Most TAs will be running it in IE, and just in case, in your notes to TA, let them know not to run it in Firefox. Kelly Lyons |
| The media.Picture instance means it returns a picture. If it's not displaying pictures, then look at the source from the html page, and see what it has in it. Kelly Lyons |
| The little red x means it can't find the picture. Check the html produced from your function. Kelly Lyons |
| Congrats on getting it to work.... Kelly Lyons |
| You can use an if statement within an if statement, you probably did this in HW4. Greg Leo |
| That's HTML. HTML won't load in Python. Do you have it inside a string? It should work in that case Kelly Lyons |
| JES assumes integers if none of your inputs are decimals. Try making one of your inputs a decimal, i.e. 1.0 Kelly Lyons |
| Check your parentheses. Kelly Lyons |
| outerFunction(innerFunction(input)) Missing Page |
| Sometimes "spacing" errors in JES are caused by syntax errors. E.g. the spacing may look correct, but there may be missing punctuation somewhere (missing colons, unmatched parens, unmatched quotes...). Missing Page |
| So, you are making all of the thumbnails and then trying to write the html? Perhaps you could do both more or less at the same time? | Bill Leahy |
| Yes | Bill Leahy |
| Hard to say based on the information you have supplied but it might be an error in the logic you are using to figure out how to scale the pictures. You might try having the program print out the original size of the picture and what you want to make the size of the thumbnails and see if that all makes sense. | Bill Leahy |
| The scale function we gave you creates a new picture. Why do you want to copy and rename it? Why not just save it under whatever name you want? | Bill Leahy |
| You open the file, write to the file and then close the file. If the file is empty check your program logic and make sure those statements are actually being executed (i.e. you could add in some print statements just to see what is happening but be sure to take them out later! | Bill Leahy |
| Don't give up. Kelly Lyons |
| Are you passing in a picture and a number into scaleImage? | Bill Leahy |
| I don't understand your question? | Bill Leahy |
| It means you are making a very large picture, and alocating a lot of memory. Check your code (before you run it) and see where you are making pictures. Are you making very large pictures accidentally? |
| Find where you are writing the ... portion. One of the ... references needs to be changed. Kelly Lyons |
| You need to define the variable within the function you are using. If you define it within a loop, then it's not recognized outside the loop. Kelly Lyons |
| If JES closes out when you're running, check what you're passing as input to makeEmptyPicture or makeEmptySound. The numbers are too big, so the picture or sound you're creating is so enormous that all of memory is used up and Java crashes. Mark Guzdial |
| No, the TAs will not use setMediaPath. Remember that the function takes in a directory. Use this instead of the media path. Kelly Lyons |
>>> thumber("C:\JES\MediaSources\mediaout", 100)
<media.Picture instance at 11032120>