<commit_before>#!/usr/bin/env python2

'''FFTresize resizes images using zero-padding in the frequency
domain.
'''

from numpy import zeros as _zeros

from . import fftinterp
from . import imutils


__author__ = '<NAME>'
__copyright__ = 'Copyright 2013, <NAME>'
__license__ = 'ISC'
__version__ = '0.2'
__email__ = '<EMAIL>'
__status__ = 'Development'


def resize(filename, factor=1.5):
    '''Resize an image by zero-padding in the frequency domain.

    Return the filename of the resized image.
    '''
    img = imutils.read(filename)
    nchannels = imutils.channels(img)
    if nchannels == 1:
        new = fftinterp.interp2(img, factor)
    else:
        new = None
        for i in range(nchannels):
            rgb = img[:, :, i]
            newrgb = fftinterp.interp2(rgb, factor)
            if new is None:
                newsize = list(newrgb.shape)
                newsize.append(imutils.channels(img))
                new = _zeros(tuple(newsize))
            new[:, :, i] = newrgb
    return imutils.save(new, filename)


if '__main__' in __name__:
    pass
<commit_msg>Bump to version 0.3.<commit_after>#!/usr/bin/env python2

'''FFTresize resizes images using zero-padding in the frequency
domain.
'''

from numpy import zeros as _zeros

from . import fftinterp
from . import imutils


__author__ = '<NAME>'
__copyright__ = 'Copyright 2013, <NAME>'
__license__ = 'ISC'
__version__ = '0.3'
__email__ = '<EMAIL>'
__status__ = 'Development'


def resize(filename, factor=1.5):
    '''Resize an image by zero-padding in the frequency domain.

    Return the filename of the resized image.
    '''
    img = imutils.read(filename)
    nchannels = imutils.channels(img)
    if nchannels == 1:
        new = fftinterp.interp2(img, factor)
    else:
        new = None
        for i in range(nchannels):
            rgb = img[:, :, i]
            newrgb = fftinterp.interp2(rgb, factor)
            if new is None:
                newsize = list(newrgb.shape)
                newsize.append(imutils.channels(img))
                new = _zeros(tuple(newsize))
            new[:, :, i] = newrgb
    return imutils.save(new, filename)


if '__main__' in __name__:
    pass

{'fraction_non_alphanumeric': 0.11279229711141678, 'fraction_numerical': 0.01192113709307657, 'mean_word_length': 2.5193548387096776, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7020807', 'n_tokens_mistral': 732, 'n_tokens_neox': 696, 'n_words': 201}