Preserving EXIF data and image.info['dpi'] missing

Ryan Neve <[email protected]> Wed, 20 Feb 2013 15:11:01 -0500
Newsgroups gmane.comp.python.image
Organization University of North Carolina Institute of Marine Sciences
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------020705060100030604070308
Content-Type: multipart/alternative;
 boundary="------------000603030707030104060206"


--------------000603030707030104060206
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I'm using PIL with a time lapse camera to add some text and a few 
reference lines to an image. I'm using jpeg, but may switch to ppm 
(converted from raw). I have two problems.

First, it seems as if PIL can read EXIF data but not write it. Is this 
correct? I've seen a lot of posts asking this question, but no recent 
answers. I really need the EXIF data preserved when I save the image.

Second, when saving, the default dpi is 72, not the original dpi. I saw 
someone suggest:

image.save('file.jpeg', dpi = image.info['dpi'])

but my image.info is {'exif':'very long string...'} with no dpi key.

I ended up hard coding my (300,300) dpi, but this seems less than ideal.

Thanks

-- 
*Ryan Neve*
University of North Carolina
Institute of Marine Sciences
3431 Arendell St
Morehead City, NC 28557
(252) 726-6841 x179
(252) 726.2426 Fax


--------------000603030707030104060206
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I'm using PIL with a time lapse camera to add some text and a few
    reference lines to an image. I'm using jpeg, but may switch to ppm
    (converted from raw). I have two problems. <br>
    <br>
    First, it seems as if PIL can read EXIF data but not write it. Is
    this correct? I've seen a lot of posts asking this question, but no
    recent answers. I really need the EXIF data preserved when I save
    the image.<br>
    <br>
    Second, when saving, the default dpi is 72, not the original dpi. I
    saw someone suggest:<br>
    <br>
    image.save('file.jpeg', dpi = image.info['dpi'])<br>
    <br>
    but my image.info is {'exif':'very long string...'} with no dpi key.<br>
    <br>
    I ended up hard coding my (300,300) dpi, but this seems less than
    ideal.<br>
    <br>
    Thanks<br>
    <br>
    <div class="moz-signature">-- <br>
      <font size="2"><b>Ryan Neve</b></font><br>
      <font size="2">University of North Carolina</font><br>
      <font size="2">Institute of Marine Sciences</font><br>
      <font size="2">3431 Arendell St</font><br>
      <font size="2">Morehead City, NC 28557</font><br>
      <font size="1">(252) 726-6841 x179</font><br>
      <font size="1">(252) 726.2426 Fax</font>
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr align="center">
          </tr>
          <tr align="center">
          </tr>
          <tr align="center">
          </tr>
          <tr align="left">
          </tr>
          <tr align="left">
          </tr>
          <tr align="left">
          </tr>
          <tr align="left">
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>

--------------000603030707030104060206--

--------------020705060100030604070308
Content-Type: text/x-vcard; charset=utf-8;
 name="neve.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="neve.vcf"

begin:vcard
fn:Ryan Neve
n:Neve;Ryan
org:University of North Carolina Insititute of Marine Sciences;Luettich Lab
adr:;;3431 Arendell St;Morehead City;NC;28557;USA
email;internet:[email protected]
tel;work:252 726-6841
tel;cell:252 515-0012
x-mozilla-html:TRUE
url:ims.unc.edu
version:2.1
end:vcard


--------------020705060100030604070308
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig

--------------020705060100030604070308--