Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34957
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!ecngs!feeder.ecngs.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vincent.vandevyvre@swing.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'url:launchpad': 0.05; 'except:': 0.07; 'pil': 0.07; 'suggestions,': 0.07; 'try:': 0.07; 'python': 0.09; 'anymore.': 0.09; 'retained': 0.09; 'self.data': 0.09; '2.7': 0.13; 'from:addr:swing.be': 0.16; 'from:addr:vincent.vandevyvre': 0.16; 'from:name:vincent vande vyvre': 0.16; 'message-id:@swing.be': 0.16; 'oqapy': 0.16; 'paqager': 0.16; 'received:mobistar.be': 0.16; 'resize': 0.16; 'subject:image': 0.16; 'url:bazaar': 0.16; 'url:head': 0.16; 'url:oqapy': 0.16; 'url:paqager': 0.16; 'url:py': 0.16; 'url:qarte': 0.16; 'v.v.': 0.16; '\xe9crit': 0.16; 'have:': 0.17; 'url:view': 0.18; 'skip:p 30': 0.20; 'import': 0.21; 'modifying': 0.22; 'work.': 0.23; 'seems': 0.23; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:" 20': 0.26; 'img': 0.29; 'helpful': 0.30; 'info': 0.32; 'retain': 0.33; 'subject:data': 0.33; 'ubuntu': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'thanks': 0.34; 'saved': 0.35; 'add': 0.36; 'but': 0.36; 'data.': 0.36; 'subject:with': 0.36; 'skip:p 20': 0.36; 'ones': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'email addr:gmail.com': 0.63; 'more': 0.63; 'received:80.12': 0.65; 'url:0': 0.67; 'gps': 0.91 |
| Date | Mon, 17 Dec 2012 07:39:31 +0100 |
| From | Vincent Vande Vyvre <vincent.vandevyvre@swing.be> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: modify image and save with exif data |
| References | <31bba35e-53e7-4a75-8ac8-ea10f4a8b4b8@googlegroups.com> |
| In-Reply-To | <31bba35e-53e7-4a75-8ac8-ea10f4a8b4b8@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.946.1355726830.29569.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1355726830 news.xs4all.nl 6984 [2001:888:2000:d::a6]:40457 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:34957 |
Show key headers only | View raw
Le 16/12/12 20:43, jwe.van.dijk@gmail.com a écrit :
> I want to resize an image but retain the exif data
> I now have:
> import Image
>
> img = Image.open('photo.jpg')
> img.thumbnail((800, 800), Image.ANTIALIAS)
> img.save('photo800.jpg', 'JPEG')
>
> The saved image photo800.jpg has no exif info anymore.
> I would so much like to have it retained in particular the exposure and gps data.
>
> I use Python 2.7 with PIL 1.17 on Ubuntu 12.04
> For exif reading/writing I use pyexiv2 0.3.2 but apparently you cannot add tags to an image that has none; only modifying existing ones seems to work.
>
> Thanks for any helpful suggestions,
> Janwillem
Hi,
If a tag is not already set you can create it with pyexiv2.
Example:
----------------------------------------------------------------------
self.data = pyexiv2.ImageMetadata(img.jpg)
self.data.read()
tag = "Exif.Image.ImageWidth"
try:
self.data[tag].value = sizes[0]
except:
self.data[tag] = pyexiv2.ExifTag(tag, sizes[0])
-----------------------------------------------------------------------
A more complete example:
http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/serie-1.0/view/head:/oqapy-1.0/metadata.py
--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
modify image and save with exif data jwe.van.dijk@gmail.com - 2012-12-16 11:43 -0800 Re: modify image and save with exif data Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2012-12-17 07:39 +0100 Re: modify image and save with exif data jwe.van.dijk@gmail.com - 2012-12-17 01:10 -0800
csiph-web