This are some exercises for my exam. Need some help ASAP. Program for 9 or 10 points would be the best, because I only need that for exam.


6 points: Write a program that reads a file .picasa.ini and copies pictures in new files, whose names are the same as identification numbers of person on these pictures (eg. 8ff985a43603dbf8.jpg). If there are more person on the picture it makes more copies. If a person is on more pictures, later override earlier copies of pictures; if a person 8ff985a43603dbf8 may appear in more pictures, only one file with this name will exist. You must presume that we have a simple file .picasa.ini (look at attached file).

7 points: The same as above, but the names of the files should be the same as names of person, spaces replaced by "_". Instead of 8ff985a43603dbf8.jpg => Michael_Scott.jpg, contacts.xml tells us that number 8ff985a43603dbf8 is Michael Scott. Later pictures override earlier ones.

8 points: The same as above, but give later copies serial numbers, so you don't override pictures of person with the same name. If Michael Scott was on 4 pictures, the names would be Michael_Scott.jpg, Michael_Scott_0001.jpg, Michael_Scott_0002.jpg and Michael_Scott_0003.jpg. You can presume that one person was photographed max. 10000.

9 points:
Change the program so it can read .picasa.ini. which includes some new information (see attached files .picasa2.ini).

10 points:
Same as before, but it mustn't copy the pictures, but only faces, that are on them. Result Michael_Scott.jpg, Michael_Scott_0001.jpg, Michael_Scott_0002.jpg, ... (only faces of the person).


Files, that are made by the program must be like in (see attached file picasa-za-10.zip).

Use files in picasa.zip.

Some help for coordinates:
1) If there are less than 16 characters, add 0's to the beginning.
2) If the picasa code is 0123456789ABCDEF, then the upper left corner of the face tag is at (0123,4567) and the lower right corner is at (89AB,CDEF)
3) The upper left corner of the photo is always (0000,0000) while the lower right is always (FFFF,FFFF).
4)The resolution of the photo doesn't matter. To the face tagging software, every photo is FFFF wide and FFFF tall, which equates to 65535 x 65535 (about 4,295 MP.. wow!)
So, if your tag is in the center of the photo, the center of your tag would be at (32767,32767) which is (7FFF,7FFF). For example, the center of my [upper right] tag from my earlier post (cfff 0000 ffff 4000) is ((ffff-cfff),(4000-0000)) which comes to (3000,4000).


PS forgot how to write person in plural :?:

Edited 6 Years Ago by Finki: n/a

It's YOUR exam. Not ours. If you show some effort, we can help you, BUT, we won't write it for you.

It's YOUR exam. Not ours. If you show some effort, we can help you, BUT, we won't write it for you.

Belive me, I have tried to solve this one, but its beyond my capabilities.

I would start working on the 6 point one, as that is clearly the basis for the rest of the programs. Try a bit of simple math from the coordinates help part of your post.... Also, I would state it in general language first before you use actual code. It can save a lot of time. For example, you're supposed to name pictures similarly when the same people are in them, so stating it a bit differently would almost be the code; "for occurence of person in pictures, photo name = name of person + n. n += 1"

I usually find that a lot of the coding is really more logic work than syntax knowledge. With that in mind, this should be much simpler than it might seem. Good luck :)

f = open('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini')
while True:
    line = f.readline()
    if not line:
        break

This is how I opened a file and told the program to read lines. Now I'm trying to figure out how to split lines that start with 'faces' by ';' and then by ',' so that I get a list of all faces.

for line in open('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini'):
    if line.startswith('faces'):
        #line.split()

Now I figured out a better way to open the file and also read lines that start with faces. But now I have a new problem, how can I split this (only bold)

faces=rect64(acb64583d1eb84cb),2623af3d8cb8e040;rect64(58bf441388df9592),d85d127e5c45cdc2

into a list? And also, how do I replace files that are named like this img_8538.jpg with bolded names? What commad should I use? Must I open these files first and than replace them?

I don't think 5 lines is much effort. Sorry.

import ConfigParser
import string
config = ConfigParser.ConfigParser()
config.read('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini')
imgs = []
for item in config.sections():
    imgs.append(config.get(item, 'faces'))#this line doesn't get me anywhere

I must stripe out those bolded words but I really don't know how to use this split metod to do so.

You probably want a list here. What about something like the following?

f = open('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini')
FacesLines = [] #the f.readline() of all lines in f that begin with "faces"
for line in f:
    LettersInLine = [] #list of each individual letter in the current line
    a = file.readline()
    for l in a:
        LettersInLine.append(l)
    if LettersInLine(0) == "f" and LettersInLine(1) == "a" and LettersInLine(2) == "c" LettersInLine(3) == "e" and LettersInLine(4) == "s": #if the first five letters in the line are "faces"
        FacesLines.append(a) #add the line to FaceLines. The default is: otherwise, do nothing and continue until a new line with "faces" is found

Cheers!

faces=rect64(acb64583d1eb84cb),2623af3d8cb8e040;rect64(58bf441388df9592),d85d127e5c45cdc2

It appears that you could split on the comma and then on the semi-colon since you want the last string in the pair. Then flatten the resulting list. Otherwise, parse each line and look for a start and stop copying character (which may be easier to understand and is a skill that is necessary in a lot of real world applications).

Edited 6 Years Ago by woooee: n/a

This question has already been answered. Start a new discussion instead.