pillow.readthedocs.io/en/stable/installation.html#basic-installation

 

Installation — Pillow (PIL Fork) 8.0.1 documentation

Build flags: --disable-zlib, --disable-jpeg, --disable-tiff, --disable-freetype, --disable-lcms, --disable-webp, --disable-webpmux, --disable-jpeg2000, --disable-imagequant, --disable-xcb. Disable building the corresponding feature even if the development

pillow.readthedocs.io

 

exif 정보를 불러올 수 있는 모양

 

  exif 정보는 아래와 같은 정보를 담고 있음

www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html

 

EXIF Tags

TIFF Tag Reference, Exif Tags Exif tags are used largely to encode additional information related to image generation by digital still cameras. Exif is the abbreviation of 'Exchangeable image file format', though this can be argued to be a misnomer, as Exi

www.awaresystems.be

 

 

PIL 을 이용해서 jpg 파일의 정보를 출력하는 간단한 프로그램

 

from PIL import Image
im = Image.open('5D3_9369.JPG')
takentime = im.getexif()[36867]
print (im.format, im.size, im.mode, takentime)

 

결과 

 

JPEG (5760, 3840) RGB 2020:10:18 12:50:39

'Python' 카테고리의 다른 글

Macbook Catalina Python 개발 환경 잡기  (0) 2020.11.28
Python 연습 프로젝트 1  (0) 2020.11.28
Tkinter 를 이용한 시계  (0) 2017.06.27
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08

 - Visual Studio Code

code.visualstudio.com

 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

- brew

brew.sh

 

 - Python3.8.2

medium.com/front-end-weekly/how-to-install-the-latest-python-3-on-mac-with-no-issues-5db0045e1429

 

 - pip 

www.geeksforgeeks.org/how-to-install-pip-in-macos/#:~:text=pip%20can%20be%20downloaded%20and%20installed%20using%20command-line,3%20Voila%21%20pip%20is%20now%20installed%20on%20

 

- Visual Studio Code 에서 python extension 들 설치

- Visual Studio Code 에서 python interpreter 설정

 : ⌘+⇧+p 

 : Python: Select Interpreter

 

사용할 python version 선택

 

 - 번외 : Mac Terminal 용 Dracula theme 설치

'Python' 카테고리의 다른 글

Python JPEG 사진 정보 불러오기 : pillow  (0) 2020.11.28
Python 연습 프로젝트 1  (0) 2020.11.28
Tkinter 를 이용한 시계  (0) 2017.06.27
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08

원하는 기능

특정 폴더에 있는 사진파일을 읽어 년도 아래 월 폴더를 만들어 이동시키기

 

 

연습 목록

1. Python 으로 사진파일 정보 중 촬영날짜 읽어오기

loekohcoder.tistory.com/27

2. Python 으로 디렉터리 확인 및 생성

 

3. Python 으로 파일 이동

'Python' 카테고리의 다른 글

Python JPEG 사진 정보 불러오기 : pillow  (0) 2020.11.28
Macbook Catalina Python 개발 환경 잡기  (0) 2020.11.28
Tkinter 를 이용한 시계  (0) 2017.06.27
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08

# clock.py  By Anton Vredegoor (anton.vredegoor@gmail.com) 

# last edit: july 2009,

# license: GPL

# enjoy!


"""

A very simple  clock.


The program transforms worldcoordinates into screencoordinates 

and vice versa according to an algorithm found in: "Programming 

principles in computer graphics" by Leendert Ammeraal.


"""


from Tkinter import *

from time import localtime

from datetime import timedelta,datetime

import sys, types, os


_inidle = type(sys.stdin) == types.InstanceType and \

  sys.stdin.__class__.__name__ == 'PyShell'


class transformer:


    def __init__(self, world, viewport):

        self.world = world 

        self.viewport = viewport



