def rotate(request, albumName, fileName, angle): # {{{ if (int(angle) % 90) == 0: options = getSettings(CONFIG_FILE, 'Options') (requestedAlbum, requestedPicture) = getAlbumAndPictureOr404(albumName, fileName) image = Image(options['media'] + requestedAlbum.path + requestedPicture.filename, options) image.rotate(angle) image.save() image.resize() image.save(type = 'MS') image.thumbnail() image.save(type = 'T') return HttpResponseRedirect('/' + albumName)
def addPictures(album): # {{{ options = getSettings(CONFIG_FILE, 'Options') dirPath, dirNames, files = walk(options['media'] + album.name).next() for pfile in files: # We do this to make sure that scaled images from prior is not added to the # gallery it self. Also this will prevent hidden files to be added to the # gallery. if pfile[:3] == 'MS_' or pfile[:2] == 'T_' or pfile[:1] == '.': continue # If the "image" is not able to open, then something is wrong or it is # probably not a picture and we just iterate to the next file. try: image = Image(dirPath + '/' + pfile, options) except IOError: continue picture = Picture( album_id = album, filename = pfile, img_format = image.format, mode = image.mode, size_x = image.size[0], size_y = image.size[1] ) picture.save() maxSizeImage = image.resize() maxSizeImage.save(options['media'] + album.name + '/MS_' + picture.filename) image.thumbnail() image.save(options['media'] + album.name + '/T_' + picture.filename) if album.index_image_filename is None: album.index_image_filename = 'T_' + picture.filename album.save()