Skip to content

Commit

Permalink
Edited documents. [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
hMatoba committed Jan 30, 2015
1 parent 8cf100e commit 910b344
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 6 deletions.
Binary file modified doc/_build/doctrees/appendices.doctree
Binary file not shown.
Binary file modified doc/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/_build/doctrees/index.doctree
Binary file not shown.
Binary file added doc/_build/doctrees/sample.doctree
Binary file not shown.
4 changes: 3 additions & 1 deletion doc/_build/html/_sources/appendices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ If value type is number(BYTE, SHORT, LONG, RATIONAL, or SRATIONAL) and value cou
| RATIONAL, SRATIONAL | ((int, int), (int, int), ...) |
+---------------------+-------------------------------+

.. note:: If value type is number and value count is one, tuple that is length one value(e.g. (int,)) also be accepted.


Exif in piexif example is below.

::
Expand All @@ -44,7 +47,6 @@ Exif in piexif example is below.
piexif.ZerothIFD.Software: u"piexif" # ASCII, count any
}
exif_ifd = {piexif.ExifIFD.ExifVersion: b"\x02\x00\x00\x00" # UNDEFINED, count 4
piexif.ExifIFD.DateTimeOriginal: u"2099:09:29 10:10:10", # ASCII, count 20
piexif.ExifIFD.LensMake: u"LensMake", # ASCII, count any
piexif.ExifIFD.Sharpness: 65535, # SHORT, count 1
piexif.ExifIFD.LensSpecification: ((1, 1), (1, 1), (1, 1), (1, 1)), # Rational, count 4
Expand Down
1 change: 1 addition & 0 deletions doc/_build/html/_sources/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ To simplify exif manipulations with python. Writing, reading, and more... Piexif
installation
functions
appendices
sample

Indices and tables
==================
Expand Down
39 changes: 39 additions & 0 deletions doc/_build/html/_sources/sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=======
Samples
=======

Rotate Image by Exif Orientation
--------------------------------

Rotate image by exif orientation tag and remove orientation tag.

::

from PIL import Image
import piexif


def rotate_jpeg(filename):
zeroth_ifd, exif_ifd, gps_ifd = piexif.load(filename)

if piexif.ZerothIFD.Orientation in zeroth_ifd:
orientation = zeroth_ifd.pop(piexif.ZerothIFD.Orientation)
exif_bytes = piexif.dump(zeroth_ifd, exif_ifd, gps_ifd)

img = Image.open(filename)
if orientation == 2:
img = img.transpose(Image.FLIP_LEFT_RIGHT)
elif orientation == 3:
img = img.rotate(180)
elif orientation == 4:
img = img.rotate(180).transpose(Image.FLIP_LEFT_RIGHT)
elif orientation == 5:
img = img.rotate(-90).transpose(Image.FLIP_LEFT_RIGHT)
elif orientation == 6:
img = img.rotate(-90)
elif orientation == 7:
img = img.rotate(90).transpose(Image.FLIP_LEFT_RIGHT)
elif orientation == 8:
img = img.rotate(90)

img.save(filename, exif=exif_bytes)
12 changes: 11 additions & 1 deletion doc/_build/html/appendices.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<link rel="author" title="About these documents"
href="about.html"/>
<link rel="top" title="Piexif 0.7.0 documentation" href="index.html"/>
<link rel="next" title="Samples" href="sample.html"/>
<link rel="prev" title="Functions" href="functions.html"/>


Expand Down Expand Up @@ -84,6 +85,10 @@
<li class="toctree-l2"><a class="reference internal" href="#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sample.html">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>


Expand Down Expand Up @@ -172,14 +177,17 @@ <h2>Exif Data in Piexif<a class="headerlink" href="#exif-data-in-piexif" title="
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If value type is number and value count is one, tuple that is length one value(e.g. (int,)) also be accepted.</p>
</div>
<p>Exif in piexif example is below.</p>
<div class="highlight-python"><div class="highlight"><pre>zeroth_ifd = {piexif.ZerothIFD.Make: u&quot;Canon&quot;, # ASCII, count any
piexif.ZerothIFD.XResolution: (96, 1), # RATIONAL, count 1
piexif.ZerothIFD.YResolution: (96, 1), # RATIONAL, count 1
piexif.ZerothIFD.Software: u&quot;piexif&quot; # ASCII, count any
}
exif_ifd = {piexif.ExifIFD.ExifVersion: b&quot;\x02\x00\x00\x00&quot; # UNDEFINED, count 4
piexif.ExifIFD.DateTimeOriginal: u&quot;2099:09:29 10:10:10&quot;, # ASCII, count 20
piexif.ExifIFD.LensMake: u&quot;LensMake&quot;, # ASCII, count any
piexif.ExifIFD.Sharpness: 65535, # SHORT, count 1
piexif.ExifIFD.LensSpecification: ((1, 1), (1, 1), (1, 1), (1, 1)), # Rational, count 4
Expand Down Expand Up @@ -223,6 +231,8 @@ <h2>On GoogleAppEngine<a class="headerlink" href="#on-googleappengine" title="Pe

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">

<a href="sample.html" class="btn btn-neutral float-right" title="Samples">Next <span class="fa fa-arrow-circle-right"></span></a>


<a href="functions.html" class="btn btn-neutral" title="Functions"><span class="fa fa-arrow-circle-left"></span> Previous</a>

Expand Down
4 changes: 4 additions & 0 deletions doc/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<li class="toctree-l2"><a class="reference internal" href="appendices.html#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sample.html">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>


Expand Down
8 changes: 8 additions & 0 deletions doc/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<li class="toctree-l2"><a class="reference internal" href="appendices.html#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sample.html">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>


Expand Down Expand Up @@ -148,6 +152,10 @@ <h1>Welcome to Piexif&#8217;s documentation!<a class="headerlink" href="#welcome
<li class="toctree-l2"><a class="reference internal" href="appendices.html#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sample.html">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions doc/_build/html/objects.inv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# Project: Piexif
# Version: 0.7.0
# The remainder of this file is compressed using zlib.
xڍ�M
�0��=ŀnS�7p!�`l�i ���H{{�$ A0�Ǜ�{��5K�!&9|�1����%kNp��!�e�KW�{n�h�N����h��\�̆��i��r�9��yͼ$�&h1� �)�#�~�8�ݰ��wÁ�{��9��
xڍ�1
�0 �ݧ��Ys��BO�FJb�ec;%�})��Bo���A��a��J��!�Ӳ˜���4l���
Z��qw�Gr�Mݜ��n����H��+��RƉ͋��-n߬��?4����{ܙ�(����;)]��f%��΄�
228 changes: 228 additions & 0 deletions doc/_build/html/sample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Samples &mdash; Piexif 0.7.0 documentation</title>






<link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>









<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />



<link rel="author" title="About these documents"
href="about.html"/>
<link rel="top" title="Piexif 0.7.0 documentation" href="index.html"/>
<link rel="prev" title="Appendices" href="appendices.html"/>


<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

<div class="wy-grid-for-nav">


<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search">

<a href="index.html" class="fa fa-home"> Piexif</a>


<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>

<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">



<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="about.html">About Piexif</a><ul>
<li class="toctree-l2"><a class="reference internal" href="about.html#what-for">What for?</a></li>
<li class="toctree-l2"><a class="reference internal" href="about.html#depends-on">Depends on</a></li>
<li class="toctree-l2"><a class="reference internal" href="about.html#environment">Environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="about.html#license">License</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="functions.html">Functions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="functions.html#load">load</a></li>
<li class="toctree-l2"><a class="reference internal" href="functions.html#dump">dump</a></li>
<li class="toctree-l2"><a class="reference internal" href="functions.html#insert">insert</a></li>
<li class="toctree-l2"><a class="reference internal" href="functions.html#remove">remove</a></li>
<li class="toctree-l2"><a class="reference internal" href="functions.html#transplant">transplant</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="appendices.html">Appendices</a><ul>
<li class="toctree-l2"><a class="reference internal" href="appendices.html#exif-data-in-piexif">Exif Data in Piexif</a></li>
<li class="toctree-l2"><a class="reference internal" href="appendices.html#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>



</div>
&nbsp;
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">


<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Piexif</a>
</nav>



<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>

<li>Samples</li>
<li class="wy-breadcrumbs-aside">

<a href="_sources/sample.txt" rel="nofollow"> View page source</a>

</li>
</ul>
<hr/>
</div>
<div role="main" class="document">

<div class="section" id="samples">
<h1>Samples<a class="headerlink" href="#samples" title="Permalink to this headline"></a></h1>
<div class="section" id="rotate-image-by-exif-orientation">
<h2>Rotate Image by Exif Orientation<a class="headerlink" href="#rotate-image-by-exif-orientation" title="Permalink to this headline"></a></h2>
<p>Rotate image by exif orientation tag and remove orientation tag.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">piexif</span>


<span class="k">def</span> <span class="nf">rotate_jpeg</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
<span class="n">zeroth_ifd</span><span class="p">,</span> <span class="n">exif_ifd</span><span class="p">,</span> <span class="n">gps_ifd</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">filename</span><span class="p">)</span>

<span class="k">if</span> <span class="n">piexif</span><span class="o">.</span><span class="n">ZerothIFD</span><span class="o">.</span><span class="n">Orientation</span> <span class="ow">in</span> <span class="n">zeroth_ifd</span><span class="p">:</span>
<span class="n">orientation</span> <span class="o">=</span> <span class="n">zeroth_ifd</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">piexif</span><span class="o">.</span><span class="n">ZerothIFD</span><span class="o">.</span><span class="n">Orientation</span><span class="p">)</span>
<span class="n">exif_bytes</span> <span class="o">=</span> <span class="n">piexif</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">zeroth_ifd</span><span class="p">,</span> <span class="n">exif_ifd</span><span class="p">,</span> <span class="n">gps_ifd</span><span class="p">)</span>

<span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="k">if</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">Image</span><span class="o">.</span><span class="n">FLIP_LEFT_RIGHT</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">Image</span><span class="o">.</span><span class="n">FLIP_LEFT_RIGHT</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">5</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="o">-</span><span class="mi">90</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">Image</span><span class="o">.</span><span class="n">FLIP_LEFT_RIGHT</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">6</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="o">-</span><span class="mi">90</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">7</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">Image</span><span class="o">.</span><span class="n">FLIP_LEFT_RIGHT</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">orientation</span> <span class="o">==</span> <span class="mi">8</span><span class="p">:</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>

<span class="n">img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">exif</span><span class="o">=</span><span class="n">exif_bytes</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>


</div>
<footer>

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">


<a href="appendices.html" class="btn btn-neutral" title="Appendices"><span class="fa fa-arrow-circle-left"></span> Previous</a>

</div>


<hr/>

<div role="contentinfo">
<p>
&copy; Copyright 2015, hMatoba.
</p>
</div>

Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.

</footer>
</div>
</div>

</section>

</div>





<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'0.7.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>





<script type="text/javascript" src="_static/js/theme.js"></script>




<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>


</body>
</html>
4 changes: 4 additions & 0 deletions doc/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<li class="toctree-l2"><a class="reference internal" href="appendices.html#on-googleappengine">On GoogleAppEngine</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sample.html">Samples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sample.html#rotate-image-by-exif-orientation">Rotate Image by Exif Orientation</a></li>
</ul>
</li>
</ul>


Expand Down

0 comments on commit 910b344

Please sign in to comment.