class clock:


    def __init__(self,root,deltahours = 0):

        self.world       = [-1,-1,1,1]

        self.bgcolor     = '#ffffff'

        self.timecolor   = '#000000'

        self._ALL        = 'all'

        self.pad         = 25

        self.root        = root

        WIDTH, HEIGHT = 200, 200

        root.bind("<Escape>", lambda _ : root.destroy())

        self.delta = timedelta(hours = deltahours)  

        self.canvas = Canvas(root, 

                width       = WIDTH,

                height      = HEIGHT,

                background  = self.bgcolor)

        viewport = (self.pad,self.pad,WIDTH-self.pad,HEIGHT-self.pad)

        self.T = transformer(self.world,viewport)

        self.root.title('Clock')

        self.canvas.bind("<Configure>",self.configure())

        self.canvas.pack(fill=BOTH, expand=YES)

        self.poll()

 

    def configure(self):

        self.redraw()

    

    def redraw(self):

        sc = self.canvas

        sc.delete(self._ALL)

        width = sc.winfo_width()

        height =sc.winfo_height()

        sc.create_rectangle([[0,0],[width,height]], fill = self.bgcolor, tag = self._ALL)


        viewport = (self.pad,self.pad,width-self.pad,height-self.pad)

        self.T = transformer(self.world,viewport)

        self.paintgrafics()


    def paintgrafics(self):

        self.painthms()

    

    def painthms(self):

        sc = self.canvas

        T = datetime.timetuple(datetime.utcnow()-self.delta)

        x,x,x,h,m,s,x,x,x = T

    #self.root.title('%02i:%02i:%02i' %(h,m,s))

        now = datetime.now()

        curTime = now.strftime('%H:%M:%S')

        workTime = now-startTime;

        sc.create_text(100,10,fill="black",text="NOW  :"+curTime)

        sc.create_text(100,30,fill="orange",text="START:"+startTime.strftime('%H:%M:%S'))

        if (workTime.seconds > 5) :

            sc.create_text(100,50,fill="magenta",text="Go to HOME!!")

        if (workTime.seconds > 8) :

            sc.create_text(100,70,fill="magenta",text="15,000!!")

    def poll(self):

        self.configure()

        self.root.after(200,self.poll)


def main():

    root= Tk()

    global startTime

    startTime = datetime.now()

    clock(root,deltahours = -9)

    if not _inidle:

        root.mainloop()


if __name__=='__main__':

  main()



'Python' 카테고리의 다른 글

Macbook Catalina Python 개발 환경 잡기  (0) 2020.11.28
Python 연습 프로젝트 1  (0) 2020.11.28
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08
functions  (0) 2016.02.08



코드 아카데미를 하나씩 따라하다가, 이제 점점 큰 프로그램들도 짜보자 싶어서 맥에다가 파이썬 개발 환경을 구축했다.

역시, 다루는 도구가 이뻐야 뭐든 시작하지.

그냥 그렇게 생각하기로 했다. (먼산)


우선, 평소에 궁금했던 sublimetext3 를 설치했고, 

생각보다 가벼운 텍스트 에디터였기에, 이것저것 검색해가며 플러그인들을 추가로 설치했다.


기왕 설치한 거 여기저기 잘 쓸 수 있는 듯 하니 잘 써봐야지 :)


1. sublimetext3에서 키보드 입출력을 사용하는 프로그램도 실행해 볼 수 있도록 하는 플러그인

http://pinkwink.kr/622


2. sidebar 색상 변경 방법

http://stackoverflow.com/questions/27931448/why-do-sublime-text-3-themes-not-affect-the-sidebar


3. package control 설명 및 anaconda

https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/


'Python' 카테고리의 다른 글

Python 연습 프로젝트 1  (0) 2020.11.28
Tkinter 를 이용한 시계  (0) 2017.06.27
import  (0) 2016.02.08
functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08

1. math library

# Ask Python to print sqrt(25) on line 

import math

print math.sqrt(25) 


2. sqrt 만 import 해오기 / 전부 import 해오기

# Import *just* the sqrt function from math on line 3!

from math import sort

from math import *


3. library import 해올 때는 되도록 import module 한 다음 module.function 해서 쓸 것. 함수명/변수명 중복되서 막 사용될 수 있음.

import math            # Imports the math module

everything = dir(math) # Sets everything to a list of things from math

print everything       # Prints 'em all!


4. python 에 기본적으로 내장되어있는 함수들 .upper(), .lower(), str(), len(), max(), min(), abs()

