GithubHelp home page GithubHelp logo

betty-cropper's Issues

Image optimization on upload

We should be saving images to a lossless original version at the MAX_WIDTH setting, so that subsequent crops won't have to crop from a huge original file.

Create cropping view

We should be self-hosting some type of cropping view, with JCrop, etc already included.

Django admin widgets

We should have a widget that allows the upload, search and cropping of images.

URL routes should match finite crop ratios

All views seem to validate & raise Http404 if given ratio_slug doesn't match pre-defined enumerations. Why bother with views at all, if the regex can reject bad request at the route level.

index f14190f..c5e2076 100644
--- a/betty/cropper/urls.py
+++ b/betty/cropper/urls.py
@@ -3,11 +3,11 @@ from django.conf.urls import patterns, url, include
 urlpatterns = patterns('betty.cropper.views',
     url(r'image\.js', "image_js"),
     url(  # noqa
-        r'^(?P<id>\d{5,})/(?P<ratio_slug>[a-z0-9]+)/(?P<width>\d+)\.(?P<extension>(jpg|png))',
+        r'^(?P<id>\d{5,})/(?P<ratio_slug>(original|1x1|2x1|3x1|3x4|4x3|16x9))/(?P<width>\d+)\.(?P<extension>(jpg|png))',
         'redirect_crop'
     ),
     url(  # noqa
-        r'^(?P<id>[0-9/]+)/(?P<ratio_slug>[a-z0-9]+)/(?P<width>\d+)\.(?P<extension>(jpg|png))',
+        r'^(?P<id>[0-9/]+)/(?P<ratio_slug>(original|1x1|2x1|3x1|3x4|4x3|16x9))/(?P<width>\d+)\.(?P<extension>(jpg|png))',
         'crop'
     ),
     url(r'api/', include("betty.cropper.api.urls")),

Better yet, just compile a regex directly from settings

re.compile('(original|{})'.format('|'.join(betty.conf.app.settings.BETTY_RATIOS))

Then reduce

--- a/betty/cropper/views.py
+++ b/betty/cropper/views.py
@@ -56,13 +56,6 @@ def redirect_crop(request, id, ratio_slug, width, extension):

 @cache_control(max_age=300)
 def crop(request, id, ratio_slug, width, extension):
-    if ratio_slug != "original" and ratio_slug not in settings.BETTY_RATIOS:
-        raise Http404
-

Change to markup results in error on refresh

Made a change to markup within the forloop for image results. On refresh, I'll get this error sometimes:

Assertion failed: (file != (FILE *) NULL), function MagickReadImageFile, file wand/magick-image.c, line 8739.
Abort trap: 6

I'm seeing this every so often and am filing in case it's something more sinister

/api/new should return image type (and animated property?)

When uploading inline images, I'd like to get the format passed back so I can update the markup properly. Right now, the filename is getting returned and I can use the extension to determine if a file is a gif or not, however that's not that great.

Gifs aren't always animated, either. Maybe /api/new should return whether an image is animate or not, too.

Prevent DDOS by disk space usage

Should probably take a few steps to help prevent this.

  1. We should be issuing warnings when we think that there might not be enough free space on a device. This could be based on the number of images/width settings.
  2. If a crop is requested at a WIDTH that isn't in the settings, we should return the crop (with proper cache headers), but should not save it to the filesystem.

0.3

Should have a number of improvements, like image optimization, responsive image js, etc.

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.