Я хочу создать и изменить изображение веб-сайта, и изображение можно создать в нужном месте, как показано ниже, но я не могу изменить и отформатировать эти изображения.
class Bookmark(models.Model):
title = models.CharField(max_length=200)
user = models.ForeignKey(User)
link = models.ForeignKey(Link)
def __unicode__(self):
return "%s, %s" % (self.user, self.link.url)
def save_image(self):
import subprocess
import os
url = self.link.url.replace("http://","").replace("https://","")\
.replace("/","|")
image_png = './teststatic/url_image/' + url + ".png"
image_jpg = './teststatic/url_image/' + url + ".jpg"
command_line = "python", "webkit2png.py","-o", image_png, self.link.url
image_crop = "mogrify", "-crop", "1280x1024+0+0", image_png
image_convert = "mogrify", "-format", "jpg", image_png
image_del = "rm", image_png
image_resize = "mogrify", "-resize", "150", "-quality", "80", image_jpg
p1=subprocess.Popen(command_line, stdout=subprocess.PIPE)
p2=subprocess.Popen(image_crop, stdin=p1.stdout, stdout=subprocess.PIPE)
p3=subprocess.Popen(image_convert, stdin=p2.stdout, stdout=subprocess.PIPE)
p4=subprocess.Popen(image_del, stdin=p3.stdout, stdout=subprocess.PIPE)
subprocess.Popen(image_resize, stdin=p4.stdout, stdout=subprocess.PIPE)
Здесь трассировка ошибок (переформатирована для удобства чтения):
mogrify: unable to open image `./teststatic/url_image/z.cn.png': \
png.la @ error/blob.c/OpenBlob/2489mogrify: unable to open image \
`./teststatic/url_image/z.cn.png': png.la @ error/blob.c/OpenBlob/2489rm: \
cannot remove `./teststatic/url_image/z.cn.png': No such file or directory
.
mogrify: unable to open image `./teststatic/url_image/z.cn.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/z.cn.png' \
@ error/png.c/ReadPNGImage/2951.
.
mogrify: unable to open image `./teststatic/url_image/z.cn.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/z.cn.png' \
@ error/png.c/ReadPNGImage/2951.
mogrify: unable to open image `./teststatic/url_image/z.cn.jpg': \
jpeg.la @ error/blob.c/OpenBlob/2489.
mogrify: unable to open image `./teststatic/url_image/z.cn.jpg': \
@ error/blob.c/OpenBlob/2489.
rm: cannot remove `./teststatic/url_image/www.igoogle.com|.png': \
No such file or directory
mogrify: unable to open image `./teststatic/url_image/www.igoogle.com|.png': \
png.la @ error/blob.c/OpenBlob/2489.
mogrify: unable to open image `./teststatic/url_image/www.igoogle.com|.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/www.igoogle.com|.png'\
@ error/png.c/ReadPNGImage/2951.
mogrify: unable to open image `./teststatic/url_image/www.igoogle.com|.png':\
png.la @ error/blob.c/OpenBlob/2489mogrify: unable to open image \
`./teststatic/url_image/www.igoogle.com|.jpg': \
jpeg.la @ error/blob.c/OpenBlob/2489.
mogrify: unable to open image `./teststatic/url_image/www.igoogle.com|.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/www.igoogle.com|.png' \
@ error/png.c/ReadPNGImage/2951.
rm: .
mogrify: unable to open image `./teststatic/url_image/www.igoogle.com|.jpg': \
@ error/blob.c/OpenBlob/2489.
cannot remove `./teststatic/url_image/www.z.cn|.png': No such file or directory
mogrify: unable to open image `./teststatic/url_image/www.z.cn|.png':\
png.la @ error/blob.c/OpenBlob/2489.
mogrify: unable to open image `./teststatic/url_image/www.z.cn|.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/www.z.cn|.png'\
@ error/png.c/ReadPNGImage/2951.
mogrify: unable to open image `./teststatic/url_image/www.z.cn|.png': \
png.la @ error/blob.c/OpenBlob/2489.
mogrify: unable to open image `./teststatic/url_image/www.z.cn|.png': \
@ error/blob.c/OpenBlob/2489.
mogrify: unable to open file `./teststatic/url_image/www.z.cn|.png'\
@ error/png.c/ReadPNGImage/2951.
rm: mogrify: unable to open image `./teststatic/url_image/www.z.cn|.jpg': \
jpeg.la @ error/blob.c/OpenBlob/2489cannot remove `./teststatic/url_image
...
...
У трубы есть некоторые проблемы, как мне решить эту проблему?