def biggest_number(*args):    #여러개의 인자를 넘기는 방법이 특이하다. 오오.

    print max(args)

    return max(args)

    

def smallest_number(*args):

    print min(args)

    return min(args)


def distance_from_zero(arg):

    print abs(arg)

    return abs(arg)



biggest_number(-10, -5, 5, 10)

smallest_number(-10, -5, 5, 10)

distance_from_zero(-10)


5. max()

# Set maximum to the max value of any set of numbers on line 3!


maximum = max(1, 19231, 2.5)


print maximum


6. min()

# Set minimum to the min value of any set of numbers on line 3!


minimum = min(4, -2 , 10, 123, -123.1)


print minimum


7. abs()


absolute = abs(-42)


print absolute


8. type()

# Print out the types of an integer, a float,

# and a string on separate lines below.


print type(42)

print type(-1.2)

print type('keol')


9. 

def shut_down(s):

    if s == "yes":

        return "Shutting down"

    elif s == "no":

        return "Shutdown aborted"

    else:

        return "Sorry"


10.

import math


print math.sqrt(13689)


11.

def distance_from_zero(arg):

    if type(arg) == int or type(arg) == float:

        return abs(arg)

    else:

        return "Nope"



'Python' 카테고리의 다른 글

Tkinter 를 이용한 시계  (0) 2017.06.27
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05

1. def 함수명(인자이름):   <- 콜론!

# Define your spam function starting on line 5. You

# can leave the code on line 11 alone for now--we'll

# explain it soon!


def spam():

    """printing eggs! in console"""

    print "Eggs!"



# Define the spam function above this line.

spam()


2. 함수 호출하기

def square(n):

    """Returns the square of a number."""

    squared = n**2

    print "%d squared is %d." % (n, squared)

    return squared

    

# Call the square function on line 9! Make sure to

# include the number 10 between the parentheses.


square(10)


3. 함수 인자 사용방법

def power(base, exponent):  # Add your parameters here!

    result = base**exponent

    print "%d to the power of %d is %d." % (base, exponent, result)


power(37,4)  # Add your arguments here!


4. 함수 안에서 함수 사용하기

def one_good_turn(n):

    return n + 1

    

def deserves_another(n):

    return one_good_turn(n) + 2


5. 함수 만들기 연습

def cube(number):

    return number**3


def by_three(number):

    if number%3 == 0:

        return cube(number)

    else :

        return False

        



'Python' 카테고리의 다른 글

Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04

1.

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")


2.

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")

if len(original) > 0:

    print original

else:

    print "empty"


3. isalpha() 캐릭터로만 되어있는지 아닌지 알아보는 함수

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")

if len(original) > 0 and original.isalpha():

    print original

else:

    print "empty"


4. 

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

else:

    print 'empty'


5. 문자열 concatenation 은 + 로. 동적 할당 이런거 신경 안써줘도 되넹

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

    new_word = word + first + pyg

    print new_word

else:

    print 'empty'


6. 배열 부분 접근 가능! matlab이랑 비슷하네

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

    new_word = word + first + pyg

    new_word = new_word[1:len(new_word)]

    print new_word

else:

    print 'empty'

'Python' 카테고리의 다른 글

import  (0) 2016.02.08
functions  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04
string  (0) 2016.02.02

1. 조건문 연습, 그 return 값

# Assign True or False as appropriate on the lines below!


# 17 < 118 % 100

bool_one = (17 < 328)


# 100 == 33 * 3 + 1

bool_two = ( 100 == (2*50) )


# 19 <= 2**4

bool_three = (19 <= 19)


# -22 >= -18

bool_four = (-22 >= -18)


# 99 != 98 + 1

bool_five = ( 99 != (98 + 1) )

# 20 + -10 * 2 > 10 % 3 % 2

bool_one = (20 - 10) > 15


# (10 + 17)**2 == 3**6

bool_two = (10 + 17) == 3**16


# 1**2**3 <= -(-(-1))

bool_three = 1**2 <= -1


# 40 / 20 * 4 >= -4**2

bool_four = 40 * 4 >= -4


