<commit_before># -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2008, 2009, 2010, 2011, 2012 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""This is websubmit_icon_creator.py
   This tool is used to create an icon of a picture file.

   + Python API:
      Please see create_icon().

   + CLI API:

##     $ python ~invenio/lib/python/invenio/websubmit_icon_creator.py \\
##               --icon-scale=200 \\
##               --icon-name=test-icon \\
##               --icon-file-format=jpg \\
##               test-image.jpg

##     $ python ~invenio/lib/python/invenio/websubmit_icon_creator.py \\
##               --icon-scale=200 \\
##               --icon-name=test-icon2 \\
##               --icon-file-format=gif \\
##               --multipage-icon \\
##               --multipage-icon-delay=50 \\
##               test-image2.pdf
"""

__revision__ = "$Id$"

import os.path, sys, getopt, shutil, tempfile, re
from invenio.config import \
     CFG_TMPDIR, \
     CFG_PATH_PS2PDF, \
     CFG_PATH_PDFTK, \
     CFG_PATH_CONVERT
from invenio.shellutils import escape_shell_arg
from invenio.websubmit_config import InvenioWebSubmitIconCreatorError

CFG_ALLOWED_FILE_EXTENSIONS = ["pdf", "gif", "jpg", \
                               "jpeg", "ps", "png", "bmp", \
                               "eps", "epsi", "epsf"]


## ***** Functions related to the icon creation process: *****

# Accepted format for the ImageMagick 'scale' parameter:
re_imagemagic_scale_parameter_format = re.compile(r'x?\d+(x\d*)?(^|!|>|<|@|%)?$')<commit_msg>WebSubmit: allow image conversion of .tiff<commit_after># -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2008, 2009, 2010, 2011, 2012 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""This is websubmit_icon_creator.py
   This tool is used to create an icon of a picture file.

   + Python API:
      Please see create_icon().

   + CLI API:

##     $ python ~invenio/lib/python/invenio/websubmit_icon_creator.py \\
##               --icon-scale=200 \\
##               --icon-name=test-icon \\
##               --icon-file-format=jpg \\
##               test-image.jpg

##     $ python ~invenio/lib/python/invenio/websubmit_icon_creator.py \\
##               --icon-scale=200 \\
##               --icon-name=test-icon2 \\
##               --icon-file-format=gif \\
##               --multipage-icon \\
##               --multipage-icon-delay=50 \\
##               test-image2.pdf
"""

__revision__ = "$Id$"

import os.path, sys, getopt, shutil, tempfile, re
from invenio.config import \
     CFG_TMPDIR, \
     CFG_PATH_PS2PDF, \
     CFG_PATH_PDFTK, \
     CFG_PATH_CONVERT
from invenio.shellutils import escape_shell_arg
from invenio.websubmit_config import InvenioWebSubmitIconCreatorError

CFG_ALLOWED_FILE_EXTENSIONS = ["pdf", "gif", "jpg", \
                               "jpeg", "ps", "png", "bmp", \
                               "eps", "epsi", "epsf", \
                               "tiff", "tif"]


## ***** Functions related to the icon creation process: *****

# Accepted format for the ImageMagick 'scale' parameter:
re_imagemagic_scale_parameter_format = re.compile(r'x?\d+(x\d*)?(^|!|>|<|@|%)?$')
{'fraction_non_alphanumeric': 0.1298787210584344, 'fraction_numerical': 0.020727673649393607, 'mean_word_length': 2.527216174183515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '521340', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1380, 'n_words': 434}