Skip to content

Commit

Permalink
m [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
hMatoba committed Feb 14, 2015
1 parent bbe6507 commit bd264f6
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ $RECYCLE.BIN/
samples2
load_sample.py
*.pdf
*.suo
*.suo
doc/_build/
Binary file modified doc/_build/doctrees/appendices.doctree
Binary file not shown.
Binary file modified doc/_build/doctrees/changes.doctree
Binary file not shown.
Binary file modified doc/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/_build/doctrees/sample.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/_build/html/_sources/appendices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Exif Data in Piexif
-------------------

Each exif tag has appropriate type of the value. BYTE, ASCII, SHORT, or... See the document of Exif.
http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf
http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf

+---------------+----------------------+
| **Exif Type** | **Python Type(3.x)** |
Expand Down
5 changes: 5 additions & 0 deletions doc/_build/html/_sources/changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

1.0.1
-----

- Fix bug. 'load' and 'dump' InteroperabilityIFD was wrong.

1.0.0
-----

Expand Down
38 changes: 38 additions & 0 deletions doc/_build/html/_sources/sample.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,41 @@ Rotate image by exif orientation tag and remove orientation tag.
img = img.rotate(90)

img.save(filename, exif=exif_bytes)

Piexif on Server
----------------

Piexif loads exif data as dict from JPEG. Python dict is easy to convert to JSON, therefore piexif has a good compatible with AJAX, document oriented DB...

::

import json

import tornado.web
import tornado.wsgi
import piexif


class PostHandler(tornado.web.RequestHandler):
def post(self):
jpg_data = self.request.body
try:
exif_dict = piexif.load(jpg_data)
except:
self.set_status(400)
return self.write("Wrong jpeg")
self.add_header("Content-Type", "application/json")
thumbnail = exif_dict.pop("thumbnail")
data_d = {}
for ifd in exif_dict:
data_d[ifd] = {piexif.TAGS[ifd][tag]["name"]:exif_dict[ifd][tag]
for tag in exif_dict[ifd]}
data_d["thumbnail"] = thumbnail
data = json.dumps(data_d, encoding="latin1")
return self.write(data)

application = tornado.web.Application([
(r"/p", PostHandler),
])

application = tornado.wsgi.WSGIAdapter(application)
6 changes: 4 additions & 2 deletions doc/_build/html/appendices.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#b">1.0.0b</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down Expand Up @@ -137,7 +139,7 @@ <h1>Appendices<a class="headerlink" href="#appendices" title="Permalink to this
<div class="section" id="exif-data-in-piexif">
<h2>Exif Data in Piexif<a class="headerlink" href="#exif-data-in-piexif" title="Permalink to this headline"></a></h2>
<p>Each exif tag has appropriate type of the value. BYTE, ASCII, SHORT, or... See the document of Exif.
<a class="reference external" href="http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf">http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf</a></p>
<a class="reference external" href="http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf">http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf</a></p>
<table border="1" class="docutils">
<colgroup>
<col width="41%" />
Expand Down
12 changes: 10 additions & 2 deletions doc/_build/html/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="#c">0.7.0c</a></li>
</ul>
</li>
Expand Down Expand Up @@ -134,7 +136,13 @@
<div class="section" id="changelog">
<h1>Changelog<a class="headerlink" href="#changelog" title="Permalink to this headline"></a></h1>
<div class="section" id="id1">
<h2>1.0.0<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<h2>1.0.1<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>Fix bug. &#8216;load&#8217; and &#8216;dump&#8217; InteroperabilityIFD was wrong.</li>
</ul>
</div>
<div class="section" id="id2">
<h2>1.0.0<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>Add handling InteroperabilityIFD, 1stIFD, and thumbnail image.</li>
<li><em>&#8216;load&#8217;</em> returns a dict that contains &#8220;0th&#8221;, &#8220;Exif&#8221;, &#8220;GPS&#8221;, &#8220;Interop&#8221;, &#8220;1st&#8221;, and &#8220;thumbnail&#8221; keys.</li>
Expand Down
4 changes: 3 additions & 1 deletion doc/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down
8 changes: 6 additions & 2 deletions doc/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down Expand Up @@ -164,10 +166,12 @@ <h1>Welcome to Piexif&#8217;s documentation!<a class="headerlink" href="#welcome
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down
6 changes: 4 additions & 2 deletions doc/_build/html/objects.inv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# Project: Piexif
# Version: 1.0.0
# The remainder of this file is compressed using zlib.
xڍ�M
� ��}N1�nd�tQ(�6Na�ђ޾?�E�Pw���*�㴂$3��!�@>[�&G�p� v���o����M&��{��Q]���`q�so� �_�9�g�>��#��S�,�4��IJ`l��i��������
xڍ�1
�0 �ݧ��Ys��BO�FJb�ec;%�})��Bo���A��a�!��o�pN�.s�^`�ӰeǗ+h
��(�n��`7�݅n����H�3�L�7H'6/b�#��x�0+���
���[[�oV��N�U�=�Lu��ׄ�
40 changes: 39 additions & 1 deletion doc/_build/html/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@
<li class="toctree-l2"><a class="reference internal" href="#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#b">1.0.0b</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down Expand Up @@ -197,6 +199,42 @@ <h2>Rotate Image by Exif Orientation<a class="headerlink" href="#rotate-image-by
</pre></div>
</div>
</div>
<div class="section" id="piexif-on-server">
<h2>Piexif on Server<a class="headerlink" href="#piexif-on-server" title="Permalink to this headline"></a></h2>
<p>Piexif loads exif data as dict from JPEG. Python dict is easy to convert to JSON, therefore piexif has a good compatible with AJAX, document oriented DB...</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">json</span>

<span class="kn">import</span> <span class="nn">tornado.web</span>
<span class="kn">import</span> <span class="nn">tornado.wsgi</span>
<span class="kn">import</span> <span class="nn">piexif</span>


<span class="k">class</span> <span class="nc">PostHandler</span><span class="p">(</span><span class="n">tornado</span><span class="o">.</span><span class="n">web</span><span class="o">.</span><span class="n">RequestHandler</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">post</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">jpg_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">body</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">exif_dict</span> <span class="o">=</span> <span class="n">piexif</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">jpg_data</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;Wrong jpeg&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_header</span><span class="p">(</span><span class="s">&quot;Content-Type&quot;</span><span class="p">,</span> <span class="s">&quot;application/json&quot;</span><span class="p">)</span>
<span class="n">thumbnail</span> <span class="o">=</span> <span class="n">exif_dict</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s">&quot;thumbnail&quot;</span><span class="p">)</span>
<span class="n">data_d</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">ifd</span> <span class="ow">in</span> <span class="n">exif_dict</span><span class="p">:</span>
<span class="n">data_d</span><span class="p">[</span><span class="n">ifd</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">piexif</span><span class="o">.</span><span class="n">TAGS</span><span class="p">[</span><span class="n">ifd</span><span class="p">][</span><span class="n">tag</span><span class="p">][</span><span class="s">&quot;name&quot;</span><span class="p">]:</span><span class="n">exif_dict</span><span class="p">[</span><span class="n">ifd</span><span class="p">][</span><span class="n">tag</span><span class="p">]</span>
<span class="k">for</span> <span class="n">tag</span> <span class="ow">in</span> <span class="n">exif_dict</span><span class="p">[</span><span class="n">ifd</span><span class="p">]}</span>
<span class="n">data_d</span><span class="p">[</span><span class="s">&quot;thumbnail&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">thumbnail</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">data_d</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s">&quot;latin1&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

<span class="n">application</span> <span class="o">=</span> <span class="n">tornado</span><span class="o">.</span><span class="n">web</span><span class="o">.</span><span class="n">Application</span><span class="p">([</span>
<span class="p">(</span><span class="s">r&quot;/p&quot;</span><span class="p">,</span> <span class="n">PostHandler</span><span class="p">),</span>
<span class="p">])</span>

<span class="n">application</span> <span class="o">=</span> <span class="n">tornado</span><span class="o">.</span><span class="n">wsgi</span><span class="o">.</span><span class="n">WSGIAdapter</span><span class="p">(</span><span class="n">application</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>


Expand Down
4 changes: 3 additions & 1 deletion doc/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@
<li class="toctree-l2"><a class="reference internal" href="sample.html#with-pil-pillow">With PIL(Pillow)</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#check-containing-tag">Check Containing Tag</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="sample.html#piexif-on-server">Piexif on Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id1">1.0.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#id2">1.0.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#c">0.7.0c</a></li>
</ul>
</li>
Expand Down

0 comments on commit bd264f6

Please sign in to comment.