# 100**0.5 != 6 + 4

bool_five = 100 != 10**2

#대입 연산자 우선순위는 python에서도 많이 낮은 듯 하다.


2. boolean 연산

"""

     Boolean Operators

---------------------------

True and True is True

True and False is False

False and True is False

False and False is False


True or True is True

True or False is True

False or True is True

False or False is False


Not True is False

Not False is True


"""

bool_one = False and False


# -(-(-(-2))) == -2 and 4 >= 16**0.5

bool_two = -(-(-(-2))) == -2 and 4 >= 16**0.5


# 19 % 4 != 300 / 10 / 10 and False

bool_three = 19 % 4 != 300 / 10 / 10 and False


# -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

bool_four =  -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2


# True and True

bool_five = True and True

# 2**3 == 108 % 100 or 'Cleese' == 'King Arthur'

bool_one = 2**3 == 108 % 100 or 'Cleese' == 'King Arthur'


# True or False

bool_two = True or False


# 100**0.5 >= 50 or False

bool_three = 100**0.5 >= 50 or False


# True or True

bool_four = True or True


# 1**100 == 100**1 or 3 * 2 * 1 != 3 + 2 + 1

bool_five = 1**100 == 100**1 or 3 * 2 * 1 != 3 + 2 + 1

# not True

bool_one = not True


# not 3**4 < 4**3

bool_two = not 3**4 < 4**3


# not 10 % 3 <= 10 % 2

bool_three = not 10 % 3 <= 10 % 2


# not 3**2 + 4**2 != 5**2

bool_four = not 3**2 + 4**2 != 5**2


# not not False

bool_five = not not False


# False or not True and True

bool_one = False or not True and True


# False and not True or True

bool_two = False and not True or True


# True and not (False or False)

bool_three = True and not (False or False)


# not not True or False and not True

bool_four = not not True or False and not True


# False or not (True and True)

bool_five = False or not (True and True)



3. if-else

response = 'Y'


answer = "Left"

if answer == "Left":

    print "This is the Verbal Abuse Room, you heap of parrot droppings!"

    

# Will the above print statement print to the console?

# Set response to 'Y' if you think so, and 'N' if you think not.



4.

def using_control_once():

    if True:

        return "Success #1"


def using_control_again():

    if 1>0:

        return "Success #2"


print using_control_once()

print using_control_again()


5. 

answer = "'Tis but a scratch!"


def black_knight():

    if answer == "'Tis but a scratch!":

        return True

    else:             

        return False       # Make sure this returns False


def french_soldier():

    if answer == "Go away, or I shall taunt you a second time!":

        return True

    else:             

        return   False     # Make sure this returns False


6. if elif else (c언어 case 구문처럼 콜론으로 )

def greater_less_equal_5(answer):

    if answer > 5:

        return 1

    elif answer <5:          

        return -1

    else:

        return 0

        

print greater_less_equal_5(4)

print greater_less_equal_5(5)

print greater_less_equal_5(6)


7. 

def the_flying_circus():

    if True or True:    # Start coding here!

        # Don't forget to indent

        # the code inside this block!

        return True

    elif 1<0:

        # Keep going here.

        # You'll want to add the else statement, too!

        return True

    else :

        return True


'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
datetime library  (0) 2016.02.04
string  (0) 2016.02.02
python 걸음마 시작  (0) 2016.02.02

1. library 불러오기

from datetime import datetime


2. 현재시간

from datetime import datetime


now = datetime.now()

print now


3. 년/월/일

from datetime import datetime


now = datetime.now()

print now

print now.year

print now.month

print now.day


from datetime import datetime

now = datetime.now()


print '%s/%s/%s' % (now.month, now.day, now.year)


4. 시:분:초

from datetime import datetime

now = datetime.now()


print '%s:%s:%s' % (now.hour, now.minute, now.second)

3.4 는 print 문법이 완전 다르구나 print ('{}:{}:{}' .format(now.hour, now.minute, now.second))


5. datetime 관련 정리

from datetime import datetime

now = datetime.now()


print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)


'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
string  (0) 2016.02.02
python 걸음마 시작  (0) 2016.02.02

+ Recent posts