×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    4

    Taking photo in JPEG_Exif format

    Hi,

    I'm working on a project and need to tag photos on a N97 using Python.
    I found out how to tag JPEG-photos using Exif and to take photos in RGB-format.

    The problem is that I can't tag RGB-photos with Exif-information. So I want to take photos in JPEG-format.

    I've been searching all over the web but can't find a working example of how to do it.
    I found this:

    Code:
    import appuifw, e32
     
     
    #Switch to landscape mode
    appuifw.app.orientation = "landscape"
     
    import camera
     
    app_lock = e32.Ao_lock() 
    def quit():
    	#Release the camera so that other programs can use it
    	camera.release()
    	app_lock.signal()
    appuifw.app.exit_key_handler = quit
     
    #Function for taking the picture
    def take_picture():
    	#Take the photo
    	photo = camera.take_photo('JPEG_Exif', (2592, 1944))
    	#Save it
    	f = open(savepath, "w")
    	f.write(photo)
    	f.close()
     
    savepath = u"C:\\DATA\\photo.jpg"  
    #This is the path and name for storing the photo
     
    appuifw.app.body = appuifw.Canvas()
     
    appuifw.app.menu=[(u"Take photo", take_picture)]
     
    app_lock.wait()
    Unfortunately the file I get as result can't be read on either my computer or on the phone. It doesn't seem to contain a JPEG-photo.

    Please help me. How to take a JPEG-photo using Python on N97

    Thanks.

    Jonas

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Taking photo in JPEG_Exif format

    Hello Jonas

    Instead:

    Code:
    #Take the photo
    photo = camera.take_photo('JPEG_Exif', (2592, 1944))
    #Save it
    f = open(savepath, "w")
    f.write(photo)
    f.close()
    Try:

    Code:
    photo = camera.take_photo('JPEG_Exif', (2592, 1944))
    photo.save(savepath)
    take_photo return an Image object, with several useful functions.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    4

    Re: Taking photo in JPEG_Exif format

    Hi Marcelo,

    Thank you for your reply.

    The method you are describing works very well if picture-mode is RGB. But as I can see in the page of your first link, the camera returns raw JPEG-data when picture-mode is JPEG_Exif.
    If I try to save it using your method I get the message that 'str' does not have a 'save'-method. So it seems the raw JPEG-data is returned as a string.

    I would be satisfied with the photos in RGB-format if it wasnøt for the fact that I need to do some Exif-tagging.

    Kind regards.
    Jonas

  4. #4
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Taking photo in JPEG_Exif format

    My fault, Jonas, sorry ...
    I did a test here as below and it worked:

    Code:
    photo = camera.take_photo('JPEG_Exif')
    f = open("e:\\photo.jpg", "wb")
    f.write(photo)
    f.close()
    Pay attention in the "b". You are saving as text, not binary ! That is the problem.

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    4

    Re: Taking photo in JPEG_Exif format

    Thank you SO much, Marcelo.

    That did it!

    But I'm afraid there's an error here then: http://wiki.forum.nokia.com/index.ph...o_take_a_photo

    Once again: thank you for your help. My JPEG-tagging works perfectly now.

    Kind regards,
    Jonas

  6. #6
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Taking photo in JPEG_Exif format

    Yes, same problem. I fixed it as well. Thanks for reporting!

Similar Threads

  1. tabs in menus
    By Scolpy in forum Symbian
    Replies: 9
    Last Post: 2008-11-08, 21:31
  2. MediaException taking a photo with 5310
    By manupeco in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2008-07-14, 15:11
  3. Make a photo in BMP format
    By Red Falcon in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-06-04, 07:28
  4. Being notified upon taking photo
    By tote_b5 in forum Symbian
    Replies: 2
    Last Post: 2008-02-17, 19:46
  5. How to see, that you are taking a photo off
    By klaus15 in forum Symbian
    Replies: 3
    Last Post: 2003-06-11, 03:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×