Esempio n. 1
0
def convert_solo(options, ext=None):
    options = re_whitespace.sub(' ', options.strip())
    dest = get_mediafile(options, ext)
    if not dest.exists():
        args = "%s %s" % (options, dest.path)
        helpers.execute(settings.CONVERT_PATH, args)
        dest._write_metadata({'relation': [options]})
    return dest
Esempio n. 2
0
def convert_solo(options, ext=None):
    options = re_whitespace.sub(' ', options.strip())
    dest = get_mediafile(options, ext)
    if not dest.exists():
        args = "%s %s" % (options, dest.path)
        helpers.execute(settings.CONVERT_PATH, args)
        dest._write_metadata({'relation': [options]})
    return dest
Esempio n. 3
0
 def convert(self, options, ext=None):
     # we sanitize relation since this is base for the seed and the output
     # filename
     options = "%s %s %s" % (settings.CONVERT_PREPEND, options, settings.CONVERT_APPEND)
     options = re_whitespace.sub(" ", options.strip())
     dest = get_mediafile(options + self.name, ext)
     if not dest.exists() or getmtime(dest.path) < getmtime(self.path):
         args = '"%s" %s "%s"' % (self.path, options, dest.path)
         helpers.execute(settings.CONVERT_PATH, args)
         dest._write_metadata({"source": self.name, "relation": [options]})
     return dest
Esempio n. 4
0
 def convert(self, options, ext=None):
     # we sanitize relation since this is base for the seed and the output
     # filename
     options = "%s %s %s" % (settings.CONVERT_PREPEND, options,
             settings.CONVERT_APPEND)
     options = re_whitespace.sub(' ', options.strip())
     dest = get_mediafile(options + self.name, ext)
     if not dest.exists() or getmtime(dest.path) < getmtime(self.path):
         args = '"%s" %s "%s"' % (self.path, options, dest.path)
         helpers.execute(settings.CONVERT_PATH, args)
         dest._write_metadata({'source': self.name, 'relation': [options]})
     return dest
Esempio n. 5
0
 def convert(self, options, ext=None):
     # we sanitize relation since this is base for the seed and the output
     # filename
     options = "%s %s %s" % (settings.CONVERT_PREPEND, options,
             settings.CONVERT_APPEND)
     options = re_whitespace.sub(' ', options.strip())
     dest = get_mediafile(options + self.name, ext)
     if not dest.exists() or getmtime(dest.path) < getmtime(self.path):
         args = '"%s" %s "%s"' % (self.path, options, dest.path)
         helpers.execute(settings.CONVERT_PATH, args)
         dest._write_metadata({'source': self.name, 'relation': [options]})
         if jpegoptim and dest.path.endswith('.jpg'):
             helpers.execute(jpegoptim, '--strip-all {}'.format(dest.path))
         if optipng and dest.path.endswith('.png'):
             helpers.execute(optipng, '--quiet {}'.format(dest.path))
     return dest
Esempio n. 6
0
from os.path import isfile, isdir, getmtime, dirname, getsize, normpath, join as pjoin
from PIL import Image
from django.utils.encoding import force_unicode, smart_str, iri_to_uri
from django.utils._os import safe_join
from django.utils.safestring import mark_safe
from convert import helpers
from convert.conf import settings

re_remote = re.compile(r'^(https?|ftp):\/\/')
re_whitespace = re.compile(r'\s{2,}')
re_ext = re.compile(r'\.([a-zA-Z]{2,4})$')

jpegoptim = None
optipng = None
try:
    jpegoptim = helpers.execute('which', 'jpegoptim').strip()
except:
    pass
try:
    optipng = helpers.execute('which', 'optipng').strip()
except:
    pass


class MediaFile(object):
    """
    A media file wrapper, targeted for image manipulation using
    ImageMagick convert.
    """
    def __init__(self, name):
        name = force_unicode(name)
Esempio n. 7
0
from PIL import Image
from django.utils.encoding import force_unicode, smart_str, iri_to_uri
from django.utils._os import safe_join
from django.utils.safestring import mark_safe
from convert import helpers
from convert.conf import settings


re_remote = re.compile(r'^(https?|ftp):\/\/')
re_whitespace = re.compile(r'\s{2,}')
re_ext = re.compile(r'\.([a-zA-Z]{2,4})$')

jpegoptim = None
optipng = None
try:
    jpegoptim = helpers.execute('which','jpegoptim').strip()
except:
    pass
try:
    optipng = helpers.execute('which','optipng').strip()
except:
    pass


class MediaFile(object):
    """
    A media file wrapper, targeted for image manipulation using
    ImageMagick convert.
    """
    def __init__(self, name):
        name = force_unicode(name)