Coder Social home page Coder Social logo

flask-thumbnails's People

Contributors

bostrt avatar dependabot[bot] avatar jaza avatar jonashoechst avatar silentsokolov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flask-thumbnails's Issues

alternate MEDIA_THUMBNAIL_FOLDER does not work

If I try to set an alternate folder via
app.config['MEDIA_THUMBNAIL_FOLDER']
app.config['MEDIA_THUMBNAIL_URL']

I see that it allways try to write to the original folder.

The problem is that in init.py/class Thumbnail/thumb_url = os.path.join(self.app.config['MEDIA_THUMBNAIL_URL'], url_path, miniature)

url_path starts_with trailing '/' and this leads to:
thumb_filename='%s/%s' % (url_path,minitature)
-> same for thumb_url

You can see what happens if you use
os.path.join('/a','/b','/c') vs
os.path.join('/a','b/b','/c')

Thumbnails on S3

This is just a quick note, to let you know that I've created a fork of flask-thumbnails called 'flask-thumbnails-s3', which is up here:

https://github.com/Jaza/flask-thumbnails-s3

It works pretty much the same as flask-thumbnails when set to use the local filesystem, but it can also be set to load / save thumbnails to an Amazon S3 bucket.

Thanks to silentsokolov and the other contributors of flask-thumbnails, for the code that I've re-used in flask-thumbnails-s3, and thanks for the generous MIT license - I believe I've followed the terms of the license (and the spirit of open source in general), but let me know if you have any issue with this fork.

If anyone else needs flask thumbnails working via S3, hope this new project is of use to you.

(And feel free to close this issue whenever you want).

PNG thumbnail error

If you try to thumbnail a PNG (with alpha channel) you get an Pillow error:

    File ".../python3.6/site-packages/PIL/JpegImagePlugin.py", line 604, in _save

    raise IOError("cannot write mode %s as JPEG" % im.mode)

    OSError: cannot write mode RGBA as JPEG

Nested Variable

I love your plugin, but I'm looking for a way to have the file name be variable. Something like this, though it doesn't work:

<img src="{{  {{image_name}} |thumbnail('200x200') }}" alt="" />

Thanks!

Remove Pillow version requirement

Currently, flask_thumbnails requires Pillow 2.2.1. This old version of Pillow has an installation bug.

Can the required version number be removed, or at least updated to 2.6.0? As far as I can tell, this version of Pillow works fine for flask_thumbnails.

thumbnail_filepath in get_thumbnail function incorrect calculated

In Option settings said, as i understand, i can set THUMBNAIL_MEDIA_THUMBNAIL_ROOT and thumbs will be saved there.

So i set:

ROOT_PATH = os.path.join('/home/devadmin','.cdnstatic')
THUMBNAIL_MEDIA_ROOT = ROOT_PATH
THUMBNAIL_MEDIA_THUMBNAIL_ROOT = os.path.join(ROOT_PATH,'.thumbnails')

So, paths will be:
/home/devadmin/.cdnstatic
/home/devadmin/.cdnstatic/.thumbnails

My originals saved in other path:

/home/devadmin/.cdnstatic/digital_image/1023/68/1-first.jpeg

Next, function calculated parameters:

original_filepath = os.path.join(self.root_directory, original_path, original_filename)
That is correct: /home/devadmin/.cdnstatic/digital_image/1023/68/1-first.jpeg

But:
thumbnail_filepath = os.path.join(self.thumbnail_directory, original_path, thumbnail_filename)
calculated as: /home/devadmin/.cdnstatic/digital_image/1023/68/<thumbnail_filename>

So my thumbs saved in same directory as originals. I try to swap <self.thumbnail_directory> and <original_path> (i think need to remove <original_path>), then it calculated as i expected: /home/devadmin/.cdnstatic/.thumbnails/<thumbnail_filename>

Same for thumbnail_url function

Can you fix this, or am I wrong and am doing something wrong?

Pillow dependency

Why do you prompt for the user to manually install you package dependencies instead of putting them in your setup.py so that they aree automatically installed with your package ?

Jinja filter not working

I'm unsure how to use the thumbnails.

<img src="{{ image|thumbnail('200x200') }}" />

Is not working.

How I got it working is:

<img src="{{ url_for('uploaded_file_thumb', filename=image, size='200x200') }}" />

And the app.py:

app = Flask(__name__)

thumb = Thumbnail(app)

...

@app.route('/thumb/<filename>/<size>')
def uploaded_file_thumb(filename, size):
    t = thumb.thumbnail(filename, size)
    return send_from_directory(app.config['UPLOAD_FOLDER'], t)

Unable to install

Hey there,

I'm trying to install your extension via:

pip install git+https://github.com/SilentSokolov/flask-thumbnails.git

But I keep getting the error:

p11-kit: couldn't load module: /usr/lib/x86_64-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: /usr/lib/x86_64-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: cannot open shared object file: No such file or directory

I'm using Ubuntu x64. I've tried to install the p11-kit and it installs, but I still can't install flask-thumbnails.

Any ideas what I should do?

Many thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.