Ce projet essai, en partant d'une IMAGESOURCE de : - appliquer des effets à l'image - la redimmensionner - changer son mode de couleur - la HAACHEER...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1_crop.py 797B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/python
  2. # coding: utf-8
  3. import Image, sys
  4. from time import gmtime, strftime
  5. im1 = Image.open(str(sys.argv[1]))
  6. largeur = im1.size[0]
  7. hauteur = im1.size[1]
  8. crop = hauteur * 3 / 4
  9. nb = largeur/crop
  10. # print infos image
  11. print
  12. print "dimensions : %d * %d pix" % (largeur, hauteur)
  13. print "crop : %d, nb = largeur/crop = %d" % (crop, nb)
  14. i = 0
  15. x1 = y1 = 0
  16. x2 = crop
  17. y2 = hauteur
  18. scriptpy = str(sys.argv[1])
  19. script = scriptpy[:-3]
  20. while i < nb :
  21. #print infos crop
  22. print
  23. print "x1 %d" % x1
  24. print "y1 %d" % y1
  25. print "x2 %d" % x2
  26. print "y2 %d" % y2
  27. print
  28. #enregistrement
  29. im2 = im1.crop((x1,y1,x2,y2))
  30. im2.save(script+".crop."+str(crop)+"."+strftime("%Y%m%d-%Hh%Mm%Ss", gmtime())+"._"+str(i)+"_.png",'PNG', quality=100)
  31. #incr boucle
  32. x1 = x1 + crop
  33. x2 = x2 + crop
  34. i = i +1