Explorar o código

更新 'service/convert.py'

rabin %!s(int64=5) %!d(string=hai) anos
pai
achega
e92910adc0
Modificáronse 1 ficheiros con 16 adicións e 10 borrados
  1. 16 10
      service/convert.py

+ 16 - 10
service/convert.py

@@ -304,17 +304,23 @@ class Convert(object):
 	def cut(self, info):
 		from pdf2jpg import pdf2jpg
 		from wand.image import Image
-		dest = info['html'] + '.photo'
 		result = pdf2jpg.convert_pdf2jpg(info['pdf'], dest, pages="0,1")
-		source = result[0]['output_jpgfiles'][0]
-		dest = info['html'] + '.jpg'
-		command = 'mv '+source+' ' + dest
-		Shell.popen(command)
-		target_width = 300
-		with Image(filename=dest) as img:
-			target_width, target_height = self.getSize(target_width, img.width, img.height)
-			img.sample(target_width, target_height)
-			img.save(filename=dest)
+        
+        i = 0
+        for j in result[0]['output_jpgfiles']:
+          source = j
+          if i == 0:
+			dest = info['html'] + '.jpg'
+          else:
+            dest = info['html'] + '.jpg_' + i + '.jpg'
+          command = 'mv '+source+' ' + dest
+          Shell.popen(command)
+          target_width = 300
+          with Image(filename=dest) as img:
+              target_width, target_height = self.getSize(target_width, img.width, img.height)
+              img.sample(target_width, target_height)
+              img.save(filename=dest)
+          i = i+1
 
 		'''
 		from wand.image import Image